admin用户能操作作业和作品

This commit is contained in:
sw 2015-06-04 17:24:50 +08:00
parent 89d15e7673
commit 243fa0af89
3 changed files with 25 additions and 4 deletions

View File

@ -200,7 +200,7 @@ class HomeworkCommonController < ApplicationController
end
#是不是课程的老师
def teacher_of_course
render_403 unless User.current.allowed_to?(:as_teacher,@course)
render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
end
def get_assigned_homeworks(student_works, n, index)

View File

@ -253,13 +253,13 @@ class StudentWorkController < ApplicationController
#是不是当前课程的成员
#当前课程成员才可以看到作品列表
def member_of_course
render_403 unless User.current.member_of_course? @course
render_403 unless User.current.member_of_course? @course || User.current.admin?
end
#判断是不是当前作品的提交者
#提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品
def author_of_work
render_403 unless User.current.id == @work.user_id && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
render_403 unless (User.current.id == @work.user_id || User.current.admin?) && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
end
#根据条件过滤作业结果

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150602055730) do
ActiveRecord::Schema.define(:version => 20150604153000) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -23,6 +23,20 @@ ActiveRecord::Schema.define(:version => 20150602055730) do
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
create_table "activity_notifies", :force => true do |t|
t.integer "activity_container_id"
t.string "activity_container_type"
t.integer "activity_id"
t.string "activity_type"
t.integer "notify_to"
t.datetime "created_on"
t.integer "is_read"
end
add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id"
add_index "activity_notifies", ["created_on"], :name => "index_an_created_on"
add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to"
create_table "api_keys", :force => true do |t|
t.string "access_token"
t.datetime "expires_at"
@ -606,6 +620,13 @@ ActiveRecord::Schema.define(:version => 20150602055730) do
t.datetime "updated_at", :null => false
end
create_table "invite_lists", :force => true do |t|
t.integer "project_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "issue_categories", :force => true do |t|
t.integer "project_id", :default => 0, :null => false
t.string "name", :limit => 30, :default => "", :null => false