Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_auth
杨树明 5 years ago
commit b958cd557a

@ -14,56 +14,31 @@ class Admins::CompetitionStagesController < Admins::BaseController
current_stage.destroy!
end
def create_stage_section
ActiveRecord::Base.transaction do
new_section = CompetitionStageSection.create!(competition_id: current_stage.competition_id, competition_stage_id: current_stage.id,
start_time: params[:new_start_time], end_time: params[:new_end_time],
entry: params[:entry], mission_count: params[:mission_count], score_source: params[:score_source])
unless params[:shixun_identifiers].blank?
params[:shixun_identifiers].each do |identifier|
new_section.competition_entries << CompetitionEntry.new(competition_stage_id: current_stage.id, shixun_identifier: identifier)
end
end
render_ok
end
end
def update_stage_section
ActiveRecord::Base.transaction do
section = current_stage.competition_stage_sections.find_by!(id: params[:section_id])
if section.present?
section_entries = section.competition_entries
if !params[:shixun_identifiers]
section_entries.destroy_all
else
if params[:shixun_identifiers].length < section_entries.size
section_entries[params[:shixun_identifiers].length, section_entries.size - 1].each(&:destroy)
end
def calculate_stage_score
if current_stage.max_end_time && current_stage.max_end_time < Time.now
params[:shixun_identifiers].each_with_index do |identifier, index|
entry = section_entries[index]
if entry.present?
entry.update_attributes!(shixun_identifier: identifier)
else
section.competition_entries << CompetitionEntry.new(competition_stage_id: current_stage.id, shixun_identifier: identifier)
render_error("#{current_stage.name}还未结束")
end
end
def send_message
if current_stage.max_end_time && current_stage.max_end_time > Time.now
User.where(id: TeamMember.where(competition_team_id: current_competition.competition_teams.pluck(:id)).pluck(:user_id).uniq).each do |user|
name = current_competition.name + "#{current_competition.sub_title}#{stage.name}"
begin
if user.phone.present?
Educoder::Sms.send(mobile: user.phone.to_s, code: '1', send_type:'competition_start', user_name:user.show_name,
name:name, result:section.start_time.strftime('%Y-%m-%d %H:%M:%S'))
end
section.update_attributes!(start_time: params[:new_start_time], end_time: params[:new_end_time],
entry: params[:entry], mission_count: params[:mission_count], score_source: params[:score_source])
render_ok
end
rescue => e
logger_error(e)
render_error("发送验证码出错")
end
end
def destroy_stage_section
section = current_stage.competition_stage_sections.find_by!(id: params[:section_id])
section.destroy!
render_ok
else
render_error("#{current_stage.name}已结束")
end
def calculate_stage_score
end
private

@ -1,11 +1,10 @@
class Admins::CompetitionsController < Admins::BaseController
include CustomSortable
before_action :find_competition, except: [:index]
def index
params[:sort_by] = params[:sort_by].presence || 'created_on'
params[:sort_direction] = params[:sort_direction].presence || 'desc'
@competitions = custom_sort Competition.all, params[:sort_by], params[:sort_direction]
# params[:sort_by] = params[:sort_by].presence || 'created_at'
# params[:sort_direction] = params[:sort_direction].presence || 'desc'
@competitions = Competition.all.order("created_at desc")
@params_page = params[:page] || 1
@competitions = paginate @competitions
ids = @competitions.map(&:id)

@ -116,13 +116,13 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
keyword = params[:keyword].to_s.strip
if keyword.present?
teams = teams.joins(users: { user_extension: :school })
teams = teams.joins(user: { user_extension: :school })
.where('competition_teams.name LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%")
end
@all_count = teams.count
@all_teams = paginate(teams.includes(:user, users: { user_extension: :school }))
@all_member_count = current_competition.team_members.count
@all_member_count = teams.joins(:team_members).count
end
def user_competition_teams

@ -347,8 +347,14 @@
</div><span class=" mt-2">%</span>
<div class="flex-1">
<a href="javascript:void(0)"class="btn btn-outline-primary export-action ml20 add-task-sub">新增子阶段</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">发送短信提醒</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">计算成绩</a>
<% if stage.max_end_time > Time.now %>
<%= agree_link '发送短信提醒', send_message_admins_competition_competition_stage_path(@competition, stage, element: ".send-message-#{stage.id}"),
class: 'btn btn-outline-primary ml20', 'data-confirm': '确认执行发送短信操作?' %>
<% end %>
<% if stage.max_end_time < Time.now %>
<%= agree_link '计算成绩', calculate_stage_score_admins_competition_competition_stage_path(@competition, stage, element: ".calculate-score-#{stage.id}"),
class: 'btn btn-outline-primary ml20', 'data-confirm': '确认执行计算成绩操作?' %>
<% end %>
</div>
<%= delete_link '删除', admins_competition_competition_stage_path(competition_id: @competition.id, id: stage.id), class: 'btn btn-default delete-stage ml20' %>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action update-stage ml20">保存</a>

@ -1034,10 +1034,9 @@ Rails.application.routes.draw do
end
resources :competition_stages, only: [:create, :update, :destroy] do
collection do
post :create_stage_section
post :update_stage_section
delete :destroy_stage_section
member do
post :send_message
post :calculate_stage_score
end
end
end

@ -88,6 +88,7 @@ class Registration extends React.Component {
// this.Getdata(keyword, page, per_page, this.props.isAdmin());
// this.GetenrollmentAPI();
}
//取模式
this.Getdataheader();
}
@ -100,6 +101,7 @@ class Registration extends React.Component {
////console.log(this.props.user.admin);
const {keyword, page, per_page} = this.state;
this.Getdata(keyword, page, per_page, this.props.user.admin);
//取报名配置
this.GetenrollmentAPI();
}
@ -144,6 +146,7 @@ class Registration extends React.Component {
})
try {
//获取学生是否被限制多次报名
if (result.data.member_staff) {
this.setState({
mutiple_limited: result.data.member_staff.mutiple_limited,
@ -157,6 +160,7 @@ class Registration extends React.Component {
}
try {
//获取老师是否被限制多次报名
if (result.data.teacher_staff) {
this.setState({
teamutiple_limited: result.data.teacher_staff.mutiple_limited
@ -167,6 +171,7 @@ class Registration extends React.Component {
}
//是否是个人赛做处理
if (result.data.personal === true) {
if (result.data.enroll_ended === true) {
this.setState({
@ -211,6 +216,17 @@ class Registration extends React.Component {
// 没有创建数据的
if (admin === true) {
//管理员
try {
this.setState({
type: result.data.competition_teams.length === 0 ? 1 : 4,
count: result.data.count,
data: result.data.my_teams,
competition_teams: result.data.competition_teams,
personal: result.data.personal,
competition_name: result.data.competition_name,
members_count: result.data.members_count
})
} catch (e) {
this.setState({
type: 4,
count: result.data.count,
@ -220,6 +236,8 @@ class Registration extends React.Component {
competition_name: result.data.competition_name,
members_count: result.data.members_count
})
}
} else {
//普通账号
this.setState({
@ -463,6 +481,12 @@ class Registration extends React.Component {
* 加入战队
* */
Jointheteam = () => {
if (this.props.checkIfLogin() === false) {
this.props.showLoginDialog()
return
}
if (this.props.user.is_teacher === true) {
try {
if (this.state.teamutiple_limited === true) {
@ -544,7 +568,12 @@ class Registration extends React.Component {
* 创建战队
**/
Createateam = () => {
//
if (this.props.checkIfLogin() === false) {
this.props.showLoginDialog()
return
}
if (this.props.user.is_teacher === true) {
try {
@ -734,6 +763,12 @@ class Registration extends React.Component {
// /competitions/:identifier/competition_teams.json
Personalregistration = () => {
let {teacher_staff, member_staff, data, enroll_ended, enrolled} = this.state;
if (this.props.checkIfLogin() === false) {
this.props.showLoginDialog();
return
}
if (enroll_ended === true) {
//已截止
this.props.showNotification(`报名已截止`);

@ -39,6 +39,15 @@ class PersonalModalteam extends Component {
}).then((result) => {
if (result) {
if (result.data) {
try {
if (result.data.status === 0) {
this.props.showNotification(`报名成功,预祝您夺得桂冠`);
}
} catch (e) {
}
this.props.Tmoconfirm(true)
}
}

@ -516,6 +516,7 @@ export function TPMIndexHOC(WrappedComponent) {
isloginCancel:"iscancel"
})
}
//验证登录是否成功方法
checkIfLogin = () => {
return this.state.current_user && this.state.current_user.login != ''
}
@ -531,6 +532,7 @@ export function TPMIndexHOC(WrappedComponent) {
AccountProfiletype: true
})
}
//验证是否完善资料
checkIfProfileCompleted = () => {
return this.state.current_user && this.state.current_user.profile_completed
}

Loading…
Cancel
Save