Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
This commit is contained in:
commit
933eafdcd3
|
@ -5,7 +5,7 @@ module Admin
|
||||||
def index
|
def index
|
||||||
authorize :invite, :index?
|
authorize :invite, :index?
|
||||||
|
|
||||||
@invites = Invite.includes(user: :account).page(params[:page])
|
@invites = filtered_invites.includes(user: :account).page(params[:page])
|
||||||
@invite = Invite.new
|
@invite = Invite.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,5 +29,19 @@ module Admin
|
||||||
@invite.expire!
|
@invite.expire!
|
||||||
redirect_to admin_invites_path
|
redirect_to admin_invites_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def resource_params
|
||||||
|
params.require(:invite).permit(:max_uses, :expires_in)
|
||||||
|
end
|
||||||
|
|
||||||
|
def filtered_invites
|
||||||
|
InviteFilter.new(filter_params).results
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter_params
|
||||||
|
params.permit(:available, :expired)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
module Admin::FilterHelper
|
module Admin::FilterHelper
|
||||||
ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended recent username display_name email ip).freeze
|
ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended recent username display_name email ip).freeze
|
||||||
REPORT_FILTERS = %i(resolved account_id target_account_id).freeze
|
REPORT_FILTERS = %i(resolved account_id target_account_id).freeze
|
||||||
|
INVITE_FILTER = %i(available expired).freeze
|
||||||
|
|
||||||
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS
|
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER
|
||||||
|
|
||||||
def filter_link_to(text, link_to_params, link_class_params = link_to_params)
|
def filter_link_to(text, link_to_params, link_class_params = link_to_params)
|
||||||
new_url = filtered_url_for(link_to_params)
|
new_url = filtered_url_for(link_to_params)
|
||||||
|
|
|
@ -102,23 +102,23 @@
|
||||||
"home.column_settings.show_reblogs": "ブースト表示",
|
"home.column_settings.show_reblogs": "ブースト表示",
|
||||||
"home.column_settings.show_replies": "返信表示",
|
"home.column_settings.show_replies": "返信表示",
|
||||||
"home.settings": "カラム設定",
|
"home.settings": "カラム設定",
|
||||||
"keyboard_shortcuts.back": "to navigate back",
|
"keyboard_shortcuts.back": "戻る",
|
||||||
"keyboard_shortcuts.boost": "to boost",
|
"keyboard_shortcuts.boost": "ブースト",
|
||||||
"keyboard_shortcuts.column": "to focus a status in one of the columns",
|
"keyboard_shortcuts.column": "左からn番目のカラム内最新トゥートに移動",
|
||||||
"keyboard_shortcuts.compose": "to focus the compose textarea",
|
"keyboard_shortcuts.compose": "トゥート入力欄に移動",
|
||||||
"keyboard_shortcuts.description": "Description",
|
"keyboard_shortcuts.description": "説明",
|
||||||
"keyboard_shortcuts.down": "to move down in the list",
|
"keyboard_shortcuts.down": "カラム内一つ下に移動",
|
||||||
"keyboard_shortcuts.enter": "to open status",
|
"keyboard_shortcuts.enter": "トゥートの詳細を表示",
|
||||||
"keyboard_shortcuts.favourite": "to favourite",
|
"keyboard_shortcuts.favourite": "お気に入り",
|
||||||
"keyboard_shortcuts.heading": "Keyboard Shortcuts",
|
"keyboard_shortcuts.heading": "キーボードショートカット一覧",
|
||||||
"keyboard_shortcuts.hotkey": "Hotkey",
|
"keyboard_shortcuts.hotkey": "ホットキー",
|
||||||
"keyboard_shortcuts.legend": "to display this legend",
|
"keyboard_shortcuts.legend": "この一覧を表示",
|
||||||
"keyboard_shortcuts.mention": "to mention author",
|
"keyboard_shortcuts.mention": "メンション",
|
||||||
"keyboard_shortcuts.reply": "to reply",
|
"keyboard_shortcuts.reply": "返信",
|
||||||
"keyboard_shortcuts.search": "to focus search",
|
"keyboard_shortcuts.search": "検索欄に移動",
|
||||||
"keyboard_shortcuts.toot": "to start a brand new toot",
|
"keyboard_shortcuts.toot": "新規トゥート",
|
||||||
"keyboard_shortcuts.unfocus": "to un-focus compose textarea/search",
|
"keyboard_shortcuts.unfocus": "トゥート入力欄・検索欄から離れる",
|
||||||
"keyboard_shortcuts.up": "to move up in the list",
|
"keyboard_shortcuts.up": "カラム内一つ上に移動",
|
||||||
"lightbox.close": "閉じる",
|
"lightbox.close": "閉じる",
|
||||||
"lightbox.next": "次",
|
"lightbox.next": "次",
|
||||||
"lightbox.previous": "前",
|
"lightbox.previous": "前",
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
@import 'variables';
|
|
||||||
|
|
||||||
.app-body {
|
.app-body {
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
-ms-overflow-style: -ms-autohiding-scrollbar;
|
-ms-overflow-style: -ms-autohiding-scrollbar;
|
||||||
|
|
|
@ -17,6 +17,9 @@ class Invite < ApplicationRecord
|
||||||
belongs_to :user, required: true
|
belongs_to :user, required: true
|
||||||
has_many :users, inverse_of: :invite
|
has_many :users, inverse_of: :invite
|
||||||
|
|
||||||
|
scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) }
|
||||||
|
scope :expired, -> { where.not(expires_at: nil).where('expires_at < ?', Time.now.utc) }
|
||||||
|
|
||||||
before_validation :set_code
|
before_validation :set_code
|
||||||
|
|
||||||
attr_reader :expires_in
|
attr_reader :expires_in
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class InviteFilter
|
||||||
|
attr_reader :params
|
||||||
|
|
||||||
|
def initialize(params)
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def results
|
||||||
|
scope = Invite.order(created_at: :desc)
|
||||||
|
|
||||||
|
params.each do |key, value|
|
||||||
|
scope.merge!(scope_for(key, value)) if value.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
scope
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def scope_for(key, _value)
|
||||||
|
case key.to_s
|
||||||
|
when 'available'
|
||||||
|
Invite.available
|
||||||
|
when 'expired'
|
||||||
|
Invite.expired
|
||||||
|
else
|
||||||
|
raise "Unknown filter: #{key}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@ class InvitePolicy < ApplicationPolicy
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy?
|
def destroy?
|
||||||
owner? || staff?
|
owner? || (Setting.min_invite_role == 'admin' ? admin? : staff?)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
%time.formatted{ datetime: invite.expires_at.iso8601, title: l(invite.expires_at) }
|
%time.formatted{ datetime: invite.expires_at.iso8601, title: l(invite.expires_at) }
|
||||||
= l invite.expires_at
|
= l invite.expires_at
|
||||||
%td= table_link_to 'link', public_invite_url(invite_code: invite.code), public_invite_url(invite_code: invite.code)
|
%td= table_link_to 'link', public_invite_url(invite_code: invite.code), public_invite_url(invite_code: invite.code)
|
||||||
%td= table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete if policy(invite).destroy?
|
%td
|
||||||
|
- if !invite.expired? && policy(invite).destroy?
|
||||||
|
= table_link_to 'times', t('invites.delete'), admin_invite_path(invite), method: :delete
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('admin.invites.title')
|
= t('admin.invites.title')
|
||||||
|
|
||||||
|
.filters
|
||||||
|
.filter-subset
|
||||||
|
%strong= t('admin.invites.filter.title')
|
||||||
|
%ul
|
||||||
|
%li= filter_link_to t('admin.invites.filter.all'), available: nil, 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
|
||||||
|
|
||||||
- if policy(:invite).create?
|
- if policy(:invite).create?
|
||||||
%p= t('invites.prompt')
|
%p= t('invites.prompt')
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
= simple_form_for(@invite) do |f|
|
= simple_form_for(@invite, url: controller.is_a?(Admin::InvitesController) ? admin_invites_path : invites_path) do |f|
|
||||||
= render 'shared/error_messages', object: @invite
|
= render 'shared/error_messages', object: @invite
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
|
|
|
@ -12,4 +12,6 @@
|
||||||
%time.formatted{ datetime: invite.expires_at.iso8601, title: l(invite.expires_at) }
|
%time.formatted{ datetime: invite.expires_at.iso8601, title: l(invite.expires_at) }
|
||||||
= l invite.expires_at
|
= l invite.expires_at
|
||||||
%td= table_link_to 'link', public_invite_url(invite_code: invite.code), public_invite_url(invite_code: invite.code)
|
%td= table_link_to 'link', public_invite_url(invite_code: invite.code), public_invite_url(invite_code: invite.code)
|
||||||
%td= table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete if policy(invite).destroy?
|
%td
|
||||||
|
- if invite.expired? && policy(invite).destroy?
|
||||||
|
= table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete
|
||||||
|
|
|
@ -232,6 +232,11 @@ en:
|
||||||
search: Search
|
search: Search
|
||||||
title: Known instances
|
title: Known instances
|
||||||
invites:
|
invites:
|
||||||
|
filter:
|
||||||
|
all: All
|
||||||
|
available: Available
|
||||||
|
expired: Expired
|
||||||
|
title: Filter
|
||||||
title: Invites
|
title: Invites
|
||||||
reports:
|
reports:
|
||||||
action_taken_by: Action taken by
|
action_taken_by: Action taken by
|
||||||
|
|
|
@ -232,6 +232,11 @@ ja:
|
||||||
search: 検索
|
search: 検索
|
||||||
title: 既知のインスタンス
|
title: 既知のインスタンス
|
||||||
invites:
|
invites:
|
||||||
|
filter:
|
||||||
|
all: すべて
|
||||||
|
available: 使用可能
|
||||||
|
expired: 期限切れ
|
||||||
|
title: フィルター
|
||||||
title: 招待
|
title: 招待
|
||||||
reports:
|
reports:
|
||||||
action_taken_by: レポート処理者
|
action_taken_by: レポート処理者
|
||||||
|
|
|
@ -232,6 +232,13 @@ pl:
|
||||||
reset: Przywróć
|
reset: Przywróć
|
||||||
search: Szukaj
|
search: Szukaj
|
||||||
title: Znane instancje
|
title: Znane instancje
|
||||||
|
invites:
|
||||||
|
filter:
|
||||||
|
all: Wszystkie
|
||||||
|
available: Dostępne
|
||||||
|
expired: Wygasłe
|
||||||
|
title: Filtruj
|
||||||
|
title: Zaproszenia
|
||||||
reports:
|
reports:
|
||||||
action_taken_by: Działanie podjęte przez
|
action_taken_by: Działanie podjęte przez
|
||||||
are_you_sure: Czy na pewno?
|
are_you_sure: Czy na pewno?
|
||||||
|
|
Loading…
Reference in New Issue