课程标签增加、删除
This commit is contained in:
parent
3933817570
commit
c8900c279c
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -207,7 +207,7 @@
|
|||
<!-- added by william -for tag -->
|
||||
<div class="user_tags">
|
||||
<div id="tags">
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @course, :object_flag => "5"} %>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @course, :object_flag => "9"} %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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 %>
|
||||
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,
|
||||
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in New Issue