diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 7258b076..d58b9bdf 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -141,6 +141,7 @@ class AccountController < ApplicationController @resubmit = "#{code}" @agreement = Help.first @cooperation = Cooperation.all + @url = params[:url] @com_coop_img = CooImg.where(:img_type => 'com_coop').order("position asc") @edu_coop_img = CooImg.where(:img_type => 'edu_coop').order("position asc") @@ -208,7 +209,7 @@ class AccountController < ApplicationController end def insert_suggest - content = "

[#{params[:question_kind]}]

" + params[:description] + content = "

[#{params[:question_kind]}]

" + "

问题页面网址:#{params[:url]}

" + params[:description] PrivateMessage.create(:user_id => User.current.id, :target_id => 1, :sender_id => User.current.id, :receiver_id => 1, :content => content, :send_time => Time.now, :status => 1) PrivateMessage.create(:user_id => 1, :target_id => User.current.id, :sender_id => User.current.id, :receiver_id => 1, :content => content, :send_time => Time.now, :status => 0) redirect_to message_detail_user_path(User.current, :user_id => 1) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index e526d468..a59747aa 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -242,14 +242,56 @@ class SubjectsController < ApplicationController memberships = params[:membership][:user_ids] memberships.each do |member| user = User.find(member) - SubjectMember.create!(:user_id => member, :subject_id => @subject.id, :role => 2) + SubjectMember.create!(:user_id => member, :subject_id => @subject.id, :role => 2, + :position => @subject.subject_members.size + 1) end end end def delete_member - member = @subject.subject_members.where(:user_id => params[:mem_id]).first - member.destroy if member + if User.current.admin? + ActiveRecord::Base.transaction do + member = @subject.subject_members.where(:id => params[:mem_id]).first + if member.present? && member.role != 1 + @subject.subject_members.where("position > #{member.position}").update_all("position = position - 1") + member.destroy + end + end + else + render_403 + end + end + + def up_member_position + if User.current.member_of_subject?(@subject) + ActiveRecord::Base.transaction do + member = @subject.subject_members.where(:id => params[:mem_id]).first + raise "不能再上移了" if member.position == 1 + up_member = @subject.subject_members.where(:position => member.position - 1).first + up_member.update_attribute(:position, member.position) + member.update_attribute(:position, member.position - 1) + end + else + render_403 + end + end + + def down_member_position + if User.current.member_of_subject?(@subject) + ActiveRecord::Base.transaction do + begin + member = @subject.subject_members.where(:id => params[:mem_id]).first + raise "不能再下移了" if member.position == @subject.subject_members.count + down_member = @subject.subject_members.where(:position => member.position + 1).first + down_member.update_attribute(:position, member.position) + member.update_attribute(:position, member.position + 1) + rescue Exception => e + raise ActiveRecord::Rollback + end + end + else + render_403 + end end def statistics diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3868f5a5..5a160436 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2559,6 +2559,15 @@ class UsersController < ApplicationController end end @objects_count = @objects.size + + # 用户访问自己主页的"我管理的"列表,且是第一页才显示新建入口 + page = params[:page] ? params[:page].to_i : 1 + @new_icon = @user == User.current && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) && page == 1 + + # 用户进自己主页的全部列表时有个新建入口,加一个"new",view层的第一页需要shift,这样翻页就没问题啦 + @objects = @objects.to_a + @objects.unshift("new") if @new_icon + @objects = paginateHelper @objects, 16 respond_to do |format| diff --git a/app/models/school.rb b/app/models/school.rb index 62e27987..8d377e97 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -66,4 +66,10 @@ class School < ActiveRecord::Base dep = departments.where("identifier is not null").first url = dep.present? ? "/colleges/#{dep.identifier}/statistics" : "" end + + def course_act_time + CourseActivity.find_by_sql("SELECT max(ca.updated_at) as max_update FROM course_activities ca left join courses on ca.course_id = + courses.id LEFT JOIN user_extensions ON courses.tea_id=user_extensions.user_id WHERE + user_extensions.`school_id` = #{self.id}").first.try(:max_update) + end end diff --git a/app/models/subject.rb b/app/models/subject.rb index 59e84ee3..819d446c 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -2,7 +2,7 @@ class Subject < ActiveRecord::Base #status :0 编辑中 1 审核中 2 发布 # belongs_to :user has_many :users, :through => :subject_members - has_many :subject_members, :dependent => :destroy, :order => "subject_members.id ASC" + has_many :subject_members, :dependent => :destroy, :order => "subject_members.position asc" has_many :career_stages, :through => :career_stage_subjects has_many :career_stage_subjects, :dependent => :destroy diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 94ea2f6b..8573c683 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -65,7 +65,7 @@ class GamesService # power判断用户是否有权限查看隐藏测试集(TPM管理员;平台认证的老师;花费金币查看者) -1 表示不能解锁 0 表示需要付费解锁 1表示可以看 # myshixun_manager - myshixun_manager = shixun_manager(shixun, current_user) || (current_user.is_certification_teacher && shixun.test_set_permission) + myshixun_manager = shixun_manager(shixun, current_user) || (current_user.is_certification_teacher) power = (myshixun_manager || game.test_sets_view ) ? 1 : (shixun.test_set_permission ? 0 : -1) # 选择题和编程题公共部分 @@ -862,7 +862,7 @@ class GamesService Rails.logger.warn("last_output is #{latest_output}") # power判断用户是否有权限查看隐藏测试集(TPM管理员;平台认证的老师;花费金币查看者) - power = (shixun_manager(shixun, current_user) || (current_user.is_certification_teacher && shixun.test_set_permission)) ? 1 : (shixun.test_set_permission ? 0 : -1) + power = (shixun_manager(shixun, current_user) || (current_user.is_certification_teacher)) ? 1 : (shixun.test_set_permission ? 0 : -1) # 测试集统计及处理 unless qurey_test_sets.blank? check_power = (power == 1 || game.test_sets_view) diff --git a/app/views/account/_suggest_show.html.erb b/app/views/account/_suggest_show.html.erb index 9279d45a..e1891d13 100644 --- a/app/views/account/_suggest_show.html.erb +++ b/app/views/account/_suggest_show.html.erb @@ -1,6 +1,6 @@ <%= stylesheet_link_tag 'css/public','css/common'%> <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> <% end %>
@@ -15,79 +15,94 @@ - <%= form_for('new_form',:url => insert_suggest_path(), :html =>{:id => "insert_suggest"}, :method => :post) do |f| %> -
- *问题分类 -
- - - - - - -
-
-
- *问题描述 -
- - -
-

内容不能为空

- - - - - - - 提交 - <% end %> + +
+

内容不能为空

+ + + + + + + 提交
+ <% end %>