diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-08-19 00:58:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-19 00:58:53 +0200 |
commit | 9dd5639f90e7a256863a2b1fc199390def8bdb14 (patch) | |
tree | 1ec4bb24d5a03c1b17a9e6d16f721298f1f619c0 /app | |
parent | c6eab9e0aa06928e644cfe8445c0787e5515cd4f (diff) |
Add admin function to deactivate all invites (#8279)
Fix #8261
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin/invites_controller.rb | 6 | ||||
-rw-r--r-- | app/policies/invite_policy.rb | 4 | ||||
-rw-r--r-- | app/views/admin/invites/index.html.haml | 28 |
3 files changed, 27 insertions, 11 deletions
diff --git a/app/controllers/admin/invites_controller.rb b/app/controllers/admin/invites_controller.rb index faccaa7c8..44a8eec77 100644 --- a/app/controllers/admin/invites_controller.rb +++ b/app/controllers/admin/invites_controller.rb @@ -30,6 +30,12 @@ module Admin redirect_to admin_invites_path end + def deactivate_all + authorize :invite, :deactivate_all? + Invite.available.in_batches.update_all(expires_at: Time.now.utc) + redirect_to admin_invites_path + end + private def resource_params diff --git a/app/policies/invite_policy.rb b/app/policies/invite_policy.rb index a2a65f934..14236f78b 100644 --- a/app/policies/invite_policy.rb +++ b/app/policies/invite_policy.rb @@ -9,6 +9,10 @@ class InvitePolicy < ApplicationPolicy min_required_role? end + def deactivate_all? + admin? + end + def destroy? owner? || (Setting.min_invite_role == 'admin' ? admin? : staff?) end diff --git a/app/views/admin/invites/index.html.haml b/app/views/admin/invites/index.html.haml index 944a60471..42159e9f3 100644 --- a/app/views/admin/invites/index.html.haml +++ b/app/views/admin/invites/index.html.haml @@ -9,22 +9,28 @@ %li= filter_link_to t('admin.invites.filter.available'), available: 1, expired: nil %li= filter_link_to t('admin.invites.filter.expired'), available: nil, expired: 1 +%hr.spacer/ + - if policy(:invite).create? %p= t('invites.prompt') = render 'invites/form' - %hr/ + %hr.spacer/ -%table.table - %thead - %tr - %th - %th= t('invites.table.uses') - %th= t('invites.table.expires_at') - %th - %th - %tbody - = render @invites +.table-wrapper + %table.table + %thead + %tr + %th + %th= t('invites.table.uses') + %th= t('invites.table.expires_at') + %th + %th + %tbody + = render @invites = paginate @invites + +- if policy(:invite).deactivate_all? + = link_to t('admin.invites.deactivate_all'), deactivate_all_admin_invites_path, method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button' |