From c8900c279cd57c3a59050f7efb8ca09f912f0ba1 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 12 Jun 2014 16:22:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=A0=87=E7=AD=BE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E3=80=81=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 2 ++ app/controllers/tags_controller.rb | 7 ++++--- app/controllers/users_controller.rb | 4 ++++ app/helpers/courses_helper.rb | 11 +++++++++++ app/helpers/tags_helper.rb | 4 ++++ app/views/layouts/base_courses.html.erb | 2 +- app/views/tags/_tag_name.html.erb | 2 +- 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index b4b92cc38..b5c67478c 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -146,6 +146,8 @@ class FilesController < ApplicationController @obj = Contest.find_by_id(@obj_id) when '8' @obj = OpenSourceProject.find_by_id(@obj_id) + when '9' + @obj = Course.find_by_id(@obj_id) else @obj = nil end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 175041de9..4c0d91884 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -15,6 +15,7 @@ class TagsController < ApplicationController include ContestsHelper include ActsAsTaggableOn::TagsHelper helper :projects + helper :courses include TagsHelper helper :tags include OpenSourceProjectsHelper @@ -224,9 +225,9 @@ class TagsController < ApplicationController when '8' @obj = OpenSourceProject.find_by_id(obj_id) @obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags)) - when '9' then - @obj = Course.find_by_id(obj_id) - @obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags)) + when '9' then + @obj = Course.find_by_id(obj_id) + @obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags)) else @obj = nil end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bf1777508..bcdc5b171 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -669,6 +669,8 @@ class UsersController < ApplicationController @obj = Contest.find_by_id(@obj_id) when '8' @obj = OpenSourceProject.find_by_id(@obj_id) + when '9' + @obj = Course.find_by_id(@obj_id) else @obj = nil end @@ -710,6 +712,8 @@ class UsersController < ApplicationController @obj = Contest.find_by_id(@obj_id) when '8' @obj = OpenSourceProject.find_by_id(@obj_id) + when '9' + @obj = Course.find_by_id(@obj_id) else @obj = nil end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index d3c852d10..7f204102d 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -31,6 +31,17 @@ module CoursesHelper # searchStudent(project).count end + # 判断用户是否是课程的管理员 + # add by nwb + def is_course_manager?(user_id,course_id) + @result = false + @user_id = CourseInfo.find_by_course_id(course_id) + if @user_id == user.id + @result = true + end + return @result + end + # 返回课程设置界面 def course_settings_tabs tabs = [{:name => 'info', :action => :edit_course, :partial => 'courses/edit', :label => :label_information_plural}, diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index 201a582f2..8e9e6bbb9 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -16,6 +16,8 @@ module TagsHelper @obj = Attachment.find_by_id(obj_id) when '7' @obj= Contest.find_by_id(obj_id) + when '9' + @obj= Course.find_by_id(obj_id) else raise Exception, '[TagsHelper] ===> tag type unknow.' end @@ -46,6 +48,8 @@ module TagsHelper if user.id == obj_id @result = true end + when '9' + @result = is_course_manager?(user.id,obj_id) end return @result end diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index a180b2a64..2d59e0ed7 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -207,7 +207,7 @@
- <%= render :partial => 'tags/tag', :locals => {:obj => @course, :object_flag => "5"} %> + <%= render :partial => 'tags/tag', :locals => {:obj => @course, :object_flag => "9"} %>
diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb index 0b94264dd..f5057aba3 100644 --- a/app/views/tags/_tag_name.html.erb +++ b/app/views/tags/_tag_name.html.erb @@ -89,7 +89,7 @@ <% end %> <% when '9' %> - <% if (CourseInfo.find_by_course_id(obj.id)).try(:user_id) == User.current.id %> + <% if (CourseInfos.find_by_course_id(obj.id)).try(:user_id) == User.current.id %> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, :taggable_id => obj.id, :taggable_type => object_flag %> <% end %>