Skip to content

Commit

Permalink
Cleanup and validations
Browse files Browse the repository at this point in the history
  • Loading branch information
beingmattlevy committed Jul 12, 2024
1 parent 6c5b639 commit f978a4f
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 65 deletions.
2 changes: 0 additions & 2 deletions Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ brew 'minikube'
brew 'kubernetes-cli'

cask 'chromedriver'
# cask 'github'

cask 'font-andale-mono'
cask 'font-anonymice-powerline'
Expand Down Expand Up @@ -112,6 +111,5 @@ cask 'font-roboto'
cask 'font-roboto-mono-nerd-font'
cask 'font-share-tech-mono'
cask 'font-sometype-mono'
# cask 'font-titillium'
cask 'font-ubuntu'
cask 'font-victor-mono'
6 changes: 6 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Event < ApplicationRecord
normalize_attributes :name

before_validation :generate_slug!
before_validation :ensure_require_role_set_default

validates :name, presence: true, length: { maximum: MAX_NAME_LENGTH }
validates :start_time, presence: true
Expand Down Expand Up @@ -236,4 +237,9 @@ def ensure_prices_set_if_maximum_specified
'can be set only if a cabin price is set')
end
end

def ensure_require_role_set_default
attributes[:require_role] = true if attributes[:require_role].nil?
end

end
57 changes: 57 additions & 0 deletions app/views/ticket_requests/_event_role.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
%h4 How are you contributing to the event?
.content-fluid
.row
.col-lg-6.col-xl-6.col-md-12.col-sm-12
.input-group-large
%fieldset
%p
= f.label :role_volunteer do
= f.label :role_volunteer, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_VOLUNTEER,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_VOLUNTEER] }
= TicketRequest::ROLES[TicketRequest::ROLE_VOLUNTEER]
= f.label :role_contributor, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_CONTRIBUTOR,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_CONTRIBUTOR] }
= TicketRequest::ROLES[TicketRequest::ROLE_CONTRIBUTOR]
= f.label :role_coordinator, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_COORDINATOR,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_COORDINATOR] }
= TicketRequest::ROLES[TicketRequest::ROLE_COORDINATOR]
= f.label :role_uber_coordinator, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_UBER_COORDINATOR,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_UBER_COORDINATOR] }
= TicketRequest::ROLES[TicketRequest::ROLE_UBER_COORDINATOR]
= f.label :role_other, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_OTHER,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_OTHER] }
= TicketRequest::ROLES[TicketRequest::ROLE_OTHER]

.col-lg-6.col-xl-6.col-md-12.col-sm-12.align-content-md-center
%p.muted.role-explanation{ class: TicketRequest::ROLE_VOLUNTEER }
You are working one or more shifts at the event

%p.muted.role-explanation.hidden{ class: TicketRequest::ROLE_CONTRIBUTOR }
Working before and during or during and after; actively involved in
planning the campout e.g. a coordinator assistant or apprentice. Bringing
gear, driving trucks, art committee, etc.

%p.muted.role-explanation.hidden{ class: TicketRequest::ROLE_COORDINATOR }
Listed on the Coordinator Sheet as someone who is leading a major area of
camp out planning; working before, during, and after the event including
things like resource coordination, significant gear prep, pre/post-site
visits, etc.

%p.muted.role-explanation.hidden{ class: TicketRequest::ROLE_OTHER }
Art Grantee or DJ

= f.text_area :role_explanation,
placeholder: 'Briefly describe your role',
rows: 4, width: 400, maxlength: 200, required: false, style: 'min-width: 100% !important; font-size: 11pt;'

.row
.col-lg-6.col-xl-6.col-md-12.col-sm-12
- if @event.require_role
= f.label :previous_contribution, 'What was your role last year?'
= f.text_area :previous_contribution, style: 'min-width: 100%',
rows: 2, maxlength: 250, required: false
58 changes: 1 addition & 57 deletions app/views/ticket_requests/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -88,63 +88,7 @@
- if !@ticket_request.post_payment? || (@event.admin?(current_user) && is_update)
%hr
- if @event.require_role
%h4 How are you contributing to the event?
.content-fluid
.row
.col-lg-6.col-xl-6.col-md-12.col-sm-12
.input-group-large
%fieldset
%p
= f.label :role_volunteer do
= f.label :role_volunteer, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_VOLUNTEER,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_VOLUNTEER] }
= TicketRequest::ROLES[TicketRequest::ROLE_VOLUNTEER]
= f.label :role_contributor, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_CONTRIBUTOR,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_CONTRIBUTOR] }
= TicketRequest::ROLES[TicketRequest::ROLE_CONTRIBUTOR]
= f.label :role_coordinator, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_COORDINATOR,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_COORDINATOR] }
= TicketRequest::ROLES[TicketRequest::ROLE_COORDINATOR]
= f.label :role_uber_coordinator, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_UBER_COORDINATOR,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_UBER_COORDINATOR] }
= TicketRequest::ROLES[TicketRequest::ROLE_UBER_COORDINATOR]
= f.label :role_other, class: 'radio inline' do
= f.radio_button :role, TicketRequest::ROLE_OTHER,
data: { 'max-tickets' => TicketRequest::TICKET_LIMITS[TicketRequest::ROLE_OTHER] }
= TicketRequest::ROLES[TicketRequest::ROLE_OTHER]

.col-lg-6.col-xl-6.col-md-12.col-sm-12.align-content-md-center
%p.muted.role-explanation{ class: TicketRequest::ROLE_VOLUNTEER }
You are working one or more shifts at the event

%p.muted.role-explanation.hidden{ class: TicketRequest::ROLE_CONTRIBUTOR }
Working before and during or during and after; actively involved in
planning the campout e.g. a coordinator assistant or apprentice. Bringing
gear, driving trucks, art committee, etc.

%p.muted.role-explanation.hidden{ class: TicketRequest::ROLE_COORDINATOR }
Listed on the Coordinator Sheet as someone who is leading a major area of
camp out planning; working before, during, and after the event including
things like resource coordination, significant gear prep, pre/post-site
visits, etc.

%p.muted.role-explanation.hidden{ class: TicketRequest::ROLE_OTHER }
Art Grantee or DJ

= f.text_area :role_explanation,
placeholder: 'Briefly describe your role',
rows: 4, width: 400, maxlength: 200, required: false, style: 'min-width: 100% !important; font-size: 11pt;'

.row
.col-lg-6.col-xl-6.col-md-12.col-sm-12
- if @event.require_role
= f.label :previous_contribution, 'What was your role last year?'
= f.text_area :previous_contribution, style: 'min-width: 100%',
rows: 2, maxlength: 250, required: false
= render partial: :event_role

- if signed_in? && @event.admin?(current_user) && is_update
.well
Expand Down
11 changes: 6 additions & 5 deletions app/views/ticket_requests/_table_ticket_requests.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

%tr
%th.bg-dark-subtle Name
%th.bg-dark-subtle.optional-medium Role
%th.bg-dark-subtle
- if event.require_role
%th.bg-dark-subtle.optional-medium Role
%th.bg-dark-subtle Notes
%th.bg-dark-subtle.text-end.optional-medium Tickets
- if event.kid_ticket_price
%th.bg-dark-subtle.text-end.optional-medium Kids
Expand All @@ -30,9 +31,9 @@
= link_to event_ticket_request_path(event, ticket_request) do
= ticket_request.user.name
%td.muted.align-content-center.optional-medium
= TicketRequest::ROLES[ticket_request.role]
- if ticket_request.role_explanation.present?
- if event.require_role
%td.muted.align-content-center.optional-medium
= TicketRequest::ROLES[ticket_request.role]
%i.icon-comment.hover-tooltip{ title: ticket_request.role_explanation }
%td.align-content-center.text-start.text-nowrap
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/events_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
expect(new_event.start_time.to_datetime).to be_a(DateTime)
end

it 'has requires role to be true' do
it 'has require_role set to true' do
expect(new_event.require_role).to be_truthy
end

Expand Down

0 comments on commit f978a4f

Please sign in to comment.