增加访问作业显示列表的权限
This commit is contained in:
parent
56ce9e8bdb
commit
ed9b97f987
|
@ -450,78 +450,82 @@ class BidsController < ApplicationController
|
||||||
# 显示作业课程
|
# 显示作业课程
|
||||||
# add by nwb
|
# add by nwb
|
||||||
def show_courseEx
|
def show_courseEx
|
||||||
# flash[:notice] = ""
|
if (User.current.logged? && User.current.member_of_course?(@bid.courses.first))
|
||||||
@membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
# flash[:notice] = ""
|
||||||
@option = []
|
@membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||||
@membership.each do |membership|
|
@option = []
|
||||||
membership.member_roles.each{|role|
|
@membership.each do |membership|
|
||||||
if(role.role_id == 3)
|
membership.member_roles.each{|role|
|
||||||
@option << membership.course
|
if(role.role_id == 3)
|
||||||
end
|
@option << membership.course
|
||||||
}
|
end
|
||||||
end
|
}
|
||||||
|
|
||||||
@user = @bid.author
|
|
||||||
@bidding_project = @bid.biding_projects.all
|
|
||||||
|
|
||||||
if params[:student_id].present?
|
|
||||||
@temp = []
|
|
||||||
@bidding_project.each do |pro|
|
|
||||||
if pro.project && pro.project.project_status
|
|
||||||
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
|
||||||
@temp << pro
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@temp
|
|
||||||
end
|
end
|
||||||
@bidding_project = @temp
|
|
||||||
else
|
|
||||||
#added by nie
|
|
||||||
@temp = []
|
|
||||||
@bidding_project.each do |pro|
|
|
||||||
if pro.project && pro.project.project_status
|
|
||||||
@temp << pro
|
|
||||||
end
|
|
||||||
@temp
|
|
||||||
end
|
|
||||||
if @temp.size > 0
|
|
||||||
@bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
|
||||||
end
|
|
||||||
#ended
|
|
||||||
end
|
|
||||||
|
|
||||||
if @bid.homework_type == 1
|
@user = @bid.author
|
||||||
@homework = HomeworkAttach.new
|
@bidding_project = @bid.biding_projects.all
|
||||||
#@homework_list = @bid.homeworks
|
|
||||||
#增加作业按评分排序,
|
|
||||||
@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
|
|
||||||
if params[:student_id].present?
|
if params[:student_id].present?
|
||||||
@temp = []
|
@temp = []
|
||||||
@homework_list.each do |pro|
|
@bidding_project.each do |pro|
|
||||||
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
if pro.project && pro.project.project_status
|
||||||
|
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||||
|
@temp << pro
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@temp
|
||||||
|
end
|
||||||
|
@bidding_project = @temp
|
||||||
|
else
|
||||||
|
#added by nie
|
||||||
|
@temp = []
|
||||||
|
@bidding_project.each do |pro|
|
||||||
|
if pro.project && pro.project.project_status
|
||||||
@temp << pro
|
@temp << pro
|
||||||
end
|
end
|
||||||
@temp
|
@temp
|
||||||
end
|
end
|
||||||
@homework_list = @temp
|
if @temp.size > 0
|
||||||
|
@bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
||||||
|
end
|
||||||
|
#ended
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
if @bid.homework_type == 1
|
||||||
if @bid.reward_type == 3
|
@homework = HomeworkAttach.new
|
||||||
format.html {
|
#@homework_list = @bid.homeworks
|
||||||
render :layout => 'base_homework'
|
#增加作业按评分排序,
|
||||||
}
|
@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
|
||||||
elsif @bid.reward_type == 1
|
if params[:student_id].present?
|
||||||
format.html {
|
@temp = []
|
||||||
render :layout => 'base_bids'
|
@homework_list.each do |pro|
|
||||||
}
|
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||||
else
|
@temp << pro
|
||||||
format.html {
|
end
|
||||||
render :layout => 'base_contest'
|
@temp
|
||||||
}
|
end
|
||||||
|
@homework_list = @temp
|
||||||
|
end
|
||||||
end
|
end
|
||||||
format.api
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @bid.reward_type == 3
|
||||||
|
format.html {
|
||||||
|
render :layout => 'base_homework'
|
||||||
|
}
|
||||||
|
elsif @bid.reward_type == 1
|
||||||
|
format.html {
|
||||||
|
render :layout => 'base_bids'
|
||||||
|
}
|
||||||
|
else
|
||||||
|
format.html {
|
||||||
|
render :layout => 'base_contest'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
format.api
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,9 @@ module ApplicationHelper
|
||||||
# REVIEW: 目测menu的机制,貌似不是很需要转换,再说
|
# REVIEW: 目测menu的机制,貌似不是很需要转换,再说
|
||||||
def link_class(label)
|
def link_class(label)
|
||||||
labels = label.is_a?(Array) ? label : ([] << label)
|
labels = label.is_a?(Array) ? label : ([] << label)
|
||||||
|
#a = current_menu_item
|
||||||
labels.include?(current_menu_item) ? 'selected' : ''
|
labels.include?(current_menu_item) ? 'selected' : ''
|
||||||
|
|
||||||
end
|
end
|
||||||
#Ended by young
|
#Ended by young
|
||||||
# Return true if user is authorized for controller/action, otherwise false
|
# Return true if user is authorized for controller/action, otherwise false
|
||||||
|
|
|
@ -214,10 +214,9 @@
|
||||||
<% if User.current.member_of_course? course %>
|
<% if User.current.member_of_course? course %>
|
||||||
<li>
|
<li>
|
||||||
<% if User.current.logged? && course && (!Member.where('user_id = ? and course_id = ?', User.current.id, course.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, course.id).first.roles&Role.where('id = ? or id = ? or id =?', 5, 10, 7)).size >0) %>
|
<% if User.current.logged? && course && (!Member.where('user_id = ? and course_id = ?', User.current.id, course.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, course.id).first.roles&Role.where('id = ? or id = ? or id =?', 5, 10, 7)).size >0) %>
|
||||||
<%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_course'}, :class => link_class(:course) %>
|
<%= link_to l(:label_homework_commit), course_for_bid_path, :class => link_class(:course) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to l(:label_homework_info), {:controller => 'bids', :action => 'show_course'}, :class => link_class(:course) %>
|
<%#= link_to l(:label_homework_info), course_for_bid_path, :class => link_class(:course) %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in New Issue