Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore views for Admin::EventsController#new, Admin::UsersController#edit #3129

Merged
merged 5 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/views/admin/events/new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.row
.col-md-12
.page-header
%h1
New Event
.row
.col-md-8
= form_for(@event, url: @url) do |f|
= render partial: 'proposals/form', locals: { f: f }
= render partial: 'shared/user_selectize'
44 changes: 44 additions & 0 deletions app/views/admin/users/_form.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
= form_for [:admin, @user] do |f|
%h4 Basic Information
- unless @user.new_record?
.pull-right
%b
Confirmed?
- if can? :toggle_confirmation, @user
= check_box_tag @user.id, @user.id, @user.confirmed?,
url: "#{toggle_confirmation_admin_user_path(@user.id)}?user[to_confirm]=",
class: 'switch-checkbox',
readonly: false
- else
= check_box_tag @user.id, @user.id, @user.confirmed?,
url: "#{toggle_confirmation_admin_user_path(@user.id)}?user[to_confirm]=",
class: 'switch-checkbox',
readonly: true
.checkbox
%label
= f.check_box :is_admin
Is admin
%span.help-block An admin can create a new conference, manage users and make other users admins.
.form-group
= f.label :name
= f.text_field :name, class: 'form-control'
- if @user.new_record?
.form-group
= label_tag :username
= text_field_tag :username, class: 'form-control'
.form-group
= f.label :email, required: true
%abbr{title: 'This field is required'} *
= f.email_field :email, required: true, class: 'form-control'
- if @user.new_record?
.form-group
= f.label :password
= f.password_field :password, class: 'form-control'
.form-group
= f.label :affiliation
= f.text_field :affiliation, class: 'form-control'
.form-group
= f.label :biography
= f.text_area :biography, rows: 10, data: { provide: 'markdown' }, class: 'form-control'
%span.help-block= markdown_hint
= f.submit nil, class: 'btn btn-primary'
1 change: 1 addition & 0 deletions app/views/admin/users/edit.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render partial: 'form'
21 changes: 13 additions & 8 deletions app/views/proposals/_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
- action_is_edit = @event.persisted?
- display_registration = current_user&.is_admin? || @program.cfp&.enable_registrations?
:ruby
action_is_edit = @event.persisted?
user_is_admin = current_user&.is_admin?
display_details = user_is_admin || action_is_edit
display_registration = user_is_admin || @program.cfp&.enable_registrations?

%h4
Proposal Information
Expand All @@ -8,11 +11,12 @@
= f.label :title
%abbr{title: 'This field is required'} *
= f.text_field :title, autofocus: true, required: true, class: 'form-control'
- if action_is_edit
- if display_details
.form-group
= f.label :subtitle
= f.text_field :subtitle, class: 'form-control'
.form-group
%label{for: 'users_selectize-selectized'} Speakers
= f.select :speaker_ids, f.object.speakers.pluck(:username, :id), {}, { multiple: true, class: "form-control", id: "users_selectize", placeholder: "Speakers" }
%span.help-block
The people responsible for the event, beside you. You can only select existing users.
Expand All @@ -31,7 +35,7 @@
= f.select :language, @languages, { include_blank: false}, { class: 'select-help-toggle form-control' }
= render 'shared/select_help_text', f: f, for: :event_type_id, options: @conference.program.event_types do |event_type|
= event_type.description
- if action_is_edit
- if display_details
- if @conference.program.difficulty_levels.any?
= f.label :difficulty_level
= f.select :difficulty_level_id, @conference.program.difficulty_levels.map{|level| [level.title, level.id ] }, {include_blank: false}, { class: 'select-help-toggle form-control' }
Expand All @@ -52,7 +56,7 @@
%span#abstract-maximum-word-count
250
words.
- if display_registration && action_is_edit
- if display_registration && display_details
%h4
Event Registration
%hr
Expand All @@ -61,13 +65,14 @@
%label
= f.check_box :require_registration
Require participants to register to your event
- if display_registration && action_is_edit
- if display_registration && display_details
.form-group
= f.number_field :max_attendees
= f.label :max_attendees
= f.number_field :max_attendees, class: 'form-control'
%span.help-block
- message = @event.room ? "Value must be between 1 and #{@event.room.size}" : 'Check room capacity after scheduling.'
= 'The maximum number of participants. ' + message
- if action_is_edit && current_user.has_any_role?(:admin, { name: :organizer, resource: @conference }, { name: :cfp, resource: @conference })
- if display_details && current_user.has_any_role?(:admin, { name: :organizer, resource: @conference }, { name: :cfp, resource: @conference })
.checkbox
%label
= f.check_box :is_highlight
Expand Down
9 changes: 9 additions & 0 deletions spec/features/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
sign_in organizer
end

scenario 'adds a proposal', feature: true, js: true do
visit admin_conference_program_events_path(conference.short_title)
click_on 'Add Event'
fill_in 'Title', with: 'Organizer-Created Proposal'
fill_in 'Abstract', with: 'This proposal was created by an organizer.'
click_button 'Create Proposal'
expect(flash).to eq('Event was successfully submitted.')
end

scenario 'rejects a proposal', feature: true, js: true do
visit admin_conference_program_events_path(conference.short_title)
expect(page).to have_content 'Example Proposal'
Expand Down
14 changes: 13 additions & 1 deletion spec/features/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@
require 'spec_helper'

feature User do
let(:admin) { create(:admin) }
let!(:user) { create(:user) }

shared_examples 'admin ability' do

scenario 'edits a user', feature: true, js: true do
visit admin_users_path
within "tr#user_#{user.id}" do
click_on 'Edit'
end
fill_in 'Name', with: 'Edited Name'
click_button 'Update User'
expect(flash).to include('Updated Edited Name')
end
end

describe 'admin' do
before { sign_in admin }

it_behaves_like 'admin ability', :admin
end
end