diff --git a/.gitignore b/.gitignore index 93c7eb248..bc936c34c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ .DS_Store public/api_doc/ /.metadata +vendor/cache diff --git a/.metadata/.plugins/com.aptana.index.core/2874248206.index b/.metadata/.plugins/com.aptana.index.core/2874248206.index deleted file mode 100644 index 2200403a8..000000000 Binary files a/.metadata/.plugins/com.aptana.index.core/2874248206.index and /dev/null differ diff --git a/.metadata/.plugins/com.aptana.index.core/2924452064.index b/.metadata/.plugins/com.aptana.index.core/2924452064.index deleted file mode 100644 index 982acfcbc..000000000 Binary files a/.metadata/.plugins/com.aptana.index.core/2924452064.index and /dev/null differ diff --git a/.metadata/.plugins/com.aptana.index.core/4010369919.index b/.metadata/.plugins/com.aptana.index.core/4010369919.index deleted file mode 100644 index e2902378c..000000000 Binary files a/.metadata/.plugins/com.aptana.index.core/4010369919.index and /dev/null differ diff --git a/Gemfile b/Gemfile index 4f2f47682..29b2716a9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,4 @@ -source 'http://rubygems.org' -#source 'http://ruby.taobao.com' +source 'http://ruby.taobao.org' #source 'http://ruby.sdutlinux.org/' unless RUBY_PLATFORM =~ /w32/ @@ -11,11 +10,11 @@ end gem 'grape', '~> 0.9.0' gem 'grape-entity' -gem 'seems_rateable', path: 'lib/seems_rateable' +gem 'seems_rateable', '~> 1.0.13' gem "rails", "3.2.13" gem "jquery-rails", "~> 2.0.2" gem "i18n", "~> 0.6.0" -gem "coderay", "~> 1.0.6" +gem 'coderay', '~> 1.1.0' gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "builder", "3.0.0" gem 'acts-as-taggable-on', '2.4.1' @@ -28,11 +27,16 @@ gem 'rails_kindeditor' group :development do gem 'grape-swagger' #gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git' - #gem 'puma' + gem 'puma' if RbConfig::CONFIG['host_os'] =~ /linux/ gem 'pry-rails' - gem 'pry-byebug' - gem 'better_errors', path: 'lib/better_errors' - gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' + if RUBY_VERSION >= '2.0.0' + gem 'pry-byebug' + else + gem 'pry-debugger' + end + gem 'pry-stack_explorer' + gem 'better_errors', '~> 1.1.0' + gem 'rack-mini-profiler', '~> 0.9.3' end group :test do diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 9b66c047f..c055d38ae 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -873,13 +873,15 @@ class CoursesController < ApplicationController "show_course_news" => true, "show_course_messages" => true, "show_bids" => true, - "show_course_journals_for_messages" => true + "show_course_journals_for_messages" => true, + "show_homeworks" => true } @date_to ||= Date.today + 1 # @date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date #@date_from = @date_to - @days-1.years @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) + @author ||= @course.teacher # 决定显示所用用户或单个用户活动 @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, :with_subprojects => false, diff --git a/app/controllers/git_callback_controller.rb b/app/controllers/git_callback_controller.rb new file mode 100644 index 000000000..717a22961 --- /dev/null +++ b/app/controllers/git_callback_controller.rb @@ -0,0 +1,9 @@ +class GitCallbackController < ApplicationController + + def post_update + @repository = Repository.find_by_root_url(params[:root_url]) + @repository.fetch_changesets + render :text => 'success' + end + +end \ No newline at end of file diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index da2855582..de9477b8a 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -58,7 +58,7 @@ class IssuesController < ApplicationController def index retrieve_query - sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) + sort_init(@query.sort_criteria.empty? ? [['updated_on', 'desc']] : @query.sort_criteria) sort_update(@query.sortable_columns) @query.sort_criteria = sort_criteria.to_a @@ -381,7 +381,7 @@ class IssuesController < ApplicationController def retrieve_previous_and_next_issue_ids retrieve_query_from_session if @query - sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) + sort_init(@query.sort_criteria.empty? ? [['updated_on', 'desc']] : @query.sort_criteria) sort_update(@query.sortable_columns, 'issues_index_sort') limit = 500 issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version]) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index ba312c74a..aaaa4484d 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -109,7 +109,7 @@ class MembersController < ApplicationController end if params[:flag] unless members.present? && members.all? {|m| m.valid? } - flash[:error] = members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ') + flash[:error] = members.empty? ? l(:label_user_role_null) :members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ') else flash[:notice] = l(:label_invite_success) end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 44e5fd8a3..e9a27cf44 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -340,6 +340,7 @@ class ProjectsController < ApplicationController @is_zhuce =false flash[:notice] = l(:notice_email_sent, :value => email) else + flash[:error] = l(:notice_registed_success, :value => email) @is_zhuce = true end respond_to do |format| diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0c1f65317..6c115fc11 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -92,6 +92,22 @@ class RepositoriesController < ApplicationController render :action => 'show', :layout => 'base_projects' end + + HOOK_TEMPLATE = %Q{#!/bin/sh +exec sh -c ' +function update() +{ + CMD_PATH=`dirname $0`; + cd $CMD_PATH; + PY_PATH=$PWD/../../git_refresh_changes.py; + [[ -s "$PY_PATH" ]] && $(which python) $PY_PATH $PWD; + cd -; +} +git update-server-info +update +' + } + def create if params[:repository_scm].to_s == 'Gitlab' # add by nwb @@ -127,7 +143,6 @@ class RepositoriesController < ApplicationController if attrs[:attrs_extra].keys.any? @repository.merge_extra_info(attrs[:attrs_extra]) end - #by xianbo @repository.project = @project if request.post? && @repository.save @@ -145,12 +160,11 @@ class RepositoriesController < ApplicationController " \n ' >> "+ @root_path+"htdocs/"+ @repository_name+"/.htaccess" system "cd "+@project_path+" ;git update-server-info" - # if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info) - # else - # logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+ - # crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+ - # "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info - # end + + File.open(@project_path+"/hooks/post-update", "w+") do |f| + f.write(HOOK_TEMPLATE) + end + @repository.update_attributes(:login => User.current.login.to_s) end redirect_to settings_project_url(@project, :tab => 'repositories') @@ -160,6 +174,8 @@ class RepositoriesController < ApplicationController render :action => 'new', :layout =>'base_projects' end end + + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d770a4633..4db471ab4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -445,15 +445,15 @@ class UsersController < ApplicationController else activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc') end - activity = activity.reject { |e| - e.act.nil? || - (!User.current.admin? && !e.act.nil? - (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) || - (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) || - (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) || - (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) || - (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))) - } + # activity = activity.reject { |e| + # e.act.nil? || + # (!User.current.admin? && !e.act.nil? + # (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) || + # (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) || + # (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) || + # (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) || + # (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))) + # } @activity_count = activity.count @activity_pages = Paginator.new @activity_count, pre_count, params['page'] @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9629ed437..b4f54f075 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1994,4 +1994,10 @@ module ApplicationHelper end technical_title end + + + def ie8? + request.env["HTTP_USER_AGENT"] =~ /MSIE 8.0/ + end + end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 221331338..02bc3d8b3 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -43,7 +43,7 @@ module WatchersHelper ) method = watched ? 'delete' : 'post' - link_to text, url, :remote => true, :method => method, :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 22px; line-height: 22px; background: none repeat scroll 0% 0% #64BDD9; TES" + link_to text, url, :remote => true, :method => method, :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 22px; line-height: 21px;padding-top:1px; background: none repeat scroll 0% 0% #64BDD9; TES" end ############## added by linchun @@ -278,11 +278,11 @@ module WatchersHelper ) method = applied ? 'delete' : 'post' - link_to text, url, :remote => true, :method => method ,:style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 22px; line-height: 22px; background: none repeat scroll 0% 0% #64BDD9; TES" + link_to text, url, :remote => true, :method => method ,:style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 21px; line-height: 22px;padding-top:1px; background: none repeat scroll 0% 0% #64BDD9; TES" end def exit_project_link(project) link_to(l(:label_exit_project),exit_cur_project_path(project.id), - :remote => true, :confirm => l(:lable_sure_exit_project), :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 22px; line-height: 22px; background: none repeat scroll 0% 0% #64BDD9; TES" ) + :remote => true, :confirm => l(:lable_sure_exit_project), :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 21px; line-height: 22px; background: none repeat scroll 0% 0% #64BDD9; TES;padding-top:1px;" ) end end diff --git a/app/models/bid.rb b/app/models/bid.rb index e5de47b24..10476b4d3 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -61,14 +61,21 @@ class Bid < ActiveRecord::Base end } + scope :course_visible, lambda {|*args| + includes(:courses).where(Course.allowed_to_condition(args.shift || User.current, :view_homeworks, *args)) + } + acts_as_watchable acts_as_taggable - acts_as_event :title => Proc.new {|o| "#{l(:label_requirement)} ##{o.id}: #{o.name}" }, + acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" }, :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}} + acts_as_activity_provider :type => 'homeworks', + :author_key => :author_id + acts_as_activity_provider :find_options => {:include => [:projects, :author]}, :author_key => :author_id diff --git a/app/models/user.rb b/app/models/user.rb index 860eb56a5..9abe80779 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -778,7 +778,7 @@ class User < Principal (block_given? ? yield(role, self) : true) } #添加课程相关的权限判断 - elsif context && context.is_a?(Course) + elsif context && context.is_a?(Course) return false unless context.allows_to?(action) # Admin users are authorized for anything else return true if admin? diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb index 92690d1db..09c88e6df 100644 --- a/app/models/user_extensions.rb +++ b/app/models/user_extensions.rb @@ -32,40 +32,42 @@ class UserExtensions < ActiveRecord::Base def get_brief_introduction return self.brief_introduction end - + + # added by meng def show_identity - if self.identity == 0 - if User.current.language == 'zh' - user_identity = '教师' - else - user_identity = 'Teacher' - end - elsif self.identity == 1 - if User.current.language == 'zh' - user_identity = '学生' - else - user_identity = 'Student' - end - elsif self.identity == 2 - if User.current.language == 'zh' - user_identity = '企业' - else - user_identity = 'Enterprise' - end - elsif self.identity == 3 - if User.current.language == 'zh' - user_identity = '开发者' - else - user_identity = 'Developer' + if User.current.language == 'zh'||User.current.language == '' + case self.identity + when 0 + user_identity = l(:label_account_identity_teacher) + when 1 + user_identity = l(:label_account_identity_student) + when 2 + user_identity = l(:label_account_identity_enterprise) + when 3 + user_identity = l(:label_account_identity_developer) + else + user_identity = '' end else - user_identity = '' + case self.identity + when 0 + user_identity = l(:label_account_identity_teacher) + when 1 + user_identity = l(:label_account_identity_student) + when 2 + user_identity = l(:label_account_identity_enterprise) + when 3 + user_identity = l(:label_account_identity_developer) + else + user_identity = '' + end end return user_identity end -# end - +# end + + def self.introduction(user, message) unless user.user_extensions.nil? info = user.user_extensions diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 22dc447f2..67ae4ce66 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -1,6 +1,6 @@ <% if defined?(container) && container && container.saved_attachments %> - <% container.attachments.each_with_index do |attachment, i| %> + <% container.saved_attachments.each_with_index do |attachment, i| %> - - <%# - If Rails's Turbolinks is used, the Better Errors page is probably - rendered in the host app's layout. Let's empty out the styles of the - host app. - %> - - - <% end %> - <% end %>
<%= exception.message %>
-