Skip to content

Commit

Permalink
Merge pull request #2014 from cloudnativedaysjp/simplify_ticket_system
Browse files Browse the repository at this point in the history
Simplify ticket system
  • Loading branch information
takaishi authored Sep 17, 2023
2 parents 2cfc7bc + 9473095 commit 696cc40
Show file tree
Hide file tree
Showing 55 changed files with 175 additions and 722 deletions.
1 change: 1 addition & 0 deletions app/controllers/admin/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def conference_params
:show_timetable,
:show_sponsors,
:brief,
:capacity,
:privacy_policy,
:privacy_policy_for_speaker,
links_attributes: [:id, :title, :url, :description, :_destroy],
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def users

def statistics
@talks = @conference.talks.includes(:registered_talks).accepted.order('conference_day_id ASC, start_time ASC, track_id ASC')
@tickets = @conference.tickets.includes(:check_ins)
end

def export_statistics
Expand Down
31 changes: 0 additions & 31 deletions app/controllers/cancel_orders_controller.rb

This file was deleted.

11 changes: 1 addition & 10 deletions app/controllers/concerns/secured.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Secured
included do
before_action :redirect_to_website
before_action :to_preparance, :redirect_to_registration, if: :should_redirect?
before_action :logged_in_using_omniauth?, :to_preparance, :need_order?, if: :use_secured_before_action?
before_action :logged_in_using_omniauth?, :to_preparance, if: :use_secured_before_action?
helper_method :admin?, :speaker?, :beta_user?
end

Expand Down Expand Up @@ -50,15 +50,6 @@ def new_user?
logged_in? && !Profile.find_by(email: set_current_user[:info][:email], conference_id: set_conference.id)
end

def need_order?
if logged_in? && set_profile.instance_of?(Profile) && Profile.find_by(email: set_current_user[:info][:email], conference_id: set_conference.id)
profile = Profile.find_by(email: set_current_user[:info][:email], conference_id: set_conference.id)
if profile.orders.empty? || profile.orders.all? { |order| order.cancel_order.present? }
redirect_to(new_order_path)
end
end
end

def admin?
@current_user[:extra][:raw_info]['https://cloudnativedays.jp/roles'].include?("#{conference.abbr.upcase}-Admin")
end
Expand Down
39 changes: 0 additions & 39 deletions app/controllers/orders_controller.rb

This file was deleted.

16 changes: 7 additions & 9 deletions app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ def create
Agreement.create!(profile_id: @profile.id, form_item_id: 9, value: 1) if agreement_params['redhat_require_tel_cndt2022']

ProfileMailer.registered(@profile, @conference).deliver_later
redirect_to(new_order_path)
if @profile.public_profile.present?
redirect_to("/#{event_name}/public_profiles/#{@profile.public_profile.id}/edit")
else
redirect_to("/#{event_name}/public_profiles/new")
end
else
respond_to do |format|
format.html { render(:new) }
Expand All @@ -51,7 +55,6 @@ def create
def update
postal_code = profile_params[:company_postal_code].gsub(/-/, '')
tel = profile_params[:company_tel].gsub(/-/, '')

respond_to do |format|
if @profile.update(profile_params.merge(conference_id: @conference.id, company_postal_code: postal_code, company_tel: tel))
format.html { redirect_to(edit_profile_path(id: @profile.id), notice: '登録情報の変更が完了しました') }
Expand Down Expand Up @@ -101,15 +104,9 @@ def profile_url
end

def checkin
ticket = Ticket.find_by(id: params[:ticket_id])
if @profile.present? &&
ticket.present? &&
@profile.active_order.present? &&
CheckIn.where(profile_id: @profile.id, order_id: @profile.active_order.id, ticket_id: ticket.id).empty?
if @profile.present?
c = CheckIn.new
c.profile_id = @profile.id
c.order_id = @profile.active_order.id
c.ticket_id = ticket.id
c.save

# TODO: This is a temporary solution. We should replace hardcoded values after CNDT2022.
Expand Down Expand Up @@ -171,6 +168,7 @@ def profile_params
:company_tel,
:department,
:position,
:participation,
:roles,
:conference_id,
:number_of_employee_id,
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/public_profiles_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class PublicProfilesController < ApplicationController
include Secured
before_action :set_conference
before_action :set_conference, :set_profile

def new
@public_profile = PublicProfile.new(profile_id: @profile.id)
Expand Down Expand Up @@ -31,7 +31,7 @@ def update

respond_to do |format|
if @public_profile.update(public_profile_params)
format.html { redirect_to(edit_public_profile_path(id: @public_profile.id), notice: 'プロフィールのの変更が完了しました') }
format.html { redirect_to(edit_public_profile_path(id: @public_profile.id), notice: 'プロフィールの変更が完了しました') }
format.json { render(:show, status: :ok, location: @public_profile) }
else
format.html { render(:edit, notice: 'プロフィールの変更時にエラーが発生しました') }
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/tickets_controller.rb

This file was deleted.

4 changes: 3 additions & 1 deletion app/forms/conference_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ConferenceForm
attr_accessor :attendee_entry
attr_accessor :show_timetable
attr_accessor :show_sponsors
attr_accessor :capacity
attr_accessor :brief
attr_accessor :privacy_policy
attr_accessor :privacy_policy_for_speaker
Expand Down Expand Up @@ -97,7 +98,7 @@ def save
return if invalid?

ActiveRecord::Base.transaction do
conference.update!(conference_status:, cfp_result_visible:, speaker_entry:, attendee_entry:, show_timetable:, show_sponsors:, brief:, privacy_policy:, privacy_policy_for_speaker:)
conference.update!(conference_status:, cfp_result_visible:, speaker_entry:, attendee_entry:, show_timetable:, show_sponsors:, capacity:, brief:, privacy_policy:, privacy_policy_for_speaker:)
end
rescue => e
puts(e)
Expand Down Expand Up @@ -126,6 +127,7 @@ def default_attributes
show_timetable: conference.show_timetable,
show_sponsors: conference.show_sponsors,
links:,
capacity: conference.capacity,
conference_days:,
brief: conference.brief,
privacy_policy: conference.privacy_policy,
Expand Down
7 changes: 7 additions & 0 deletions app/javascript/stylesheets/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,18 @@ footer ul li {
text-decoration: none;
}
}

.registration-form {
background: rgba(256, 256, 256, 0.8);
span.required {
color: $red;
}
span.warning {
color: $red;
}
.reached_capacity {
text-decoration: line-through;
}
a {
text-decoration: underline;
}
Expand Down
22 changes: 0 additions & 22 deletions app/models/cancel_order.rb

This file was deleted.

6 changes: 0 additions & 6 deletions app/models/check_in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# order_id :string(255)
# profile_id :integer
# ticket_id :string(255)
#
# Indexes
#
# index_check_ins_on_order_id (order_id)
# index_check_ins_on_profile_id (profile_id)
# index_check_ins_on_ticket_id (ticket_id)
#
class CheckIn < ApplicationRecord
has_one :ticket
has_one :order
has_one :profile
end
7 changes: 6 additions & 1 deletion app/models/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# about :text(65535)
# attendee_entry :integer default("attendee_entry_disabled")
# brief :string(255)
# capacity :integer
# cfp_result_visible :boolean default(FALSE)
# coc :text(65535)
# committee_name :string(255) default("CloudNative Days Committee"), not null
Expand Down Expand Up @@ -69,7 +70,6 @@ class Conference < ApplicationRecord
has_many :admin_profiles
has_many :live_stream_media_live
has_many :media_package_harvest_jobs
has_many :tickets
has_many :rooms

scope :upcoming, -> {
Expand All @@ -84,6 +84,11 @@ class Conference < ApplicationRecord
merge(where(conference_status: Conference::STATUS_REGISTERED).or(where(conference_status: Conference::STATUS_OPENED)).or(where(conference_status: Conference::STATUS_CLOSED)))
}

def reach_capacity?
return false if capacity.nil?
profiles.where(participation: 'offline').size >= capacity
end

def remaining_date
(conference_days.where(internal: false).order(:date).first.date - Date.today).floor
end
Expand Down
27 changes: 0 additions & 27 deletions app/models/order.rb

This file was deleted.

26 changes: 0 additions & 26 deletions app/models/orders_ticket.rb

This file was deleted.

Loading

0 comments on commit 696cc40

Please sign in to comment.