课程标签增加、删除
This commit is contained in:
parent
3933817570
commit
c8900c279c
|
@ -146,6 +146,8 @@ class FilesController < ApplicationController
|
||||||
@obj = Contest.find_by_id(@obj_id)
|
@obj = Contest.find_by_id(@obj_id)
|
||||||
when '8'
|
when '8'
|
||||||
@obj = OpenSourceProject.find_by_id(@obj_id)
|
@obj = OpenSourceProject.find_by_id(@obj_id)
|
||||||
|
when '9'
|
||||||
|
@obj = Course.find_by_id(@obj_id)
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,7 @@ class TagsController < ApplicationController
|
||||||
include ContestsHelper
|
include ContestsHelper
|
||||||
include ActsAsTaggableOn::TagsHelper
|
include ActsAsTaggableOn::TagsHelper
|
||||||
helper :projects
|
helper :projects
|
||||||
|
helper :courses
|
||||||
include TagsHelper
|
include TagsHelper
|
||||||
helper :tags
|
helper :tags
|
||||||
include OpenSourceProjectsHelper
|
include OpenSourceProjectsHelper
|
||||||
|
|
|
@ -669,6 +669,8 @@ class UsersController < ApplicationController
|
||||||
@obj = Contest.find_by_id(@obj_id)
|
@obj = Contest.find_by_id(@obj_id)
|
||||||
when '8'
|
when '8'
|
||||||
@obj = OpenSourceProject.find_by_id(@obj_id)
|
@obj = OpenSourceProject.find_by_id(@obj_id)
|
||||||
|
when '9'
|
||||||
|
@obj = Course.find_by_id(@obj_id)
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
@ -710,6 +712,8 @@ class UsersController < ApplicationController
|
||||||
@obj = Contest.find_by_id(@obj_id)
|
@obj = Contest.find_by_id(@obj_id)
|
||||||
when '8'
|
when '8'
|
||||||
@obj = OpenSourceProject.find_by_id(@obj_id)
|
@obj = OpenSourceProject.find_by_id(@obj_id)
|
||||||
|
when '9'
|
||||||
|
@obj = Course.find_by_id(@obj_id)
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,6 +31,17 @@ module CoursesHelper
|
||||||
# searchStudent(project).count
|
# searchStudent(project).count
|
||||||
end
|
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
|
def course_settings_tabs
|
||||||
tabs = [{:name => 'info', :action => :edit_course, :partial => 'courses/edit', :label => :label_information_plural},
|
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)
|
@obj = Attachment.find_by_id(obj_id)
|
||||||
when '7'
|
when '7'
|
||||||
@obj= Contest.find_by_id(obj_id)
|
@obj= Contest.find_by_id(obj_id)
|
||||||
|
when '9'
|
||||||
|
@obj= Course.find_by_id(obj_id)
|
||||||
else
|
else
|
||||||
raise Exception, '[TagsHelper] ===> tag type unknow.'
|
raise Exception, '[TagsHelper] ===> tag type unknow.'
|
||||||
end
|
end
|
||||||
|
@ -46,6 +48,8 @@ module TagsHelper
|
||||||
if user.id == obj_id
|
if user.id == obj_id
|
||||||
@result = true
|
@result = true
|
||||||
end
|
end
|
||||||
|
when '9'
|
||||||
|
@result = is_course_manager?(user.id,obj_id)
|
||||||
end
|
end
|
||||||
return @result
|
return @result
|
||||||
end
|
end
|
||||||
|
|
|
@ -207,7 +207,7 @@
|
||||||
<!-- added by william -for tag -->
|
<!-- added by william -for tag -->
|
||||||
<div class="user_tags">
|
<div class="user_tags">
|
||||||
<div id="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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% when '9' %>
|
<% 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,
|
<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>
|
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in New Issue