具体竞赛页的邀请码tip没有显示、竞赛菜单的“暂停加入”和“删除”

This commit is contained in:
cxt 2016-12-30 11:18:29 +08:00
parent 73350e34f1
commit 738db43f34
8 changed files with 76 additions and 6 deletions

View File

@ -500,6 +500,10 @@ class ApplicationController < ActionController::Base
#<23><>ȡ<EFBFBD>γ<EFBFBD>
def find_course
@course= Course.find(params[:id])
if @course.is_delete == 1 and !User.current.admin?
render_404
return
end
rescue ActiveRecord::RecordNotFound
render_404
end

View File

@ -5,10 +5,11 @@ class ContestsController < ApplicationController
helper :contest_members
helper :users
before_filter :find_contest, :only => [:show, :settings, :update, :contest_activities, :search_member, :private_or_public, :switch_role]
before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :search_member, :private_or_public, :switch_role, :set_invite_code_halt, :renew]
before_filter :is_logged, :only => [:index, :new, :create]
before_filter :is_admin?, :only => [:settings]
before_filter :is_admin?, :only => [:settings, :set_invite_code_halt, :destroy]
before_filter :is_member?, :only => [:show, :contest_activities]
layout "base_contests"
def show
@ -106,6 +107,10 @@ class ContestsController < ApplicationController
end
end
def destroy
@contest.update_attributes(:is_delete => true)
end
def private_or_public
@contest.update_attributes(:is_public => !@contest.is_public)
@ -231,6 +236,23 @@ class ContestsController < ApplicationController
end
end
# 邀请码停用/启用
def set_invite_code_halt
if User.current.admin_of_contest?(@contest) || User.current.admin?
@contest.update_attribute('invite_code_halt', @contest.invite_code_halt == 0 ? 1 : 0)
end
end
# 恢复已删除的竞赛
def renew
if User.current.admin?
@contest.update_attributes(:is_delete => false)
redirect_to contest_path(@contest)
else
return 404
end
end
private
def find_contest
@ -239,6 +261,10 @@ class ContestsController < ApplicationController
return
end
@contest = Contest.find(params[:id])
if @contest.is_delete and !User.current.admin?
render_404
return
end
rescue ActiveRecord::RecordNotFound
render_404
end

View File

@ -32,5 +32,22 @@
<% else %>
<%= link_to "加入竞赛",join_contest_contests_path(),:remote => true, :method => "get", :class => "fr sy_btn_blue mt28 ml10" %>
<% end %>
<span class="fr mt30 f16"> 邀请码:<span class="sy_corange"><%= @contest.invite_code %></span></span>
<div class="cl"></div>
<span class="fr mt30 f16"> 邀请码:
<span class="sy_corange">
<span class="sy_corange">
<% if @contest.invite_code_halt == 0 %>
<%=@contest.generate_invite_code %>
<% else %>
已停用
<% end %>
</span>
</span></span>
<div class="cl"></div>
<% if User.current.admin_of_contest?(@contest) || User.current.admin? %>
<div class="invite_code_tip_box fontGrey2" id="invite_code_tip_box" style="top: 160px;">
<em></em>
<span></span>
<p class="mt10 mb5"><%= @contest.invite_code_halt == 0 ? "请将邀请码告诉成员" : "邀请码已停用" %></p>
<p class="mb10"><%= @contest.invite_code_halt == 0 ? "他们可以主动加入" : "暂时停止成员主动加入" %></p>
</div>
<% end %>

View File

@ -3,9 +3,19 @@
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><%= link_to !@contest.is_public ? "设为公开" : "设为私有", {:controller => 'contests', :action => 'private_or_public', :id => @contest},:remote=>true,:confirm=>"您确定要设置为"+(!@contest.is_public ? "公开" : "私有")+"吗", :class => "postOptionLink" %></li>
<!--<li><a href="javascript:void(0);" class="postOptionLink">暂停加入</a></li>-->
<% if @contest.invite_code_halt == 0 %>
<li><a href="javascript:void(0);" class="postOptionLink" onclick="alert_halt_code();">暂停加入</a></li>
<% elsif @contest.invite_code_halt == 1 %>
<li><a href="<%=set_invite_code_halt_contest_path(@contest) %>" data-remote="true" class="postOptionLink">放开加入</a></li>
<% end %>
<li><%= link_to "配置", {:controller => 'contests', :action => 'settings', :id => @contest}, :class => "postOptionLink" %></li>
<!--<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>-->
<li>
<% if !@contest.is_delete %>
<a href="javascript:void(0);" class="postOptionLink" onclick="delete_confirm_box_2('<%=contest_path(@contest) %>', '您确定要删除该竞赛吗?<br/>删除后可联系系统管理员进行恢复')">删除</a>
<% else %>
<%=link_to "恢复竞赛", renew_contest_path(@contest), :class => "postOptionLink" %>
<% end %>
</li>
</ul>
</li>
</ul>

View File

@ -0,0 +1,2 @@
hideModal();
window.location.href = "<%=user_contest_community_path(User.current) %>";

View File

@ -0,0 +1,2 @@
$("#contest_base_info").html("<%= escape_javascript(render :partial => 'contests/contest_base_info') %>");
hideModal();

View File

@ -110,6 +110,13 @@
}
<% end %>
});
function alert_halt_code(){
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">邀请码停用后,用户不能主动加入该竞赛了</p><p class="text_c mt10 f14">您是否确认停用</p><div class="cl"></div>'+
'<a href="<%=set_invite_code_halt_contest_path(@contest) %>" class="fr sy_btn_blue mr135 mt10" data-remote="true">确&nbsp;&nbsp;定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取&nbsp;&nbsp;消</a></div></div>';
pop_box_new(htmlvalue, 400, 180);
}
</script>
</html>

View File

@ -629,6 +629,8 @@ RedmineApp::Application.routes.draw do
get 'contest_activities'
get 'private_or_public'
get "switch_role"
get 'set_invite_code_halt'
get 'renew'
end
resources :boards