Skip to content

Commit

Permalink
Merge pull request #376 from cs169/187436627-registration-only-textbox
Browse files Browse the repository at this point in the history
187436627 registration only textbox - look at last
  • Loading branch information
cycomachead authored Aug 1, 2024
2 parents 04290cc + 389332a commit 0e26688
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 183 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def conference_params
:vpositions_attributes, :use_volunteers, :color,
:sponsorship_levels_attributes, :sponsors_attributes,
:registration_limit, :organization_id, :ticket_layout,
:booth_limit, :custom_css)
:booth_limit, :custom_css, :registered_attendees_message)
end
end
end
5 changes: 5 additions & 0 deletions app/controllers/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def show
# User messages at the top of the page.
@unpaid_tickets = current_user_has_unpaid_tickets?
@user_needs_to_register = current_user_needs_to_register?
@user_registered = current_user_registered?

@image_url = @splashpage.banner_photo_url || @conference.picture_url

Expand Down Expand Up @@ -141,6 +142,10 @@ def current_user_needs_to_register?
current_user_tickets.where(ticket: @conference.registration_tickets).paid.any?
end

def current_user_registered?
current_user && @conference.user_registered?(current_user)
end

def current_user_has_unpaid_tickets?
current_user && current_user_tickets.unpaid.any?
end
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class UsersController < ApplicationController
before_action :authenticate_user!, only: :search
before_action :set_currency_options, only: [:edit, :new, :create, :update]
load_and_authorize_resource

# GET /users/1
Expand Down Expand Up @@ -40,7 +41,7 @@ def search

def user_params
params[:user][:timezone] = params[:user][:timezone].presence || nil
params.require(:user).permit(:name, :biography, :nickname, :affiliation,
params.require(:user).permit(:name, :biography, :nickname, :affiliation, :default_currency,
:picture, :picture_cache, :timezone)
end

Expand All @@ -49,5 +50,9 @@ def user_params
def load_user
@user ||= (params[:id] && params[:id] != 'current' && User.find(params[:id])) || current_user
end

# rubocop:enable Naming/MemoizedInstanceVariableName
def set_currency_options
@currency_options = CurrencyConversion::VALID_CURRENCIES.map { |currency| [currency, currency] }
end
end
53 changes: 27 additions & 26 deletions app/models/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@
#
# Table name: conferences
#
# id :bigint not null, primary key
# booth_limit :integer default(0)
# color :string
# custom_css :text
# custom_domain :string
# description :text
# end_date :date not null
# end_hour :integer default(20)
# events_per_week :text
# guid :string not null
# logo_file_name :string
# picture :string
# registration_limit :integer default(0)
# revision :integer default(0), not null
# short_title :string not null
# start_date :date not null
# start_hour :integer default(9)
# ticket_layout :integer default("portrait")
# timezone :string not null
# title :string not null
# use_vdays :boolean default(FALSE)
# use_volunteers :boolean
# use_vpositions :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
# organization_id :integer
# id :bigint not null, primary key
# booth_limit :integer default(0)
# color :string
# custom_css :text
# custom_domain :string
# description :text
# end_date :date not null
# end_hour :integer default(20)
# events_per_week :text
# guid :string not null
# logo_file_name :string
# picture :string
# registered_attendees_message :text
# registration_limit :integer default(0)
# revision :integer default(0), not null
# short_title :string not null
# start_date :date not null
# start_hour :integer default(9)
# ticket_layout :integer default("portrait")
# timezone :string not null
# title :string not null
# use_vdays :boolean default(FALSE)
# use_volunteers :boolean
# use_vpositions :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
# organization_id :integer
#
# Indexes
#
Expand Down
2 changes: 2 additions & 0 deletions app/models/currency_conversion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class CurrencyConversion < ApplicationRecord
VALID_CURRENCIES = %w[AUD CAD CHF CNY EUR GBP JPY USD].freeze
belongs_to :conference
validates :rate, numericality: { greater_than: 0 }
# Ensure from_currency and to_currency are among the VALID_CURRENCIES
validates :from_currency, :to_currency, inclusion: { in: VALID_CURRENCIES }
validates :from_currency, uniqueness: { scope: :to_currency }, on: :create

def self.convert_currency(conference, amount, from_currency, to_currency)
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# default_currency :text
# email :string default(""), not null
# email_public :boolean default(FALSE)
# encrypted_password :string default(""), not null
Expand Down
53 changes: 27 additions & 26 deletions app/serializers/conference_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@
#
# Table name: conferences
#
# id :bigint not null, primary key
# booth_limit :integer default(0)
# color :string
# custom_css :text
# custom_domain :string
# description :text
# end_date :date not null
# end_hour :integer default(20)
# events_per_week :text
# guid :string not null
# logo_file_name :string
# picture :string
# registration_limit :integer default(0)
# revision :integer default(0), not null
# short_title :string not null
# start_date :date not null
# start_hour :integer default(9)
# ticket_layout :integer default("portrait")
# timezone :string not null
# title :string not null
# use_vdays :boolean default(FALSE)
# use_volunteers :boolean
# use_vpositions :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
# organization_id :integer
# id :bigint not null, primary key
# booth_limit :integer default(0)
# color :string
# custom_css :text
# custom_domain :string
# description :text
# end_date :date not null
# end_hour :integer default(20)
# events_per_week :text
# guid :string not null
# logo_file_name :string
# picture :string
# registered_attendees_message :text
# registration_limit :integer default(0)
# revision :integer default(0), not null
# short_title :string not null
# start_date :date not null
# start_hour :integer default(9)
# ticket_layout :integer default("portrait")
# timezone :string not null
# title :string not null
# use_vdays :boolean default(FALSE)
# use_volunteers :boolean
# use_vpositions :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
# organization_id :integer
#
# Indexes
#
Expand Down
52 changes: 6 additions & 46 deletions app/views/admin/conferences/_form_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
= f.label :description
= f.text_area :description, rows: 5, data: { provide: 'markdown' }, class: 'form-control'
.help-block= markdown_hint('Splash page content')
.form-group
= f.label :registered_attendees_message, 'Message for Registered Attendees'
= f.text_area :registered_attendees_message, rows: 5, data: { provide: 'markdown' }, class: 'form-control'
.help-block= markdown_hint('Splash page content')
.form-group
= f.color_field :color, size: 6, class: 'form-control'
%span.help-block
Expand All @@ -46,52 +50,8 @@
= f.select :ticket_layout, Conference.ticket_layouts.keys, {}, class: 'form-control'
%span.help-block
Layout type for tickets of the conference.

%h4 Scheduling
%hr
.form-group
= f.label :timezone
= f.time_zone_select :timezone, nil, { default: 'UTC' }, { class: 'form-control' }
%span.help-block
Please select in what time zone your conference will take place.
.form-group
= f.label :start_date, "Start Date"
%abbr{title: 'This field is required'} *
= f.text_field :start_date, id: 'conference-start-datepicker', required: true, class: 'form-control'
.form-group
= f.label :end_date, "End Date"
%abbr{title: 'This field is required'} *
= f.text_field :end_date, id: 'conference-end-datepicker', required: true, class: 'form-control'
- unless f.object.new_record?
.form-group
= f.label :start_hour
= f.number_field :start_hour, size: 2, min: 0, max: 23, class: 'form-control'
%span.help-block
= rescheduling_hint(@affected_event_count)
.form-group
= f.label :end_hour
= f.number_field :end_hour, size: 2, min: 1, max: 24, class: 'form-control'
%span.help-block
= rescheduling_hint(@affected_event_count)
%h4 Registrations
%hr
.form-group
= f.label :registration_limit
= f.number_field :registration_limit, in: 0..9999, class: 'form-control'
%span.help-block
Limit the number of registrations to the conference (0 no limit). Please note that the registration limit
does not apply to speakers of confirmed events, they will still be able to register even if the limit has been reached.
You currently have #{pluralize(@conference.registrations.count, 'registration')}.
%h4
Booths
%hr
.form-group
= f.label :booth_limit
= f.number_field :booth_limit, in: 0..9999, class: 'form-control'
%span.help-block
#{(t'booth').capitalize} limit is the maximum number of #{(t'booth').pluralize}
that you can accept for this conference. By setting this number (0 no limit) you can be sure that you are not going to accept more #{(t'booth').pluralize}
than the conference can accommodate. You currently have #{pluralize(@conference.booths.accepted.count, "accepted #{t'booth'}")}.
=render partial: 'scheduling_form_fields', locals: {f: f}
=render partial: 'registration_and_booth_form_fields', locals: {f: f}
%p.text-right
- if f.object.new_record?
= f.submit nil, { class: 'btn btn-success' }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- unless f.object.new_record?
%h4 Registrations
%hr
.form-group
= f.label :registration_limit
= f.number_field :registration_limit, in: 0..9999, class: 'form-control'
%span.help-block
Limit the number of registrations to the conference (0 no limit). Please note that the registration limit
does not apply to speakers of confirmed events, they will still be able to register even if the limit has been reached.
You currently have #{pluralize(@conference.registrations.count, 'registration')}.
%h4 Booths
%hr
.form-group
= f.label :booth_limit
= f.number_field :booth_limit, in: 0..9999, class: 'form-control'
%span.help-block
#{(t'booth').capitalize} limit is the maximum number of #{(t'booth').pluralize}
that you can accept for this conference. By setting this number (0 no limit) you can be sure that you are not going to accept more #{(t'booth').pluralize}
than the conference can accommodate. You currently have #{pluralize(@conference.booths.accepted.count, "accepted #{t'booth'}")}.
26 changes: 26 additions & 0 deletions app/views/admin/conferences/_scheduling_form_fields.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
%h4 Scheduling
%hr
.form-group
= f.label :timezone
= f.time_zone_select :timezone, nil, { default: 'UTC' }, { class: 'form-control' }
%span.help-block
Please select in what time zone your conference will take place.
.form-group
= f.label :start_date, "Start Date"
%abbr{title: 'This field is required'} *
= f.text_field :start_date, id: 'conference-start-datepicker', required: true, class: 'form-control'
.form-group
= f.label :end_date, "End Date"
%abbr{title: 'This field is required'} *
= f.text_field :end_date, id: 'conference-end-datepicker', required: true, class: 'form-control'
- unless f.object.new_record?
.form-group
= f.label :start_hour
= f.number_field :start_hour, size: 2, min: 0, max: 23, class: 'form-control'
%span.help-block
= rescheduling_hint(@affected_event_count)
.form-group
= f.label :end_hour
= f.number_field :end_hour, size: 2, min: 1, max: 24, class: 'form-control'
%span.help-block
= rescheduling_hint(@affected_event_count)
3 changes: 0 additions & 3 deletions app/views/admin/currency_conversions/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
%h1 Currency Conversions
%p.text-muted
Enter the currency conversions for this conference
%p.alert.alert-warning
%strong Warning:
Currency conversion feature has not been implemented yet. Do not add any currency conversions.
.row
.col-md-12
%table.table.table-hover#currency-conversions
Expand Down
2 changes: 2 additions & 0 deletions app/views/conferences/_about_and_happening_now.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

= content_for :about do
#about
-if @user_registered && conference.registered_attendees_message.present?
= markdown(conference.registered_attendees_message, false)
= markdown(conference.description, false)

%section#about-and-happening-now
Expand Down
3 changes: 3 additions & 0 deletions app/views/users/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
The timezone setting will update the event schedules to show using the time you selected.
Your browser is current set to
%span.js-localTimezone
.form-group
= f.label :default_currency, 'Default Currency'
= f.select :default_currency, options_for_select(@currency_options, selected: @user.default_currency), {}, { class: 'form-control' }
.form-group
= f.label :avatar
%br
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class SetCurrencyForNullTicketPurchaseCurrency < ActiveRecord::Migration[7.0]
def up
TicketPurchase.where(currency: nil).update_all(currency: 'USD')
# TicketPurchase.where(currency: nil).update_all(currency: 'USD')
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddRegisteredAttendeesMessageToConferences < ActiveRecord::Migration[7.0]
def change
add_column :conferences, :registered_attendees_message, :text
end
end
7 changes: 7 additions & 0 deletions db/migrate/20240801042356_add_default_currency_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddDefaultCurrencyToUsers < ActiveRecord::Migration[7.0]
def change
unless ActiveRecord::Base.connection.column_exists?(:users, :default_currency)
add_column :users, :default_currency, :text
end
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_04_22_200831) do
ActiveRecord::Schema[7.0].define(version: 2024_08_01_042356) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "plpgsql"
Expand Down Expand Up @@ -109,6 +109,7 @@
t.string "custom_domain"
t.integer "booth_limit", default: 0
t.text "custom_css"
t.text "registered_attendees_message"
t.index ["organization_id"], name: "index_conferences_on_organization_id"
end

Expand Down Expand Up @@ -627,6 +628,7 @@
t.boolean "is_disabled", default: false
t.string "picture"
t.string "timezone"
t.text "default_currency"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
Expand Down
Loading

0 comments on commit 0e26688

Please sign in to comment.