Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
986fcc8b0c
|
@ -33,7 +33,7 @@ class BoardsController < ApplicationController
|
|||
#modify by nwb
|
||||
@flag = params[:flag] || false
|
||||
if @project
|
||||
if !@project.is_public? && !User.current.member_of?(@project) && !User.current.admin?
|
||||
if !@project.is_public? && !User.current.member_of?(@project) && !User.current.admin? && !User.current.allowed_to?(:view_messages, @project)
|
||||
render_403
|
||||
else
|
||||
@boards = @project.boards.includes(:last_message => :author).all
|
||||
|
|
|
@ -15,6 +15,7 @@ class ContestantWorksController < ApplicationController
|
|||
|
||||
def new
|
||||
#更新消息
|
||||
if @contestwork.work_status == 1
|
||||
noEvaluation = @contestwork.contest_messages.where("user_id =? and viewed =?", User.current.id, 0)
|
||||
noEvaluation.update_all(:viewed => true)
|
||||
|
||||
|
@ -23,6 +24,9 @@ class ContestantWorksController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html{ render :layout => "base_contests"}
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
|
|
|
@ -175,11 +175,11 @@ class ContestsController < ApplicationController
|
|||
end
|
||||
case params[:agree]
|
||||
when 'Y'
|
||||
if ContestMember.where(:user_id => apply_user.id).first.nil?
|
||||
if ContestMember.where(:user_id => apply_user.id, :contest_id => applied_contest.contest_id).first.nil?
|
||||
member = ContestMember.new(:user_id => apply_user.id)
|
||||
Contest.find(applied_contest.contest_id).contest_members << member
|
||||
else
|
||||
member = ContestMember.where(:user_id => apply_user.id).first
|
||||
member = ContestMember.where(:user_id => apply_user.id, :contest_id => applied_contest.contest_id).first
|
||||
end
|
||||
|
||||
contest_member_roles = member.contest_member_roles
|
||||
|
|
|
@ -273,7 +273,7 @@ class NewsController < ApplicationController
|
|||
elsif @news.contest_id
|
||||
@contest = Contest.find(@news.contest_id)
|
||||
if @contest
|
||||
@left_nav_type = 4
|
||||
@left_nav_type = 5
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'base_contests'}
|
||||
|
|
|
@ -70,7 +70,7 @@ class WorksController < ApplicationController
|
|||
homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(homework)
|
||||
|
||||
homework.work_status = homework.publish_time > Date.today ? 0 : 1
|
||||
homework.work_status = homework.publish_time > Date.today ? 0 : (homework.end_time < Date.today ? 2 : 1)
|
||||
|
||||
work_detail_manual = WorkDetailManual.new
|
||||
|
||||
|
|
|
@ -103,8 +103,10 @@ class Message < ActiveRecord::Base
|
|||
:if => lambda {|message, user|
|
||||
if message.project
|
||||
user.allowed_to?(:edit_messages, message.project)
|
||||
else
|
||||
elsif message.course
|
||||
user.allowed_to?(:edit_messages, message.course)
|
||||
elsif message.contest
|
||||
user.admin_of_contest?(message.contest)
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@
|
|||
l(:button_edit),
|
||||
{:action => 'edit', :id => @news},
|
||||
:class => 'postOptionLink'
|
||||
) if User.current == @news.author || User.current.admin_of_contest?(@contest) %>
|
||||
) if User.current == @news.author || User.current.admin_of_contest?(@contest) || User.current.admin? %>
|
||||
</li>
|
||||
<li>
|
||||
<%= delete_link(
|
||||
news_path(@news),
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:class => 'postOptionLink'
|
||||
) if User.current == @news.author || User.current.admin_of_contest?(@contest) %>
|
||||
) if User.current == @news.author || User.current.admin_of_contest?(@contest) || User.current.admin? %>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<div>
|
||||
<p class="fl sy_p_grey">
|
||||
更新时间:<%= format_date(contest.updated_at) %>
|
||||
创建者:<%= contest.user.show_name %>
|
||||
创建者:<%= link_to contest.user.show_name, user_path(contest.user) %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -45,14 +45,14 @@
|
|||
l(:button_edit),
|
||||
{controller:'news', :action => 'edit', :id => activity.id},
|
||||
:class => 'postOptionLink'
|
||||
) if User.current == activity.author || User.current.admin_of_contest?(activity.contest) %>
|
||||
) if User.current == activity.author || User.current.admin_of_contest?(activity.contest) || User.current.admin? %>
|
||||
</li>
|
||||
<li>
|
||||
<%= delete_link(
|
||||
news_path(activity),
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:class => 'postOptionLink'
|
||||
) if User.current == activity.author || User.current.admin_of_contest?(activity.contest) %>
|
||||
) if User.current == activity.author || User.current.admin_of_contest?(activity.contest) || User.current.admin? %>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
<span class="homepageNewsType fl">发布了竞赛题:</span>
|
||||
</li>
|
||||
<li class="messageInformationContents">
|
||||
<% if User.current.contestant_of_contest?(ma.contest_message.contest) && cur_user_works_for_work(ma.contest_message).nil? %>
|
||||
<% if User.current.contestant_of_contest?(ma.contest_message.contest) && cur_user_works_for_work(ma.contest_message).nil? && ma.contest_message.work_status == 1 %>
|
||||
<%= link_to ma.contest_message.name, new_contestant_work_path(:work => ma.contest_message.id),
|
||||
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
|
||||
:target => '_blank',
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
namespace :contest_work_evaluation do
|
||||
desc "start and end evaluation"
|
||||
def get_assigned_contestant_works(judges, n, index, num)
|
||||
judges[(index % num) .. ((index + n - 1) % num)]
|
||||
judges = judges + judges
|
||||
first_index = (index * n) % num
|
||||
last_index = (index * n + n - 1) % num < first_index ? ((index * n + n - 1) % num) + num : (index * n + n - 1) % num
|
||||
judges[first_index .. last_index]
|
||||
end
|
||||
# 获取竞赛的评委人员
|
||||
def contest_judges contest
|
||||
|
|
Loading…
Reference in New Issue