forked from Trustie/forgeplus
启智竞赛接口调整
This commit is contained in:
parent
78fd1d158f
commit
7ab87df7fc
|
|
@ -331,7 +331,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
# if !User.current.logged? && Rails.env.development?
|
||||
# User.current = User.find 1
|
||||
User.current = User.find 4
|
||||
# end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
class CompetitionInfosController < ApplicationController
|
||||
before_action :find_competition, only: [:show, :enroll, :upload, :enroll_status, :statistics]
|
||||
# before_action :require_admin, only: [:index, :new, :edit, :create, :update]
|
||||
before_action :manager_competition, only: [:enroll_list]
|
||||
|
||||
def index
|
||||
|
|
@ -71,7 +72,9 @@ class CompetitionInfosController < ApplicationController
|
|||
competition_user = CompetitionUser.new(enroll_params)
|
||||
competition_user.competition_info = @competition_info
|
||||
competition_user.user = current_user
|
||||
competition_user.members = params[:members]
|
||||
competition_user.save
|
||||
render_ok
|
||||
end
|
||||
|
||||
def enroll_status
|
||||
|
|
@ -83,18 +86,16 @@ class CompetitionInfosController < ApplicationController
|
|||
tip_exception "未报名,请先报名" if competition_user.blank?
|
||||
tip_exception "未提交作品" if params[:attachment_ids].blank?
|
||||
tip_exception "您已经提交作品!" if competition_user.present? && competition_user.attachments.present?
|
||||
if competition_user.present? && params[:attachment_ids].present?
|
||||
params[:attachment_ids].each do |id|
|
||||
attachment = Attachment.find_by_id(id)
|
||||
unless attachment.blank?
|
||||
attachment.container = competition_user
|
||||
attachment.author_id = current_user.id
|
||||
attachment.description = ""
|
||||
attachment.save
|
||||
end
|
||||
params[:attachment_ids].each do |id|
|
||||
attachment = Attachment.find_by_id(id)
|
||||
unless attachment.blank?
|
||||
attachment.container = competition_user
|
||||
attachment.author_id = current_user.id
|
||||
attachment.description = ""
|
||||
attachment.save
|
||||
end
|
||||
render_ok
|
||||
end
|
||||
render_ok
|
||||
end
|
||||
|
||||
#赛事风采
|
||||
|
|
@ -112,7 +113,8 @@ class CompetitionInfosController < ApplicationController
|
|||
end
|
||||
|
||||
def competition_info_params
|
||||
params.require(:competition_info).permit(:title, :zones, :sub_competitions, :identifier, :content, :video_url, :is_local)
|
||||
params.require(:competition_info).permit(:title, :zones, :zones_local, :sub_competitions, :identifier, :content,
|
||||
:video_url, :is_local, :upload_date, :enroll_date)
|
||||
end
|
||||
|
||||
def find_competition
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
# is_local :boolean default(FALSE)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# enroll_date :datetime
|
||||
# upload_date :datetime
|
||||
# zones_local :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
@ -23,7 +26,7 @@ class CompetitionInfo < ApplicationRecord
|
|||
has_many :competition_users
|
||||
|
||||
def competition_zones
|
||||
self.zones.to_s.split(",")
|
||||
self.is_local? ? self.zones_local.to_s.split(",") : self.zones.to_s.split(",")
|
||||
end
|
||||
|
||||
def competition_subs
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@
|
|||
<%= form.check_box("is_local", {}, "true", "false") %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :zones, "赛区(内网)" %>
|
||||
<%= form.text_field :zones_local, :style=>'width:1200px;' %>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :zones, "赛区" %>
|
||||
|
|
@ -44,6 +49,16 @@
|
|||
<%= form.text_field :sub_competitions , :style=>'width:1200px;' %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :enroll_date, "报名时间" %>
|
||||
<%= form.text_field :enroll_date , :style=>'width:200px;' %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :upload_date, "提交作品时间" %>
|
||||
<%= form.text_field :upload_date , :style=>'width:200px;' %>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="actions">
|
||||
<%= form.submit("保存赛事")%>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<td><%= info.identifier %></td>
|
||||
<td><%= info.title %></td>
|
||||
<td><%= info.content %></td>
|
||||
<td><%= info.zones %></td>
|
||||
<td><%= info.is_local? ? info.zones_local : info.zones %></td>
|
||||
<td><%= info.sub_competitions %></td>
|
||||
<td><%= info.is_local? %></td>
|
||||
<td><%= link_to 'Edit', edit_competition_info_path(info) %></td>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ json.status 0
|
|||
json.message "success"
|
||||
json.data do
|
||||
json.extract! @competition_info, :id, :identifier, :title, :content, :video_url, :is_local
|
||||
json.zones @competition_info.zones.to_s.split(",")
|
||||
json.zones @competition_info.competition_zones
|
||||
json.sub_competitions @competition_info.sub_competitions.to_s.split(",")
|
||||
end
|
||||
|
|
@ -2,6 +2,7 @@ json.status 0
|
|||
json.message "success"
|
||||
json.enroll_count @competition_users.count
|
||||
json.upload_count @upload_count
|
||||
json.competition_subs @competition_info.competition_subs
|
||||
|
||||
json.data do
|
||||
json.array! @competition_info.competition_zones.each do |d|
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
class AddCompetitionInfoDate < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :competition_infos, :enroll_date, :datetime
|
||||
add_column :competition_infos, :upload_date, :datetime
|
||||
add_column :competition_infos, :zones_local, :string
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue