thredded 0.15.4 → 0.15.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/stylesheets/thredded/base/_alerts.scss +1 -0
  4. data/app/controllers/thredded/application_controller.rb +14 -7
  5. data/app/controllers/thredded/messageboards_controller.rb +5 -6
  6. data/app/controllers/thredded/moderation_controller.rb +28 -18
  7. data/app/controllers/thredded/topics_controller.rb +1 -1
  8. data/app/forms/thredded/post_form.rb +1 -1
  9. data/app/forms/thredded/private_post_form.rb +1 -1
  10. data/app/forms/thredded/private_topic_form.rb +2 -3
  11. data/app/forms/thredded/topic_form.rb +1 -1
  12. data/app/helpers/thredded/application_helper.rb +10 -9
  13. data/app/mailer_previews/thredded/base_mailer_preview.rb +4 -4
  14. data/app/models/concerns/thredded/content_moderation_state.rb +24 -24
  15. data/app/models/concerns/thredded/topic_common.rb +1 -1
  16. data/app/models/concerns/thredded/user_topic_read_state_common.rb +1 -1
  17. data/app/models/thredded/category.rb +1 -1
  18. data/app/models/thredded/messageboard.rb +6 -6
  19. data/app/models/thredded/messageboard_user.rb +4 -1
  20. data/app/models/thredded/post.rb +4 -2
  21. data/app/models/thredded/post_moderation_record.rb +3 -9
  22. data/app/models/thredded/private_topic.rb +6 -5
  23. data/app/models/thredded/topic.rb +6 -4
  24. data/app/models/thredded/topic_category.rb +2 -2
  25. data/app/models/thredded/user_detail.rb +12 -6
  26. data/app/models/thredded/user_extender.rb +22 -22
  27. data/app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb +7 -0
  28. data/app/models/thredded/user_permissions/moderate/none.rb +6 -0
  29. data/app/models/thredded/user_permissions/read/all.rb +7 -0
  30. data/app/models/thredded/user_preference.rb +9 -9
  31. data/app/policies/thredded/messageboard_policy.rb +8 -3
  32. data/app/views/thredded/messageboards/_form.html.erb +3 -2
  33. data/app/views/thredded/messageboards/new.html.erb +1 -1
  34. data/app/views/thredded/private_topics/_form.html.erb +1 -1
  35. data/app/views/thredded/private_topics/edit.html.erb +1 -1
  36. data/app/views/thredded/shared/_field_errors.html.erb +5 -3
  37. data/app/views/thredded/shared/nav/_moderation.html.erb +1 -1
  38. data/app/views/thredded/topics/_form.html.erb +1 -1
  39. data/app/views/thredded/topics/edit.html.erb +1 -1
  40. data/bin/rails +2 -2
  41. data/config/locales/ru.yml +1 -1
  42. data/lib/generators/thredded/install/install_generator.rb +2 -2
  43. data/lib/generators/thredded/install/templates/initializer.rb +3 -0
  44. data/lib/thredded.rb +15 -2
  45. data/lib/thredded/base_notifier.rb +1 -3
  46. data/lib/thredded/database_seeder.rb +2 -5
  47. data/lib/thredded/engine.rb +1 -3
  48. data/lib/thredded/rails_lt_5_2_arel_case_node.rb +4 -4
  49. data/lib/thredded/version.rb +1 -1
  50. metadata +86 -72
@@ -8,7 +8,10 @@ module Thredded
8
8
  class_name: 'Thredded::Messageboard',
9
9
  foreign_key: :thredded_messageboard_id,
10
10
  inverse_of: :messageboard_users
11
- belongs_to :user_detail, class_name: 'Thredded::UserDetail', foreign_key: :thredded_user_detail_id
11
+ belongs_to :user_detail,
12
+ class_name: 'Thredded::UserDetail',
13
+ foreign_key: :thredded_user_detail_id,
14
+ inverse_of: :messageboard_users
12
15
  scope :recently_active, -> { where(arel_table[:last_seen_at].gt(Thredded.active_user_threshold.ago)) }
13
16
  end
14
17
  end
@@ -10,7 +10,8 @@ module Thredded
10
10
  inverse_of: :thredded_posts,
11
11
  **(Thredded.rails_gte_51? ? { optional: true } : {})
12
12
  belongs_to :messageboard,
13
- counter_cache: true
13
+ counter_cache: true,
14
+ inverse_of: :posts
14
15
  belongs_to :postable,
15
16
  class_name: 'Thredded::Topic',
16
17
  inverse_of: :posts,
@@ -27,7 +28,8 @@ module Thredded
27
28
  has_many :user_notifications,
28
29
  class_name: 'Thredded::UserPostNotification',
29
30
  dependent: :destroy
30
- has_one :last_moderation_record, -> { order_newest_first },
31
+ has_one :last_moderation_record, # rubocop:disable Rails/InverseOf
32
+ -> { order_newest_first },
31
33
  class_name: 'Thredded::PostModerationRecord'
32
34
 
33
35
  validates :messageboard_id, presence: true
@@ -4,9 +4,7 @@ module Thredded
4
4
  class PostModerationRecord < ActiveRecord::Base
5
5
  include Thredded::ModerationState
6
6
  # Rails 4 doesn't support enum _prefix
7
- if Rails::VERSION::MAJOR >= 5
8
- enum previous_moderation_state: moderation_states, _prefix: :previous
9
- end
7
+ enum previous_moderation_state: moderation_states, _prefix: :previous if Rails::VERSION::MAJOR >= 5
10
8
  validates :previous_moderation_state, presence: true
11
9
 
12
10
  scope :order_newest_first, -> { order(created_at: :desc, id: :desc) }
@@ -26,9 +24,7 @@ module Thredded
26
24
  **(Thredded.rails_gte_51? ? { optional: true } : {})
27
25
 
28
26
  validates_each :moderation_state do |record, attr, value|
29
- if record.previous_moderation_state == value
30
- record.errors.add attr, "Post moderation_state is already #{value}"
31
- end
27
+ record.errors.add attr, "Post moderation_state is already #{value}" if record.previous_moderation_state == value
32
28
  end
33
29
 
34
30
  paginates_per Thredded.posts_per_page
@@ -40,9 +36,7 @@ module Thredded
40
36
  # @return [Thredded::PostModerationRecord] the newly created persisted record
41
37
  def self.record!(moderator:, post:, previous_moderation_state:, moderation_state:)
42
38
  # Rails 4 doesn't support enum _prefix
43
- if Rails::VERSION::MAJOR < 5
44
- previous_moderation_state = moderation_states[previous_moderation_state.to_s]
45
- end
39
+ previous_moderation_state = moderation_states[previous_moderation_state.to_s] if Rails::VERSION::MAJOR < 5
46
40
  create!(
47
41
  previous_moderation_state: previous_moderation_state,
48
42
  moderation_state: moderation_state,
@@ -27,10 +27,13 @@ module Thredded
27
27
  foreign_key: :postable_id,
28
28
  inverse_of: :postable,
29
29
  dependent: :destroy
30
- has_one :first_post, -> { order_oldest_first },
30
+ has_one :first_post, # rubocop:disable Rails/InverseOf
31
+ -> { order_oldest_first },
31
32
  class_name: 'Thredded::PrivatePost',
32
33
  foreign_key: :postable_id
33
- has_many :private_users, inverse_of: :private_topic
34
+ has_many :private_users,
35
+ inverse_of: :private_topic,
36
+ dependent: :delete_all
34
37
  has_many :users, through: :private_users
35
38
  has_many :user_read_states,
36
39
  class_name: 'Thredded::UserPrivateTopicReadState',
@@ -54,9 +57,7 @@ module Thredded
54
57
 
55
58
  validates_each :users do |model, _attr, users|
56
59
  # Must include the creator + at least one other user
57
- if users.length < 2
58
- model.errors.add(:user_ids, I18n.t('thredded.private_topics.errors.user_ids_length'))
59
- end
60
+ model.errors.add(:user_ids, I18n.t('thredded.private_topics.errors.user_ids_length')) if users.length < 2
60
61
  unless users.include?(model.user)
61
62
  # This never happens in the UI, so we don't need to i18n the message.
62
63
  model.errors.add(:user_ids, 'must include in user_ids')
@@ -58,14 +58,16 @@ module Thredded
58
58
  foreign_key: :postable_id,
59
59
  inverse_of: :postable,
60
60
  dependent: :destroy
61
- has_one :first_post, -> { order_oldest_first },
62
- class_name: 'Thredded::Post',
61
+ has_one :first_post, # rubocop:disable Rails/InverseOf
62
+ -> { order_oldest_first },
63
+ class_name: 'Thredded::Post',
63
64
  foreign_key: :postable_id
64
- has_one :last_post, -> { order_newest_first },
65
+ has_one :last_post, # rubocop:disable Rails/InverseOf
66
+ -> { order_newest_first },
65
67
  class_name: 'Thredded::Post',
66
68
  foreign_key: :postable_id
67
69
 
68
- has_many :topic_categories, dependent: :destroy
70
+ has_many :topic_categories, inverse_of: :topic, dependent: :delete_all
69
71
  has_many :categories, through: :topic_categories
70
72
  has_many :user_read_states,
71
73
  class_name: 'Thredded::UserTopicReadState',
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Thredded
4
4
  class TopicCategory < ActiveRecord::Base
5
- belongs_to :category
6
- belongs_to :topic
5
+ belongs_to :category, inverse_of: :topic_categories
6
+ belongs_to :topic, inverse_of: :topic_categories
7
7
  end
8
8
  end
@@ -7,12 +7,18 @@ module Thredded
7
7
  belongs_to :user, class_name: Thredded.user_class_name, inverse_of: :thredded_user_detail
8
8
  validates :user_id, uniqueness: true, **(Thredded.rails_gte_51? ? {} : { presence: true })
9
9
 
10
- has_many :topics, class_name: 'Thredded::Topic', foreign_key: :user_id, primary_key: :user_id
11
- has_many :private_topics, class_name: 'Thredded::PrivateTopic', foreign_key: :user_id, primary_key: :user_id
12
- has_many :posts, class_name: 'Thredded::Post', foreign_key: :user_id, primary_key: :user_id
13
- has_many :private_posts, class_name: 'Thredded::PrivatePost', foreign_key: :user_id, primary_key: :user_id
14
- has_many :messageboard_users, class_name: 'Thredded::MessageboardUser', foreign_key: :thredded_user_detail_id,
15
- inverse_of: :user_detail, dependent: :destroy
10
+ with_options foreign_key: :user_id, primary_key: :user_id, inverse_of: :user_detail, dependent: :nullify do
11
+ has_many :topics, class_name: 'Thredded::Topic'
12
+ has_many :private_topics, class_name: 'Thredded::PrivateTopic'
13
+ has_many :posts, class_name: 'Thredded::Post'
14
+ has_many :private_posts, class_name: 'Thredded::PrivatePost'
15
+ end
16
+
17
+ has_many :messageboard_users,
18
+ class_name: 'Thredded::MessageboardUser',
19
+ foreign_key: :thredded_user_detail_id,
20
+ inverse_of: :user_detail,
21
+ dependent: :delete_all
16
22
 
17
23
  scope :recently_active, -> { where(arel_table[:last_seen_at].gt(Thredded.active_user_threshold.ago)) }
18
24
 
@@ -11,29 +11,29 @@ module Thredded
11
11
  include ::Thredded::UserPermissions::Admin::IfAdminColumnTrue
12
12
 
13
13
  included do # rubocop:disable Metrics/BlockLength
14
- with_options dependent: :nullify, foreign_key: 'user_id', inverse_of: :user do |opt|
15
- opt.has_many :thredded_posts, class_name: 'Thredded::Post'
16
- opt.has_many :thredded_topics, class_name: 'Thredded::Topic'
17
- opt.has_many :thredded_private_posts, class_name: 'Thredded::PrivatePost'
18
- opt.has_many :thredded_started_private_topics, class_name: 'Thredded::PrivateTopic'
14
+ with_options dependent: :nullify, foreign_key: 'user_id', inverse_of: :user do
15
+ has_many :thredded_posts, class_name: 'Thredded::Post'
16
+ has_many :thredded_topics, class_name: 'Thredded::Topic'
17
+ has_many :thredded_private_posts, class_name: 'Thredded::PrivatePost'
18
+ has_many :thredded_started_private_topics, class_name: 'Thredded::PrivateTopic'
19
19
  end
20
20
 
21
- with_options dependent: :nullify, foreign_key: 'last_user_id', inverse_of: :last_user do |opt|
22
- opt.has_many :thredded_last_user_topics, class_name: 'Thredded::Topic'
23
- opt.has_many :thredded_last_user_private_topics, class_name: 'Thredded::PrivateTopic'
21
+ with_options dependent: :nullify, foreign_key: 'last_user_id', inverse_of: :last_user do
22
+ has_many :thredded_last_user_topics, class_name: 'Thredded::Topic'
23
+ has_many :thredded_last_user_private_topics, class_name: 'Thredded::PrivateTopic'
24
24
  end
25
25
 
26
- with_options dependent: :destroy, foreign_key: 'user_id', inverse_of: :user do |opt|
27
- opt.has_many :thredded_user_messageboard_preferences, class_name: 'Thredded::UserMessageboardPreference'
28
- opt.has_many :thredded_notifications_for_followed_topics, class_name: 'Thredded::NotificationsForFollowedTopics'
29
- opt.has_many :thredded_notifications_for_private_topics, class_name: 'Thredded::NotificationsForPrivateTopics'
30
- opt.has_many :thredded_post_notifications, class_name: 'Thredded::UserPostNotification'
31
- opt.has_many :thredded_private_users, class_name: 'Thredded::PrivateUser'
32
- opt.has_many :thredded_topic_read_states, class_name: 'Thredded::UserTopicReadState'
33
- opt.has_many :thredded_private_topic_read_states, class_name: 'Thredded::UserPrivateTopicReadState'
34
- opt.has_many :thredded_topic_follows, class_name: 'Thredded::UserTopicFollow'
35
- opt.has_one :thredded_user_detail, class_name: 'Thredded::UserDetail'
36
- opt.has_one :thredded_user_preference, class_name: 'Thredded::UserPreference'
26
+ with_options dependent: :destroy, foreign_key: 'user_id', inverse_of: :user do
27
+ has_many :thredded_user_messageboard_preferences, class_name: 'Thredded::UserMessageboardPreference'
28
+ has_many :thredded_notifications_for_followed_topics, class_name: 'Thredded::NotificationsForFollowedTopics'
29
+ has_many :thredded_notifications_for_private_topics, class_name: 'Thredded::NotificationsForPrivateTopics'
30
+ has_many :thredded_post_notifications, class_name: 'Thredded::UserPostNotification'
31
+ has_many :thredded_private_users, class_name: 'Thredded::PrivateUser'
32
+ has_many :thredded_topic_read_states, class_name: 'Thredded::UserTopicReadState'
33
+ has_many :thredded_private_topic_read_states, class_name: 'Thredded::UserPrivateTopicReadState'
34
+ has_many :thredded_topic_follows, class_name: 'Thredded::UserTopicFollow'
35
+ has_one :thredded_user_detail, class_name: 'Thredded::UserDetail'
36
+ has_one :thredded_user_preference, class_name: 'Thredded::UserPreference'
37
37
  end
38
38
 
39
39
  has_many :thredded_private_topics,
@@ -41,9 +41,9 @@ module Thredded
41
41
  class_name: 'Thredded::PrivateTopic',
42
42
  source: :private_topic
43
43
 
44
- with_options dependent: :nullify, class_name: 'Thredded::PostModerationRecord' do |opt|
45
- opt.has_many :thredded_post_moderation_records, foreign_key: 'post_user_id', inverse_of: :post_user
46
- opt.has_many :thredded_post_moderated_records, foreign_key: 'moderator_id', inverse_of: :moderator
44
+ with_options dependent: :nullify, class_name: 'Thredded::PostModerationRecord' do
45
+ has_many :thredded_post_moderation_records, foreign_key: 'post_user_id', inverse_of: :post_user
46
+ has_many :thredded_post_moderated_records, foreign_key: 'moderator_id', inverse_of: :moderator
47
47
  end
48
48
 
49
49
  scope :left_join_thredded_user_details, -> {
@@ -10,6 +10,13 @@ module Thredded
10
10
  def thredded_can_moderate_messageboards
11
11
  send(Thredded.moderator_column) ? Thredded::Messageboard.all : Thredded::Messageboard.none
12
12
  end
13
+
14
+ # @param [Thredded::Messageboard] messageboard
15
+ # @return [Boolean] Whether the user can moderate the given messageboard.
16
+ def thredded_can_moderate_messageboard?(messageboard)
17
+ scope = thredded_can_moderate_messageboards
18
+ scope == Thredded::Messageboard.all || scope.include?(messageboard)
19
+ end
13
20
  end
14
21
  end
15
22
  end
@@ -10,6 +10,12 @@ module Thredded
10
10
  def thredded_can_moderate_messageboards
11
11
  Thredded::Messageboard.none
12
12
  end
13
+
14
+ # @param [Thredded::Messageboard] messageboard
15
+ # @return [false] Whether the user can moderate the given messageboard.
16
+ def thredded_can_moderate_messageboard?(messageboard) # rubocop:disable Lint/UnusedMethodArgument
17
+ false
18
+ end
13
19
  end
14
20
  end
15
21
  end
@@ -12,6 +12,13 @@ module Thredded
12
12
  Thredded::Messageboard.all
13
13
  end
14
14
 
15
+ # @param [Thredded::Messageboard] messageboard
16
+ # @return [Boolean] Whether the user can read the given messageboard.
17
+ def thredded_can_read_messageboard?(messageboard)
18
+ scope = thredded_can_read_messageboards
19
+ scope == Thredded::Messageboard.all || scope.include?(messageboard)
20
+ end
21
+
15
22
  module ClassMethods
16
23
  # Users that can read some of the given messageboards.
17
24
  #
@@ -5,15 +5,15 @@ module Thredded
5
5
  belongs_to :user, class_name: Thredded.user_class_name, inverse_of: :thredded_user_preference
6
6
 
7
7
  with_options(inverse_of: :user_preference, primary_key: :user_id, foreign_key: :user_id,
8
- dependent: :destroy) do |opt|
9
- opt.has_many :messageboard_preferences,
10
- class_name: 'Thredded::UserMessageboardPreference'
11
- opt.has_many :messageboard_notifications_for_followed_topics,
12
- class_name: 'Thredded::MessageboardNotificationsForFollowedTopics'
13
- opt.has_many :notifications_for_followed_topics,
14
- class_name: 'Thredded::NotificationsForFollowedTopics'
15
- opt.has_many :notifications_for_private_topics,
16
- class_name: 'Thredded::NotificationsForPrivateTopics'
8
+ dependent: :destroy) do
9
+ has_many :messageboard_preferences,
10
+ class_name: 'Thredded::UserMessageboardPreference'
11
+ has_many :messageboard_notifications_for_followed_topics,
12
+ class_name: 'Thredded::MessageboardNotificationsForFollowedTopics'
13
+ has_many :notifications_for_followed_topics,
14
+ class_name: 'Thredded::NotificationsForFollowedTopics'
15
+ has_many :notifications_for_private_topics,
16
+ class_name: 'Thredded::NotificationsForPrivateTopics'
17
17
  end
18
18
  validates :user_id, presence: true
19
19
 
@@ -13,7 +13,12 @@ module Thredded
13
13
 
14
14
  # @return [ActiveRecord::Relation<Thredded::Messageboards>]
15
15
  def resolve
16
- @scope.merge(@user.thredded_can_read_messageboards)
16
+ readable = @user.thredded_can_read_messageboards
17
+ if readable == Thredded::Messageboard.all
18
+ @scope
19
+ else
20
+ @scope.merge(readable)
21
+ end
17
22
  end
18
23
  end
19
24
 
@@ -29,7 +34,7 @@ module Thredded
29
34
  end
30
35
 
31
36
  def read?
32
- @user.thredded_admin? || @user.thredded_can_read_messageboards.include?(@messageboard)
37
+ @user.thredded_admin? || @user.thredded_can_read_messageboard?(@messageboard)
33
38
  end
34
39
 
35
40
  def update?
@@ -43,7 +48,7 @@ module Thredded
43
48
  end
44
49
 
45
50
  def moderate?
46
- @user.thredded_admin? || @user.thredded_can_moderate_messageboards.include?(@messageboard)
51
+ @user.thredded_admin? || @user.thredded_can_moderate_messageboard?(@messageboard)
47
52
  end
48
53
  end
49
54
  end
@@ -3,6 +3,7 @@
3
3
  <li>
4
4
  <%= f.label t('thredded.messageboard.form.title_label') %>
5
5
  <%= f.text_field :name, required: true %>
6
+ <%= render 'thredded/shared/field_errors', messages: f.object.errors[:name] %>
6
7
  </li>
7
8
  <li>
8
9
  <%= f.label t('thredded.messageboard.form.description_label') %>
@@ -20,9 +21,9 @@
20
21
  </li>
21
22
 
22
23
  <li>
23
- <%= f.submit @messageboard.persisted? ? t('thredded.messageboard.update') : t('thredded.messageboard.create'),
24
+ <%= f.submit messageboard.persisted? ? t('thredded.messageboard.update') : t('thredded.messageboard.create'),
24
25
  class: 'thredded--form--submit',
25
- 'data-disable-with' => @messageboard.persisted? ?
26
+ 'data-disable-with' => messageboard.persisted? ?
26
27
  t('thredded.messageboard.form.update_btn_submitting') :
27
28
  t('thredded.messageboard.form.create_btn_submitting') %>
28
29
  </li>
@@ -10,6 +10,6 @@
10
10
 
11
11
  <%= thredded_page do %>
12
12
  <section class="thredded--main-section">
13
- <%= render 'form', messageboard: @messageboard %>
13
+ <%= render 'form', messageboard: @new_messageboard %>
14
14
  </section>
15
15
  <% end %>
@@ -13,7 +13,7 @@
13
13
  <li class="title">
14
14
  <%= form.label :title, t('thredded.private_topics.form.title_label') %>
15
15
  <%= form.text_field :title, placeholder: placeholder, required: true, autocomplete: 'off' %>
16
- <%= render 'thredded/shared/field_errors', messages: form.object.errors[:title] if form.object.errors.include?(:title) %>
16
+ <%= render 'thredded/shared/field_errors', messages: form.object.errors[:title] %>
17
17
  </li>
18
18
  <li>
19
19
  <%= form.label :user_names, t('thredded.private_topics.form.users_label') %>
@@ -22,7 +22,7 @@
22
22
  placeholder: t('thredded.private_topics.form.title_placeholder_new'),
23
23
  autofocus: true,
24
24
  required: true %>
25
- <%= render 'thredded/shared/field_errors', messages: form.object.errors[:title] if form.object.errors.include?(:title) %>
25
+ <%= render 'thredded/shared/field_errors', messages: form.object.errors[:title] %>
26
26
  </li>
27
27
  <li>
28
28
  <button type="submit" class="thredded--form--submit"
@@ -1,3 +1,5 @@
1
- <div class="thredded--alert thredded--alert-danger">
2
- <%= safe_join messages, raw("<br>") %>
3
- </div>
1
+ <% unless messages.blank? %>
2
+ <div class="thredded--alert thredded--alert-danger">
3
+ <%= safe_join messages, raw("<br>") %>
4
+ </div>
5
+ <% end %>
@@ -1,4 +1,4 @@
1
- <% if moderatable_messageboards_ids.present? %>
1
+ <% if thredded_moderator? %>
2
2
  <% current = current_page_moderation? %>
3
3
  <li class="thredded--user-navigation--item thredded--user-navigation--moderation<%= ' thredded--is-current' if current %>">
4
4
  <%= link_to current ? nav_back_path : pending_moderation_path, rel: 'nofollow' do %>
@@ -11,7 +11,7 @@
11
11
  <li class="title">
12
12
  <%= form.label :title, t('thredded.topics.form.title_label') %>
13
13
  <%= form.text_field :title, placeholder: placeholder, required: true, autocomplete: 'off' %>
14
- <%= render 'thredded/shared/field_errors', messages: form.object.errors[:title] if form.object.errors.include?(:title) %>
14
+ <%= render 'thredded/shared/field_errors', messages: form.object.errors[:title] %>
15
15
  </li>
16
16
 
17
17
  <% if form.object.category_options.any? %>
@@ -22,7 +22,7 @@
22
22
  placeholder: t('thredded.topics.form.title_placeholder'),
23
23
  autofocus: true,
24
24
  required: true %>
25
- <%= render 'thredded/shared/field_errors', messages: form.object.errors[:title] if form.object.errors.include?(:title) %>
25
+ <%= render 'thredded/shared/field_errors', messages: form.object.errors[:title] %>
26
26
  </li>
27
27
 
28
28
  <% if form.object.category_options.any? %>
data/bin/rails CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- APP_PATH = File.expand_path('../../spec/dummy/config/application', __FILE__)
5
- require File.expand_path('../../spec/dummy/config/boot', __FILE__)
4
+ APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
5
+ require File.expand_path('../spec/dummy/config/boot', __dir__)
6
6
  require 'rails/commands'
@@ -250,7 +250,7 @@ ru:
250
250
  users:
251
251
  currently_online: Онлайн
252
252
  last_active_html: Последняя активность %{time_ago}
253
- posted_in_topic_html: Сделан пост в %{topic_link}
253
+ posted_in_topic_html: Написал в %{topic_link}
254
254
  posts_count:
255
255
  few: Сделано %{count} поста
256
256
  many: Сделано %{count} постов
@@ -5,8 +5,8 @@ module Thredded
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
  def set_source_paths
7
7
  @source_paths = [
8
- File.expand_path('../templates', __FILE__),
9
- File.expand_path('../../../../..', __FILE__),
8
+ File.expand_path('templates', __dir__),
9
+ File.expand_path('../../../..', __dir__),
10
10
  ]
11
11
  end
12
12
 
@@ -84,6 +84,9 @@ Thredded.layout = 'thredded/application'
84
84
  # Thredded.parent_mailer = 'ActionMailer::Base'
85
85
 
86
86
  # ==> Model configuration
87
+ # The range of valid messageboard name lengths. Default:
88
+ # Thredded.messageboard_name_length_range = (1..60)
89
+ #
87
90
  # The range of valid topic title lengths. Default:
88
91
  # Thredded.topic_title_length_range = (1..200)
89
92
 
@@ -44,7 +44,16 @@ require 'thredded/base_notifier'
44
44
  require 'thredded/arel_compat'
45
45
  require 'thredded/collection_to_strings_with_cache_renderer'
46
46
 
47
- module Thredded
47
+ if Rails::VERSION::MAJOR < 5
48
+ begin
49
+ require 'where-or'
50
+ rescue LoadError
51
+ $stderr.puts "\nthredded: Please add gem 'where-or' to your Gemfile"
52
+ exit 1 # rubocop:disable Rails/Exit
53
+ end
54
+ end
55
+
56
+ module Thredded # rubocop:disable Metrics/ModuleLength
48
57
  class << self
49
58
  #== User
50
59
 
@@ -110,7 +119,7 @@ module Thredded
110
119
  # :last_post_at_desc most recent post first
111
120
  # :topics_count_desc most topics first
112
121
  # @return [:position, :last_post_at_desc, :topics_count_desc]
113
- attr_accessor :messageboards_order
122
+ attr_reader :messageboards_order
114
123
 
115
124
  # @return [Number] The number of topics to display per page.
116
125
  attr_accessor :topics_per_page
@@ -157,6 +166,9 @@ module Thredded
157
166
 
158
167
  #== Misc
159
168
 
169
+ # @return [Range<Integer>] The range of valid messageboard name lengths.
170
+ attr_accessor :messageboard_name_length_range
171
+
160
172
  # @return [Range<Integer>] The range of valid topic title lengths.
161
173
  attr_accessor :topic_title_length_range
162
174
 
@@ -267,5 +279,6 @@ module Thredded
267
279
  self.slugifier = ->(input) { input.parameterize }
268
280
  self.routes_id_constraint = /[1-9]\d*/
269
281
 
282
+ self.messageboard_name_length_range = (1..60)
270
283
  self.topic_title_length_range = (1..200)
271
284
  end