forked from Trustie/forgeplus
fixed 资讯增加活动报名
This commit is contained in:
parent
ef867e1e83
commit
eb7f4e6da3
|
|
@ -325,7 +325,7 @@ class CompetitionInfosController < ApplicationController
|
|||
def competition_info_params
|
||||
params.require(:competition_info).permit(:title, :zones, :zones_local, :sub_competitions, :identifier, :content,
|
||||
:video_url, :is_local, :manager_ids, :upload_date, :enroll_date, :guide, :about_us,
|
||||
:banner_url, :enroll_template, :enroll_columns, :applet_banner_url,:start_at)
|
||||
:banner_url, :enroll_template, :enroll_columns, :applet_banner_url,:start_at, :sort_no)
|
||||
end
|
||||
|
||||
def find_competition
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ class WatchersController < ApplicationController
|
|||
@target = target_type.capitalize.constantize.find_by(id: params[:id])
|
||||
when "competition_info"
|
||||
@target = CompetitionInfo.where(:identifier => params[:id]).exists? ? CompetitionInfo.find_by(:identifier => params[:id]) : CompetitionInfo.find_by(id: params[:id])
|
||||
when "platform_communicate"
|
||||
@target = PlatformCommunicate.find_by(id: params[:id])
|
||||
else
|
||||
@target = target_type.capitalize.constantize.find_by(login: params[:id]) #用户
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,15 +2,18 @@
|
|||
#
|
||||
# Table name: platform_communicates
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# title :string(255)
|
||||
# content :text(65535)
|
||||
# tag_field :text(65535)
|
||||
# fake_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# order_index :integer default(0)
|
||||
# id :integer not null, primary key
|
||||
# title :string(255)
|
||||
# content :text(65535)
|
||||
# tag_field :text(65535)
|
||||
# fake_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# order_index :integer default("0")
|
||||
# watchers_count :integer default("0")
|
||||
#
|
||||
|
||||
class PlatformCommunicate < ApplicationRecord
|
||||
|
||||
has_many :watchers, as: :watchable, dependent: :destroy
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
json.status 0
|
||||
json.message "success"
|
||||
json.data do
|
||||
json.extract! @competition_info, :id, :identifier, :title, :content, :video_url, :is_local, :enroll_date, :upload_date, :guide, :about_us,:banner_url,:enroll_template, :applet_banner_url, :watchers_count,:start_at, :visits
|
||||
json.extract! @competition_info, :id, :identifier, :title, :content, :video_url, :is_local, :enroll_date, :upload_date, :guide, :about_us,:banner_url,:enroll_template, :applet_banner_url, :watchers_count,:start_at, :visits, :sort_no
|
||||
json.zones @competition_info.competition_zones
|
||||
json.sub_competitions @competition_info.sub_competitions.to_s.split(",")
|
||||
json.is_manager @competition_info.is_manager?(current_user)
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@ json.communicates do
|
|||
json.(communicate, :id, :title, :content, :fake_id)
|
||||
json.tag communicate.tag_field.include?(',') ? communicate.tag_field.split(",") : communicate.tag_field
|
||||
json.created_time format_time(Memo.find_by(id: communicate.fake_id)&.published_at)
|
||||
json.watched current_user.watched?(communicate)
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
class AddCompetitionInfoSort < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :competition_infos, :sort_no, :integer, default: 0
|
||||
add_column :platform_communicates, :watchers_count, :integer, default: 0
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue