parent
c6eab9e0aa
commit
9dd5639f90
|
@ -30,6 +30,12 @@ module Admin
|
||||||
redirect_to admin_invites_path
|
redirect_to admin_invites_path
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def resource_params
|
def resource_params
|
||||||
|
|
|
@ -9,6 +9,10 @@ class InvitePolicy < ApplicationPolicy
|
||||||
min_required_role?
|
min_required_role?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deactivate_all?
|
||||||
|
admin?
|
||||||
|
end
|
||||||
|
|
||||||
def destroy?
|
def destroy?
|
||||||
owner? || (Setting.min_invite_role == 'admin' ? admin? : staff?)
|
owner? || (Setting.min_invite_role == 'admin' ? admin? : staff?)
|
||||||
end
|
end
|
||||||
|
|
|
@ -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.available'), available: 1, expired: nil
|
||||||
%li= filter_link_to t('admin.invites.filter.expired'), available: nil, expired: 1
|
%li= filter_link_to t('admin.invites.filter.expired'), available: nil, expired: 1
|
||||||
|
|
||||||
|
%hr.spacer/
|
||||||
|
|
||||||
- if policy(:invite).create?
|
- if policy(:invite).create?
|
||||||
%p= t('invites.prompt')
|
%p= t('invites.prompt')
|
||||||
|
|
||||||
= render 'invites/form'
|
= render 'invites/form'
|
||||||
|
|
||||||
%hr/
|
%hr.spacer/
|
||||||
|
|
||||||
%table.table
|
.table-wrapper
|
||||||
%thead
|
%table.table
|
||||||
%tr
|
%thead
|
||||||
%th
|
%tr
|
||||||
%th= t('invites.table.uses')
|
%th
|
||||||
%th= t('invites.table.expires_at')
|
%th= t('invites.table.uses')
|
||||||
%th
|
%th= t('invites.table.expires_at')
|
||||||
%th
|
%th
|
||||||
%tbody
|
%th
|
||||||
= render @invites
|
%tbody
|
||||||
|
= render @invites
|
||||||
|
|
||||||
= paginate @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'
|
||||||
|
|
|
@ -281,6 +281,7 @@ en:
|
||||||
search: Search
|
search: Search
|
||||||
title: Known instances
|
title: Known instances
|
||||||
invites:
|
invites:
|
||||||
|
deactivate_all: Deactivate all
|
||||||
filter:
|
filter:
|
||||||
all: All
|
all: All
|
||||||
available: Available
|
available: Available
|
||||||
|
|
|
@ -134,7 +134,12 @@ Rails.application.routes.draw do
|
||||||
resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
|
resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
|
||||||
resources :action_logs, only: [:index]
|
resources :action_logs, only: [:index]
|
||||||
resource :settings, only: [:edit, :update]
|
resource :settings, only: [:edit, :update]
|
||||||
resources :invites, only: [:index, :create, :destroy]
|
|
||||||
|
resources :invites, only: [:index, :create, :destroy] do
|
||||||
|
collection do
|
||||||
|
post :deactivate_all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
resources :relays, only: [:index, :new, :create, :destroy] do
|
resources :relays, only: [:index, :new, :create, :destroy] do
|
||||||
member do
|
member do
|
||||||
|
|
Loading…
Reference in a new issue