Merge pull request #3129 from AndrewKvalheim/restore-views
Restore views for `Admin::EventsController#new`, `Admin::UsersController#edit`
This commit is contained in:
commit
fc507e8df3
6 changed files with 90 additions and 9 deletions
10
app/views/admin/events/new.html.haml
Normal file
10
app/views/admin/events/new.html.haml
Normal file
|
|
@ -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
app/views/admin/users/_form.html.haml
Normal file
44
app/views/admin/users/_form.html.haml
Normal file
|
|
@ -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
app/views/admin/users/edit.html.haml
Normal file
1
app/views/admin/users/edit.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
= render partial: 'form'
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
- action_is_edit = @event.persisted?
|
:ruby
|
||||||
- display_registration = current_user&.is_admin? || @program.cfp&.enable_registrations?
|
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
|
%h4
|
||||||
Proposal Information
|
Proposal Information
|
||||||
|
|
@ -8,11 +11,12 @@
|
||||||
= f.label :title
|
= f.label :title
|
||||||
%abbr{title: 'This field is required'} *
|
%abbr{title: 'This field is required'} *
|
||||||
= f.text_field :title, autofocus: true, required: true, class: 'form-control'
|
= f.text_field :title, autofocus: true, required: true, class: 'form-control'
|
||||||
- if action_is_edit
|
- if display_details
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :subtitle
|
= f.label :subtitle
|
||||||
= f.text_field :subtitle, class: 'form-control'
|
= f.text_field :subtitle, class: 'form-control'
|
||||||
.form-group
|
.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" }
|
= f.select :speaker_ids, f.object.speakers.pluck(:username, :id), {}, { multiple: true, class: "form-control", id: "users_selectize", placeholder: "Speakers" }
|
||||||
%span.help-block
|
%span.help-block
|
||||||
The people responsible for the event, beside you. You can only select existing users.
|
The people responsible for the event, beside you. You can only select existing users.
|
||||||
|
|
@ -31,7 +35,7 @@
|
||||||
= f.select :language, @languages, { include_blank: false}, { class: 'select-help-toggle form-control' }
|
= 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|
|
= render 'shared/select_help_text', f: f, for: :event_type_id, options: @conference.program.event_types do |event_type|
|
||||||
= event_type.description
|
= event_type.description
|
||||||
- if action_is_edit
|
- if display_details
|
||||||
- if @conference.program.difficulty_levels.any?
|
- if @conference.program.difficulty_levels.any?
|
||||||
= f.label :difficulty_level
|
= 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' }
|
= f.select :difficulty_level_id, @conference.program.difficulty_levels.map{|level| [level.title, level.id ] }, {include_blank: false}, { class: 'select-help-toggle form-control' }
|
||||||
|
|
@ -52,7 +56,7 @@
|
||||||
%span#abstract-maximum-word-count
|
%span#abstract-maximum-word-count
|
||||||
250
|
250
|
||||||
words.
|
words.
|
||||||
- if display_registration && action_is_edit
|
- if display_registration && display_details
|
||||||
%h4
|
%h4
|
||||||
Event Registration
|
Event Registration
|
||||||
%hr
|
%hr
|
||||||
|
|
@ -61,13 +65,14 @@
|
||||||
%label
|
%label
|
||||||
= f.check_box :require_registration
|
= f.check_box :require_registration
|
||||||
Require participants to register to your event
|
Require participants to register to your event
|
||||||
- if display_registration && action_is_edit
|
- if display_registration && display_details
|
||||||
.form-group
|
.form-group
|
||||||
= f.number_field :max_attendees
|
= f.label :max_attendees
|
||||||
|
= f.number_field :max_attendees, class: 'form-control'
|
||||||
%span.help-block
|
%span.help-block
|
||||||
- message = @event.room ? "Value must be between 1 and #{@event.room.size}" : 'Check room capacity after scheduling.'
|
- message = @event.room ? "Value must be between 1 and #{@event.room.size}" : 'Check room capacity after scheduling.'
|
||||||
= 'The maximum number of participants. ' + message
|
= '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
|
.checkbox
|
||||||
%label
|
%label
|
||||||
= f.check_box :is_highlight
|
= f.check_box :is_highlight
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,15 @@ feature Event do
|
||||||
sign_in organizer
|
sign_in organizer
|
||||||
end
|
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
|
scenario 'rejects a proposal', feature: true, js: true do
|
||||||
visit admin_conference_program_events_path(conference.short_title)
|
visit admin_conference_program_events_path(conference.short_title)
|
||||||
expect(page).to have_content 'Example Proposal'
|
expect(page).to have_content 'Example Proposal'
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,24 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature User do
|
feature User do
|
||||||
|
let(:admin) { create(:admin) }
|
||||||
|
let!(:user) { create(:user) }
|
||||||
|
|
||||||
shared_examples 'admin ability' do
|
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
|
end
|
||||||
|
|
||||||
describe 'admin' do
|
describe 'admin' do
|
||||||
|
before { sign_in admin }
|
||||||
|
|
||||||
it_behaves_like 'admin ability', :admin
|
it_behaves_like 'admin ability', :admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue