thredded 0.16.12 → 0.16.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd9dbf548a2ae13d2c77b2a49e4022af13b17e5df084dc22baf370e37d7b1a2f
4
- data.tar.gz: 6f21adfcf7f040ab397637f03f47df3c4f9f15d3956dfd4fb3a2a09b9a871ddd
3
+ metadata.gz: 34e83f36d097c95e1f03964b88a49e915ec18e82981667803a68668033adda9d
4
+ data.tar.gz: 19e36508e79ecf4a9dfa196e022a4c31b96607828843704ad236d55311067d03
5
5
  SHA512:
6
- metadata.gz: 80692ab8668d1fdbcc60309774f2dcab3e8a6893b1a78892e9507ad4a9f70d9d91d174ce9277058622faba6d562c3187f4cf6dfa2aec92c97a9863a32b858b4f
7
- data.tar.gz: dd5c3253a6df6f69512eb5acd778beb0ef7370be4b53b30fb03c865b6669af3e7e5217cc46e5feaf4695c1354cd9b748743b05f66edc94eff5c55a8ef810b886
6
+ metadata.gz: 2859851223d3889f78331303bdeb8eeb78b3eea60316b2dc40249a8e940fd9a79fa34219f264ebc4afe5b8bc947ab40fda25902cfb71e877f06a510bddda6e88
7
+ data.tar.gz: a67c187aa11cf3f4a900a2a7aa86da6245b73c221f367790dc111793fbafe531b56f082d105d9e03f07bae4f5818a99da00b69c6aa79889e4526602ee8dc9073
data/README.md CHANGED
@@ -95,7 +95,7 @@ Then, see the rest of this Readme for more information about using and customizi
95
95
  Add the gem to your Gemfile:
96
96
 
97
97
  ```ruby
98
- gem 'thredded', '~> 0.16.12'
98
+ gem 'thredded', '~> 0.16.13'
99
99
  ```
100
100
 
101
101
  Add the Thredded [initializer] to your parent app by running the install generator.
@@ -94,6 +94,10 @@
94
94
  margin-bottom: 0;
95
95
  }
96
96
 
97
+ .thredded--messageboard--delete {
98
+ background-color: $thredded-alert-danger-color;
99
+ }
100
+
97
101
  .thredded--messageboards--actions {
98
102
  @extend %thredded--buttons-list;
99
103
  @media print {
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Thredded
4
4
  class MessageboardsController < Thredded::ApplicationController
5
- before_action :thredded_require_login!, only: %i[new create edit update]
5
+ before_action :thredded_require_login!, only: %i[new create edit update destroy]
6
6
 
7
7
  after_action :verify_authorized, except: %i[index]
8
- after_action :verify_policy_scoped, except: %i[new create edit update]
8
+ after_action :verify_policy_scoped, except: %i[new create edit update destroy]
9
9
 
10
10
  def index
11
11
  @groups = Thredded::MessageboardGroupView.grouped(
@@ -44,6 +44,13 @@ module Thredded
44
44
  end
45
45
  end
46
46
 
47
+ def destroy
48
+ @messageboard = Thredded::Messageboard.friendly_find!(params[:id])
49
+ authorize @messageboard, :destroy?
50
+ @messageboard.destroy!
51
+ redirect_to root_path, notice: t('thredded.messageboard.deleted_notice')
52
+ end
53
+
47
54
  private
48
55
 
49
56
  def messageboard_params
@@ -62,12 +62,7 @@ module Thredded
62
62
 
63
63
  unread_scope = reads_class.where(reads[:id].eq(nil).or(reads[:unread_posts_count].not_eq(0)))
64
64
 
65
- # Work around https://github.com/rails/rails/issues/36761
66
- if Thredded.rails_gte_600_rc_2?
67
- merge(unread_scope).joins(joins_reads)
68
- else
69
- joins(joins_reads).merge(unread_scope)
70
- end
65
+ joins(joins_reads).merge(unread_scope)
71
66
  end
72
67
 
73
68
  private
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thredded
4
- class Messageboard < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
4
+ class Messageboard < ActiveRecord::Base
5
5
  extend FriendlyId
6
6
  friendly_id :slug_candidates,
7
7
  use: %i[slugged reserved],
@@ -138,21 +138,9 @@ module Thredded
138
138
  .and(read_states[:user_id].eq(user.id))
139
139
  .and(read_states[:unread_posts_count].eq(0))
140
140
 
141
- scope =
142
- # Work around https://github.com/rails/rails/issues/36761
143
- if Thredded.rails_gte_600_rc_2?
144
- merge(topics_scope).joins(
145
- messageboards.join(topics)
146
- .on(topics[:messageboard_id].eq(messageboards[:id]))
147
- .outer_join(read_states).on(read_states_join_cond).join_sources
148
- )
149
- else
150
- joins(:topics).merge(topics_scope).joins(
151
- messageboards.outer_join(read_states).on(read_states_join_cond).join_sources
152
- )
153
- end
154
-
155
- scope.group(messageboards[:id]).pluck(
141
+ joins(:topics).merge(topics_scope).joins(
142
+ messageboards.outer_join(read_states).on(read_states_join_cond).join_sources
143
+ ).group(messageboards[:id]).pluck(
156
144
  :id,
157
145
  Arel::Nodes::Subtraction.new(topics[:id].count, read_states[:id].count)
158
146
  ).to_h
@@ -41,6 +41,10 @@ module Thredded
41
41
  @user.thredded_admin?
42
42
  end
43
43
 
44
+ def destroy?
45
+ @user.thredded_admin?
46
+ end
47
+
44
48
  def post?
45
49
  @user.thredded_admin? ||
46
50
  (!@messageboard.locked? || moderate?) &&
@@ -29,3 +29,11 @@
29
29
  </li>
30
30
  </ul>
31
31
  <% end %>
32
+ <% if messageboard.persisted? and Thredded.show_messageboard_delete_button %>
33
+ <%= button_to t('thredded.messageboard.form.delete'),
34
+ messageboard_path(messageboard),
35
+ method: 'delete',
36
+ class: 'thredded--messageboard--delete',
37
+ form_class: 'thredded--form',
38
+ data: {confirm: t('thredded.messageboard.form.delete_confirm', messageboard_name: messageboard.name)}%>
39
+ <% end %>
@@ -56,8 +56,13 @@ de:
56
56
  update_btn_submitting: Änderungen übernehmen...
57
57
  messageboard:
58
58
  create: Erstelle ein neues Forum
59
+ deleted_notice: Messageboard gelöscht
59
60
  form:
60
61
  create_btn_submitting: :thredded.form.create_btn_submitting
62
+ delete: Messageboard löschen
63
+ delete_confirm: >-
64
+ Dadurch werden das Messageboard %{messageboard_name} und alle zugehörigen Posts entfernt. Sie können es
65
+ nicht wiederherstellen. Möchten Sie das wirklich tun?
61
66
  description_label: Beschreibung
62
67
  locked_label: Geschlossen
63
68
  locked_notice: Dieses Forum ist geschlossen. Nur Moderatoren können hier neue Beiträge erstellen.
@@ -55,8 +55,13 @@ en:
55
55
  update_btn_submitting: Updating...
56
56
  messageboard:
57
57
  create: Create a New Messageboard
58
+ deleted_notice: Messageboard deleted
58
59
  form:
59
60
  create_btn_submitting: :thredded.form.create_btn_submitting
61
+ delete: Delete Messageboard
62
+ delete_confirm: >-
63
+ This will remove the messageboard %{messageboard_name} and all of its posts. You will not be able to recover
64
+ it. Are you sure you want to do this?
60
65
  description_label: Description
61
66
  locked_label: Locked
62
67
  locked_notice: This messageboard is locked. Only moderators can create new topics here.
@@ -57,8 +57,13 @@ es:
57
57
  update_btn_submitting: Actualizando...
58
58
  messageboard:
59
59
  create: Crear un nuevo foro
60
+ deleted_notice: Tablero de mensajes eliminado
60
61
  form:
61
62
  create_btn_submitting: :thredded.form.create_btn_submitting
63
+ delete: Eliminar tablero de mensajes
64
+ delete_confirm: >-
65
+ Esto eliminará el tablero de mensajes %{messageboard_name} y todas sus publicaciones. No podrás recuperarlo.
66
+ ¿Seguro que quieres hacer esto?
62
67
  description_label: Descripción
63
68
  locked_label: Bloqueado
64
69
  locked_notice: Este mensaje está bloqueado. Solo los moderadores pueden crear nuevos temas aquí.
@@ -55,8 +55,13 @@ fr:
55
55
  update_btn_submitting: Mise à jour en cours...
56
56
  messageboard:
57
57
  create: Créer une nouvelle catégorie
58
+ deleted_notice: Messageboard supprimé
58
59
  form:
59
60
  create_btn_submitting: :thredded.form.create_btn_submitting
61
+ delete: Supprimer le babillard
62
+ delete_confirm: >-
63
+ Cela supprimera le panneau de messages %{messageboard_name} et tous ses messages. Vous ne pourrez pas
64
+ le récupérer. Es-tu sûr de vouloir faire ça?
60
65
  description_label: Description
61
66
  locked_label: Verrouillé
62
67
  locked_notice: Ce message est verrouillé. Seuls les modérateurs peuvent créer de nouveaux sujets ici.
@@ -55,8 +55,13 @@ it:
55
55
  update_btn_submitting: Aggiornamento in corso...
56
56
  messageboard:
57
57
  create: Crea una nuova bacheca
58
+ deleted_notice: Messageboard cancellato
58
59
  form:
59
60
  create_btn_submitting: :thredded.form.create_btn_submitting
61
+ delete: Elimina bacheca
62
+ delete_confirm: >-
63
+ Ciò rimuoverà la bacheca %{messageboard_name} e tutti i suoi post. Non sarai in grado di recuperarlo.
64
+ Sei sicuro di volerlo fare?
60
65
  description_label: Descrizione
61
66
  locked_label: Bloccato
62
67
  locked_notice: Questa bacheca è bloccata. Solo i moderatori possono creare nuove discussioni qui.
@@ -55,8 +55,13 @@ pl:
55
55
  update_btn_submitting: Aktualizowanie...
56
56
  messageboard:
57
57
  create: Stwórz nową tablicę
58
+ deleted_notice: Tablica ogłoszeń została usunięta
58
59
  form:
59
60
  create_btn_submitting: :thredded.form.create_btn_submitting
61
+ delete: Usuń tablicę wiadomości
62
+ delete_confirm: >-
63
+ Spowoduje to usunięcie tablicy %{messageboard_name} i wszystkich jej postów. Nie będziesz w stanie go
64
+ odzyskać. Czy na pewno chcesz to zrobić?
60
65
  description_label: Opis
61
66
  locked_label: Zablokowany
62
67
  locked_notice: Ta wiadomość jest zablokowana. Tylko moderatorzy mogą tworzyć nowe tematy tutaj.
@@ -56,8 +56,13 @@ pt-BR:
56
56
  update_btn_submitting: Atualizando...
57
57
  messageboard:
58
58
  create: Criar um novo Fórum de Mensagem
59
+ deleted_notice: Messageboard excluído
59
60
  form:
60
61
  create_btn_submitting: :thredded.form.create_btn_submitting
62
+ delete: Excluir Messageboard
63
+ delete_confirm: >-
64
+ Isto irá remover o messageboard %{messageboard_name} e todos os seus posts. Você não poderá recuperá-lo.
65
+ Você tem certeza de que quer fazer isso?
61
66
  description_label: Descrição
62
67
  locked_label: Bloqueado
63
68
  locked_notice: Este quadro de mensagens está bloqueado. Somente os moderadores podem criar novos tópicos
@@ -54,8 +54,13 @@ ru:
54
54
  update_btn_submitting: Обновляю...
55
55
  messageboard:
56
56
  create: Создать форум
57
+ deleted_notice: Доска объявлений удалена
57
58
  form:
58
59
  create_btn_submitting: :thredded.form.create_btn_submitting
60
+ delete: Удалить доску объявлений
61
+ delete_confirm: >-
62
+ Это удалит доску сообщений %{messageboard_name} и все ее сообщения. Вы не сможете его восстановить. Вы
63
+ уверены, что хотите это сделать?
59
64
  description_label: Описание
60
65
  locked_label: Заблокировать
61
66
  locked_notice: Этот форум заблокирован. Только модераторы могут создавать новые темы здесь.
@@ -52,8 +52,11 @@ zh-CN:
52
52
  update_btn_submitting: 更新中...
53
53
  messageboard:
54
54
  create: 创建一个新板块
55
+ deleted_notice: 留言板已删除
55
56
  form:
56
57
  create_btn_submitting: :thredded.form.create_btn_submitting
58
+ delete: 删除留言板
59
+ delete_confirm: 这将删除留言板%{messageboard_name}及其所有帖子。你将无法恢复它。你确定你要这么做吗?
57
60
  description_label: 描述
58
61
  locked_label: 锁定
59
62
  locked_notice: 这个消息板被锁定。只有版主可以在这里创建新的主题。
data/config/routes.rb CHANGED
@@ -59,7 +59,7 @@ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
59
59
 
60
60
  resource :preferences, only: %i[edit update], as: :global_preferences
61
61
  resource :messageboard, path: 'messageboards', only: [:new]
62
- resources :messageboards, only: %i[edit update]
62
+ resources :messageboards, only: %i[edit update destroy]
63
63
  resources :messageboards, only: %i[index create], path: '' do
64
64
  resource :preferences, only: %i[edit update]
65
65
  resource :topic, path: 'topics', only: [:new] do
@@ -225,9 +225,9 @@ class CreateThredded < Thredded::BaseMigration
225
225
  t.references :post, index: false
226
226
  t.references :messageboard, index: false
227
227
  t.text :post_content, limit: 65_535
228
- t.references :post_user, index: false
228
+ t.references :post_user, index: false, type: user_id_type
229
229
  t.text :post_user_name
230
- t.references :moderator, index: false
230
+ t.references :moderator, index: false, type: user_id_type
231
231
  t.integer :moderation_state, null: false
232
232
  t.integer :previous_moderation_state, null: false
233
233
  t.timestamp :created_at, null: false
@@ -55,6 +55,9 @@ Thredded.content_visible_while_pending_moderation = true
55
55
  # :topics_count_desc most topics first
56
56
  Thredded.messageboards_order = :position
57
57
 
58
+ # Whether admin users see button to delete entire messageboards on the messageboard edit page.
59
+ Thredded.show_messageboard_delete_button = false
60
+
58
61
  # Whether users that are following a topic are listed on the topic page.
59
62
  Thredded.show_topic_followers = false
60
63
 
data/lib/thredded.rb CHANGED
@@ -88,6 +88,9 @@ module Thredded # rubocop:disable Metrics/ModuleLength
88
88
  # @return [Symbol] The name of the moderator flag column on the users table for the default permissions model
89
89
  attr_accessor :moderator_column
90
90
 
91
+ # @return [Boolean] Whether admin users see button to delete entire messageboards on the messageboard edit page.
92
+ attr_accessor :show_messageboard_delete_button
93
+
91
94
  #== UI
92
95
 
93
96
  # @return [String] The layout to use for rendering Thredded views.
@@ -251,13 +254,6 @@ module Thredded # rubocop:disable Metrics/ModuleLength
251
254
  @rails_gte_51
252
255
  end
253
256
 
254
- # @api private
255
- # Mainly to work around https://github.com/rails/rails/issues/36761
256
- def rails_gte_600_rc_2?
257
- @rails_gte_600_rc_2 = (Rails.gem_version >= Gem::Version.new('6.0.0.rc2')) if @rails_gte_600_rc_2.nil?
258
- @rails_gte_600_rc_2
259
- end
260
-
261
257
  # @api private
262
258
  def rails_supports_csp_nonce?
263
259
  @rails_supports_csp_nonce = (Rails.gem_version >= Gem::Version.new('5.2.0')) if @rails_supports_csp_nonce.nil?
@@ -271,6 +267,7 @@ module Thredded # rubocop:disable Metrics/ModuleLength
271
267
 
272
268
  self.content_visible_while_pending_moderation = true
273
269
  self.moderator_column = :admin
270
+ self.show_messageboard_delete_button = false
274
271
 
275
272
  self.layout = 'thredded/application'
276
273
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thredded
4
- VERSION = '0.16.12'
4
+ VERSION = '0.16.13'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thredded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.12
4
+ version: 0.16.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Oliveira
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-26 00:00:00.000000000 Z
12
+ date: 2019-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_record_union
@@ -130,7 +130,7 @@ dependencies:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: 4.2.10
133
- - - "<="
133
+ - - "!="
134
134
  - !ruby/object:Gem::Version
135
135
  version: 6.0.0.rc2
136
136
  type: :runtime
@@ -140,7 +140,7 @@ dependencies:
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
142
  version: 4.2.10
143
- - - "<="
143
+ - - "!="
144
144
  - !ruby/object:Gem::Version
145
145
  version: 6.0.0.rc2
146
146
  - !ruby/object:Gem::Dependency