mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #1097 from shlok007/manual_confirmation
Ability to confirm users by admin
This commit is contained in:
commit
9c5fd18c3e
7 changed files with 90 additions and 16 deletions
|
|
@ -10,6 +10,17 @@ module Admin
|
|||
@users = User.all
|
||||
end
|
||||
|
||||
# This action allow admins to manually toggle confirmation state of another user
|
||||
def toggle_confirmation
|
||||
if user_params[:to_confirm] == 'true'
|
||||
@user.confirm
|
||||
elsif user_params[:to_confirm] == 'false'
|
||||
@user.confirmed_at = nil
|
||||
@user.save
|
||||
end
|
||||
head :ok
|
||||
end
|
||||
|
||||
def show
|
||||
# Variable @show_attributes holds the attributes that are visible for the 'show' action
|
||||
# If you want to change the attributes that are shown in the 'show' action of users
|
||||
|
|
@ -40,7 +51,7 @@ module Admin
|
|||
|
||||
def user_params
|
||||
params.require(:user).permit(:email, :name, :email_public, :biography, :nickname, :affiliation, :is_admin, :username, :login, :is_disabled,
|
||||
:tshirt, :mobile, :volunteer_experience, :languages, role_ids: [])
|
||||
:tshirt, :mobile, :volunteer_experience, :languages, :to_confirm, role_ids: [])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
%th #
|
||||
%th E-Mail
|
||||
%th Date registered
|
||||
%th Status
|
||||
%th Confirmed?
|
||||
- recent_users.each_with_index do |user, index|
|
||||
%tbody
|
||||
%tr
|
||||
|
|
@ -14,10 +14,12 @@
|
|||
%td= link_to user.email, admin_user_path(user.id)
|
||||
%td= user.created_at.strftime('%m/%d/%Y')
|
||||
%td
|
||||
- if user.confirmed?
|
||||
%span.label.label-success Confirmed
|
||||
-else
|
||||
%span.label.label-danger Unconfirmed
|
||||
= check_box_tag user.id, user.id, user.confirmed?,
|
||||
method: :patch,
|
||||
url: "/admin/users/#{user.id}/toggle_confirmation?user[to_confirm]=",
|
||||
class: 'switch-checkbox',
|
||||
readonly: true,
|
||||
data: { size: 'small', on_color: 'success', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
- else
|
||||
%h5.text-warning.text-center
|
||||
No sign ups!
|
||||
|
|
|
|||
|
|
@ -1,5 +1,22 @@
|
|||
= semantic_form_for [:admin, @user] do |f|
|
||||
= f.inputs 'Basic Information' do
|
||||
.pull-right
|
||||
%b
|
||||
Confirmed?
|
||||
- if can? :toggle_confirmation, @user
|
||||
= check_box_tag @user.id, @user.id, @user.confirmed?,
|
||||
method: :patch,
|
||||
url: "/admin/users/#{@user.id}/toggle_confirmation?user[to_confirm]=",
|
||||
class: 'switch-checkbox',
|
||||
readonly: false,
|
||||
data: { size: 'small', on_color: 'success', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
- else
|
||||
= check_box_tag @user.id, @user.id, @user.confirmed?,
|
||||
method: :patch,
|
||||
url: "/admin/users/#{@user.id}/toggle_confirmation?user[to_confirm]=",
|
||||
class: 'switch-checkbox',
|
||||
readonly: true,
|
||||
data: { size: 'small', on_color: 'success', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
= f.input :is_admin, hint: 'An admin can create a new conference, manage users and make other users admins.'
|
||||
= f.input :name, :as => :string
|
||||
= f.input :email
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
%table.table.table-striped.table-bordered.table-hover.datatable
|
||||
%thead
|
||||
%th ID
|
||||
%th State
|
||||
%th Confirmed?
|
||||
%th Email
|
||||
%th Name
|
||||
%th Attended Conferences
|
||||
|
|
@ -23,10 +23,20 @@
|
|||
%td
|
||||
= user.id
|
||||
%td
|
||||
- if user.confirmed?
|
||||
confirmed
|
||||
- if can? :toggle_confirmation, user
|
||||
= check_box_tag user.id, user.id, user.confirmed?,
|
||||
method: :patch,
|
||||
url: "/admin/users/#{user.id}/toggle_confirmation?user[to_confirm]=",
|
||||
class: 'switch-checkbox',
|
||||
readonly: false,
|
||||
data: { size: 'small', on_color: 'success', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
- else
|
||||
unconfirmed
|
||||
= check_box_tag user.id, user.id, user.confirmed?,
|
||||
method: :patch,
|
||||
url: "/admin/users/#{user.id}/toggle_confirmation?user[to_confirm]=",
|
||||
class: 'switch-checkbox',
|
||||
readonly: true,
|
||||
data: { size: 'small', on_color: 'success', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
%td
|
||||
= user.email
|
||||
%td
|
||||
|
|
|
|||
|
|
@ -14,12 +14,6 @@
|
|||
- if can? :edit, @user
|
||||
.pull-right
|
||||
= link_to 'Edit', edit_admin_user_path(@user), class: 'btn btn-primary'
|
||||
- if @user.confirmed?
|
||||
%span.label.label-success
|
||||
confirmed
|
||||
- else
|
||||
%span.label.label-warning
|
||||
unconfirmed
|
||||
%table.table
|
||||
- @show_attributes.each do |attr|
|
||||
%tr
|
||||
|
|
@ -32,6 +26,28 @@
|
|||
- elsif attr == 'biography'
|
||||
%td
|
||||
= markdown(@user.biography)
|
||||
- elsif attr == 'email'
|
||||
%td
|
||||
= @user.send(attr)
|
||||
%tr
|
||||
%td
|
||||
%b
|
||||
Confirmed?
|
||||
%td
|
||||
- if can? :toggle_confirmation, @user
|
||||
= check_box_tag @user.id, @user.id, @user.confirmed?,
|
||||
method: :patch,
|
||||
url: "/admin/users/#{@user.id}/toggle_confirmation?user[to_confirm]=",
|
||||
class: 'switch-checkbox',
|
||||
readonly: false,
|
||||
data: { size: 'small', on_color: 'success', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
- else
|
||||
= check_box_tag @user.id, @user.id, @user.confirmed?,
|
||||
method: :patch,
|
||||
url: "/admin/users/#{@user.id}/toggle_confirmation?user[to_confirm]=",
|
||||
class: 'switch-checkbox',
|
||||
readonly: true,
|
||||
data: { size: 'small', on_color: 'success', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
- else
|
||||
%td= @user.send(attr)
|
||||
#submissions-content.tab-pane{class: "#{'active' if params[:tab] == 'submissions-content'}"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue