competitions
cxt 5 years ago
parent c48ef87479
commit a571ae0c35

@ -1,5 +1,6 @@
class Competitions::CompetitionsController < Competitions::BaseController
skip_before_action :require_login
before_action :allow_visit, except: [:index]
def index
# 已上架 或者 即将上架
@ -24,10 +25,10 @@ class Competitions::CompetitionsController < Competitions::BaseController
end
def show
unless current_competition.published? || admin_or_business?
render_forbidden
return
end
end
def common_header
end
private
@ -35,4 +36,11 @@ class Competitions::CompetitionsController < Competitions::BaseController
def current_competition
@_current_competition ||= Competition.find_by!(identifier: params[:id])
end
def allow_visit
unless current_competition.published? || admin_or_business?
render_forbidden
return
end
end
end

@ -1,7 +1,7 @@
json.count @count
json.competitions do
json.array! @competitions.each do |competition|
json.extract! competition, :id, :identifier, :name, :sub_title
json.extract! competition, :id, :identifier, :name, :sub_title, :bonus, :description
json.visits_count competition.visits
member_count = @member_count_map&.fetch(competition.id, 0) || competition.team_members.count

@ -13,6 +13,7 @@ rescue => ex
puts %Q{\033[33m [warning] wechat config or configuration.yml missing,
please add it or execute 'cp config/configuration.yml.example config/configuration.yml' \033[0m}
wechat_config = {}
weapp_config = {}
end
# 网站应用

@ -790,6 +790,10 @@ Rails.application.routes.draw do
end
resources :teachers, only: [:index]
resources :students, only: [:index]
member do
get :common_header
end
end
end

@ -0,0 +1,6 @@
class AddDescriptionToCompetitions < ActiveRecord::Migration[5.2]
def change
add_column :competitions, :description, :text
add_column :competitions, :introduction, :text
end
end
Loading…
Cancel
Save