Skip to content

Commit

Permalink
admin vs non-admin dropdown and descriptions event types working
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanylamm committed Apr 5, 2024
1 parent b1375b5 commit 784d50f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
11 changes: 5 additions & 6 deletions app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class ProposalsController < ApplicationController
include ConferenceHelper
before_action :authenticate_user!, except: %i[show new create]
before_action :set_is_admin
load_resource :conference, find_by: :short_title
load_resource :program, through: :conference, singleton: true
load_and_authorize_resource :event, parent: false, through: :program
Expand Down Expand Up @@ -31,12 +32,6 @@ def new
@url = conference_program_proposals_path(@conference.short_title)
@languages = @program.languages_list
@superevents = @program.super_events

if current_user.is_admin?
@event_types = @program.event_types
else
@event_types = @program.event_types.available_for_public
end
end

def edit
Expand Down Expand Up @@ -224,4 +219,8 @@ def event_params
def user_params
params.require(:user).permit(:email, :password, :password_confirmation, :username)
end

def set_is_admin
@is_admin = current_user.is_admin
end
end
12 changes: 10 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,16 @@ def volunteer_links(event)
end, ', ')
end

def event_types_sentence(conference)
conference.event_types.map { |et| et.title.pluralize }.to_sentence
def event_types_sentence(conference, is_admin = true)
if is_admin
conference.event_types.map { |et| et.title.pluralize }.to_sentence
else
conference.event_types.available_for_public.map { |et| et.title.pluralize }.to_sentence
end
end

def event_types_dropdown(conference, is_admin = true)
is_admin ? conference.event_types : conference.event_types.available_for_public
end

def sign_in_path
Expand Down
2 changes: 1 addition & 1 deletion app/views/proposals/_encouragement_text.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%p.lead
- if @program.event_types.any?
You can submit proposals for
= "#{event_types_sentence(@conference)}."
= "#{event_types_sentence(@conference, @is_admin)}."
- if @program.tracks.confirmed.cfp_active.any?
Proposals should fit in one of the
= "#{pluralize(@program.tracks.confirmed.cfp_active.count, 'track')}:"
Expand Down
4 changes: 2 additions & 2 deletions app/views/proposals/_submission_type_content_form.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
%p Please select a submission type, then fill in the abstract and extended details.

.form-group
= f.label :event_type_id, 'Type'
= f.select :event_type_id, event_type_select_options(@conference.program.event_types), { include_blank: false }, { class: 'select-help-toggle form-control' }
= f.label :event_type_id, "Type"
= f.select :event_type_id, event_type_select_options(event_types_dropdown(@conference, @is_admin)), { include_blank: false }, { class: 'select-help-toggle form-control' }

- program.event_types.each do |event_type|
.help-block.event_event_type_id.collapse{ id: "#{dom_id(event_type)}-help" }
Expand Down

0 comments on commit 784d50f

Please sign in to comment.