osem-fcy/app/views/admin/users/_form.html.haml

84 lines
3 KiB
Text
Raw Normal View History

= 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'
2025-10-13 17:38:44 +02:00
- unless @user.new_record?
%hr
%h4 Conference Registration
.row
.col-md-6
%h5 Register to Conference
= form_with url: register_user_admin_user_path(@user), local: true, method: :post do |form|
.form-group
= form.label :conference_id, 'Select Conference'
= form.select :conference_id,
options_from_collection_for_select(Conference.all.order(:title), :id, :title),
{ prompt: 'Choose a conference...' },
{ class: 'form-control', required: true }
= form.submit 'Register User', class: 'btn btn-success'
.col-md-6
%h5 Current Registrations
- if @user.registrations.any?
.table-responsive
%table.table.table-condensed
%thead
%tr
%th Conference
%th Registered On
%th Actions
%tbody
- @user.registrations.includes(:conference).each do |registration|
%tr
%td= registration.conference.title
%td= registration.created_at.strftime('%B %d, %Y')
%td
= link_to 'Remove',
unregister_user_admin_user_path(@user, registration_id: registration.id),
method: :delete,
class: 'btn btn-xs btn-danger',
confirm: 'Are you sure you want to remove this registration?'
- else
%p.text-muted No current registrations