竞赛者加入,无需身份验证,发送消息通知给竞赛所有管理员即可
This commit is contained in:
parent
b318c460d9
commit
77c25db233
|
@ -24,6 +24,21 @@ class ContestsService
|
||||||
if params[:invite_code].present?
|
if params[:invite_code].present?
|
||||||
role_ids = params[:role]
|
role_ids = params[:role]
|
||||||
|
|
||||||
|
if role_ids.include?("15")
|
||||||
|
member = ContestMember.new(:user_id => current_user.id)
|
||||||
|
contest.contest_members << member
|
||||||
|
contest_member_roles = member.contest_member_roles
|
||||||
|
contest_member_roles << ContestMemberRole.new(:role_id => 15)
|
||||||
|
ContestantForContest.create(:student_id => current_user.id, :contest_id => contest.id)
|
||||||
|
|
||||||
|
# 给管理员发消息
|
||||||
|
admins = contest_managers contest
|
||||||
|
admins.each do |member|
|
||||||
|
course_join = ContestMessage.new(:user_id =>member.user_id, :contest_message_id=>current_user.id,:contest_id => contest.id,:contest_message_type=>"JoinContest", :content => role_ids, :viewed => false, :status => 2)
|
||||||
|
course_join.save
|
||||||
|
end
|
||||||
|
@state = 0
|
||||||
|
else
|
||||||
#如果已经发送过消息了,那么就要给个提示
|
#如果已经发送过消息了,那么就要给个提示
|
||||||
if AppliedContest.where(:contest_id => contest.id, :user_id => current_user.id, :status => 0).count != 0
|
if AppliedContest.where(:contest_id => contest.id, :user_id => current_user.id, :status => 0).count != 0
|
||||||
@state = 7
|
@state = 7
|
||||||
|
@ -37,6 +52,7 @@ class ContestsService
|
||||||
end
|
end
|
||||||
@state = 6
|
@state = 6
|
||||||
end
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@state = 1
|
@state = 1
|
||||||
end
|
end
|
||||||
|
|
|
@ -139,7 +139,10 @@
|
||||||
<li><a href="<%=contest_path(ma.contest) %>" target="_blank" title="<%=User.find(ma.contest_message_id).show_name %> 将您加入了竞赛:<%= ma.contest.name%>"><span class="shadowbox_news_user"><%=User.find(ma.contest_message_id).show_name %> </span>将您加入了竞赛:<%= ma.contest.name%></a></li>
|
<li><a href="<%=contest_path(ma.contest) %>" target="_blank" title="<%=User.find(ma.contest_message_id).show_name %> 将您加入了竞赛:<%= ma.contest.name%>"><span class="shadowbox_news_user"><%=User.find(ma.contest_message_id).show_name %> </span>将您加入了竞赛:<%= ma.contest.name%></a></li>
|
||||||
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 1 %>
|
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 1 %>
|
||||||
<li><a href="<%=settings_contest_path(ma.contest_id, :tab=>'member') %>" target="_blank" title="系统提示 您增加了新的竞赛成员:<%= User.find(ma.contest_message_id).login+"("+User.find(ma.contest_message_id).show_name+")"%>"><span class="shadowbox_news_user">系统提示 </span>您增加了新的竞赛成员:<%= User.find(ma.contest_message_id).login+"("+User.find(ma.contest_message_id).show_name+")"%></a></li>
|
<li><a href="<%=settings_contest_path(ma.contest_id, :tab=>'member') %>" target="_blank" title="系统提示 您增加了新的竞赛成员:<%= User.find(ma.contest_message_id).login+"("+User.find(ma.contest_message_id).show_name+")"%>"><span class="shadowbox_news_user">系统提示 </span>您增加了新的竞赛成员:<%= User.find(ma.contest_message_id).login+"("+User.find(ma.contest_message_id).show_name+")"%></a></li>
|
||||||
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 1 %>
|
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 2 %>
|
||||||
|
<% user = User.find(ma.contest_message_id) %>
|
||||||
|
<li><a href="<%=contest_path(ma.contest) %>" target="_blank" title="<%=user.show_name %> <%= user.user_extensions.school_id.blank? || user.user_extensions.school.nil? ? '' : '来自'+user.user_extensions.school.name+',' %>以'参赛者'的身份加入了竞赛:<%= ma.contest.name%>"><span class="shadowbox_news_user"><%=user.show_name %> </span><%= user.user_extensions.school_id.blank? || user.user_extensions.school.nil? ? '' : '来自'+user.user_extensions.school.name+',' %>以'参赛者'的身份加入了竞赛:<%= ma.contest.name%></a></li>
|
||||||
|
<% elsif ma.contest_message_type == "RemoveFromContest" %>
|
||||||
<li><a href="<%=contest_path(ma.contest) %>" target="_blank" title="<%=User.find(ma.contest_message_id).show_name %> 将您移出了竞赛:<%= ma.contest.name%>"><span class="shadowbox_news_user"><%=User.find(ma.contest_message_id).show_name %> </span>将您移出了竞赛:<%= ma.contest.name%></a></li>
|
<li><a href="<%=contest_path(ma.contest) %>" target="_blank" title="<%=User.find(ma.contest_message_id).show_name %> 将您移出了竞赛:<%= ma.contest.name%>"><span class="shadowbox_news_user"><%=User.find(ma.contest_message_id).show_name %> </span>将您移出了竞赛:<%= ma.contest.name%></a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% elsif ma.class == AppliedMessage %>
|
<% elsif ma.class == AppliedMessage %>
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!--被管理员拉入竞赛-->
|
<!--被管理员拉入竞赛:学生身份-->
|
||||||
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 0 %>
|
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 0 %>
|
||||||
<ul class="homepageNewsList fl">
|
<ul class="homepageNewsList fl">
|
||||||
<div class="longMessageWidth">
|
<div class="longMessageWidth">
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!--被管理员拉入竞赛-->
|
<!--被管理员拉入竞赛:老师身份-->
|
||||||
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 1 %>
|
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 1 %>
|
||||||
<ul class="homepageNewsList fl">
|
<ul class="homepageNewsList fl">
|
||||||
<div class="longMessageWidth">
|
<div class="longMessageWidth">
|
||||||
|
@ -85,6 +85,30 @@
|
||||||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<!--主动加入竞赛-->
|
||||||
|
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 2 %>
|
||||||
|
<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">
|
||||||
|
<% user = User.find(ma.contest_message_id) %>
|
||||||
|
<span class="newsBlue homepageNewsPublisher">
|
||||||
|
<%=link_to user.show_name, user_path(user),
|
||||||
|
:class => "newsBlue homepageNewsPublisher", :target => '_blank' %></span>
|
||||||
|
<span class="homepageNewsType fl">
|
||||||
|
<%= user.user_extensions.school_id.blank? || user.user_extensions.school.nil? ? "" : "来自"+user.user_extensions.school.name+"," %>
|
||||||
|
以"参赛者"的身份加入了竞赛:
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<li class="messageInformationContents">
|
||||||
|
<%= link_to ma.contest.name, contest_path(ma.contest), :class => "#{!ma.viewed ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<!--被老师移出课程-->
|
<!--被老师移出课程-->
|
||||||
<% elsif ma.contest_message_type == "RemoveFromContest" %>
|
<% elsif ma.contest_message_type == "RemoveFromContest" %>
|
||||||
<ul class="homepageNewsList fl">
|
<ul class="homepageNewsList fl">
|
||||||
|
|
Loading…
Reference in New Issue