Merge branch 'cxt_course' of https://git.trustie.net/jacknudt/trustieforge into cxt_course

This commit is contained in:
huang 2016-12-22 17:11:15 +08:00
commit 3406d4ba0d
9 changed files with 130 additions and 2 deletions

View File

@ -81,6 +81,40 @@ class ContestsController < ApplicationController
end
end
#处理加入竞赛成为管理员、评委、参赛者的请求
#status 1 同意 2 拒绝
def dealwith_apply_request
@msg = AppliedMessage.find(params[:msg_id])
#AppliedMessage role 13 管理员 14 评委 15 参赛者
applied_contest = @msg.applied
apply_user = User.find(applied_contest.user_id)
ids = applied_contest.role.split(",") # [@msg.content] msg content保存的是申请的职位角色
integer_ids = []
ids.each do |role_id|
integer_ids << role_id.to_i
end
case params[:agree]
when 'Y'
members = []
members << ContestMember.new(:role_ids => integer_ids, :user_id => apply_user.id)
Contest.find(applied_contest.contest_id).contest_members << members
ContestMessage.create(:user_id => apply_user.id, :contest_id => applied_contest.contest_id, :viewed => false,:contest_message_id=>User.current.id,:content=>applied_contest.role,:contest_message_type=>'ContestRequestDealResult',:status=>1)
applied_contest.applied_messages.update_all(:status => 1, :viewed => 1)
applied_contest.update_attributes(:status => 1)
if integer_ids.include?("15")
ContestantForContest.create(:student_id => apply_user.id, :contest_id =>applied_contest.contest_id)
end
when 'N'
ContestMessage.create(:user_id => apply_user.id, :contest_id => applied_contest.contest_id, :viewed => false,:contest_message_id=>User.current.id,:content=>applied_contest.role,:contest_message_type=>'ContestRequestDealResult',:status=>2)
applied_contest.applied_messages.update_all(:status => 2, :viewed => 1)
applied_contest.update_attributes(:status => 2)
end
respond_to do |format|
format.js
end
end
private
def find_contest

View File

@ -1880,7 +1880,7 @@ class UsersController < ApplicationController
@applied_message_alls << mess
end
elsif (message_all.message_type == "AppliedMessage" )
if (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 )
if (mess.applied_type == "AppliedContest" && mess.status == 0) || (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 )
@applied_message_alls << mess
end
elsif message_all.message_type == "CourseMessage"

View File

@ -9,7 +9,7 @@ class AppliedContest < ActiveRecord::Base
# 仅仅给项目管理人员发送消息
def send_appliled_message
self.contest.managers.each do |member|
self.contest.contest_managers.each do |member|
self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => 0, :viewed => false, :applied_user_id => self.user_id, :role => self.role)
end
# end

View File

@ -0,0 +1 @@
$("#contest_message_join_<%=@msg.id %>").html('<%= escape_javascript(render :partial => 'users/join_contest_applied_message', :locals => {:ma => @msg}) %>');

View File

@ -0,0 +1,51 @@
<div class="shortMessageWidth">
<% applied_contest = ma.applied %>
<% contest = Contest.find applied_contest.contest_id %>
<% message_user = User.find(applied_contest.user_id) %>
<li class="homepageNewsPortrait fl">
<div class="navHomepageLogo fl">
<%= link_to image_tag(url_to_avatar(message_user), :width => "30", :height => "30"), user_path(message_user), :target => '_blank' %>
</div>
</li>
<li class="homepageNewsPubType fl">
<span class="newsBlue homepageNewsPublisher">
<%=link_to message_user.show_name, user_path(applied_contest.user_id),
:class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
</span>
<span class="homepageNewsType fl">
<% if applied_contest.role
role_str = ""
if applied_contest.role.include?('13') && applied_contest.role.include?('14')
role_str = "管理员、评委"
elsif applied_contest.role.include?('13')
role_str = "管理员"
elsif applied_contest.role.include?('14')
role_str = "评委"
elsif applied_contest.role.include?('15')
role_str = "参赛者"
end
end %>
申请以<%= role_str %>的身份加入班级:
</span>
</li>
<li class="messageInformationContents">
<% content = message_user.show_name + "申请成为班级\"" + "#{contest.name}" + "\"的" + role_str %>
<%= link_to contest.name, contest_path(contest.id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank', :title => "#{content}" %>
</li>
</div>
<li class="messageOperateContents fl">
<span id="deal_info_<%=ma.id%>">
<% if ma.status == 0 || ma.status.nil?%>
<%= link_to '同意',dealwith_apply_request_contest_path(contest,:agree=>'Y',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%>
|
<%= link_to '拒绝',dealwith_apply_request_contest_path(contest,:agree=>'N',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%>
<% elsif ma.status == 1%> <!-- 同意 -->
已同意申请
<% elsif ma.status == 2%> <!-- 拒绝 -->
已拒绝申请
<%end %>
</span>
</li>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>

View File

@ -10,6 +10,9 @@
<!--项目消息-->
<%= render :partial => 'users/user_message_forge', :locals => {:ma => ma} %>
<%# 竞赛消息 %>
<%= render :partial => 'users/user_message_contest', :locals => {:ma => ma} %>
<!--公共贴吧-->
<%= render :partial => 'users/user_message_forum', :locals => {:ma => ma} %>

View File

@ -46,5 +46,9 @@
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %>
</li>
</ul>
<% elsif ma && ma.applied_type == "AppliedContest" %>
<ul class="homepageNewsList fl" id="contest_message_join_<%=ma.id %>">
<%= render :partial => 'join_contest_applied_message', :locals => {:ma => ma} %>
</ul>
<% end %>
<% end %>

View File

@ -0,0 +1,34 @@
<% if ma.contest_message_type == "ContestRequestDealResult" %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<div class="navHomepageLogo fl"><%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %></div>
</li>
<li class="homepageNewsPubType fl">
<span class="newsBlue homepageNewsPublisher">系统提示</span>
<span class="homepageNewsType fl">
竞赛申请进度反馈:</span>
</li>
<li class="messageInformationContents">
<% if ma.content
role_str = ""
if ma.content.include?('13') && ma.content.include?('14')
role_str = "管理员、评委"
elsif ma.content.include?('13')
role_str = "管理员"
elsif ma.content.include?('14')
role_str = "评委"
elsif ma.content.include?('15')
role_str = "参赛者"
end
end %>
<%= link_to ma.status == 1 ?
'您申请成为竞赛"'+Course.find(ma.course_id).name+'"的'+ role_str +'申请已通过'
:
'您申请成为竞赛"'+Course.find(ma.course_id).name+'"的'+ role_str +'的申请被拒绝', contest_path(Contest.find(ma.contest_id)),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
</li>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>

View File

@ -617,6 +617,7 @@ RedmineApp::Application.routes.draw do
member do
match 'settings' , :via => [:get, :post]
get 'dealwith_apply_request'
end
resources :boards