课程标签增加、删除

This commit is contained in:
nwb 2014-06-12 16:22:35 +08:00
parent 3933817570
commit c8900c279c
7 changed files with 27 additions and 5 deletions

View File

@ -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

View File

@ -15,6 +15,7 @@ class TagsController < ApplicationController
include ContestsHelper
include ActsAsTaggableOn::TagsHelper
helper :projects
helper :courses
include TagsHelper
helper :tags
include OpenSourceProjectsHelper

View File

@ -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

View File

@ -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},

View File

@ -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

View File

@ -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>

View File

@ -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 %>