thredded 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.mkdn +21 -0
  3. data/README.mkdn +17 -1
  4. data/app/assets/stylesheets/thredded/_thredded.scss +1 -0
  5. data/app/assets/stylesheets/thredded/base/_grid.scss +6 -0
  6. data/app/assets/stylesheets/thredded/base/_nav.scss +51 -0
  7. data/app/assets/stylesheets/thredded/base/_variables.scss +1 -0
  8. data/app/assets/stylesheets/thredded/components/_base.scss +4 -0
  9. data/app/assets/stylesheets/thredded/components/_post.scss +19 -6
  10. data/app/assets/stylesheets/thredded/components/_topics.scss +6 -0
  11. data/app/assets/stylesheets/thredded/layout/_moderation.scss +53 -8
  12. data/app/assets/stylesheets/thredded/layout/_navigation.scss +1 -1
  13. data/app/assets/stylesheets/thredded/layout/_user-navigation.scss +7 -47
  14. data/app/assets/stylesheets/thredded/layout/_user.scss +10 -0
  15. data/app/commands/thredded/moderate_post.rb +1 -1
  16. data/app/controllers/thredded/messageboards_controller.rb +1 -1
  17. data/app/controllers/thredded/moderation_controller.rb +39 -5
  18. data/app/helpers/thredded/application_helper.rb +4 -2
  19. data/app/models/concerns/thredded/content_moderation_state.rb +15 -8
  20. data/app/models/concerns/thredded/post_common.rb +1 -0
  21. data/app/models/concerns/thredded/topic_common.rb +0 -1
  22. data/app/models/thredded/messageboard.rb +4 -4
  23. data/app/models/thredded/post.rb +2 -0
  24. data/app/models/thredded/post_moderation_record.rb +3 -1
  25. data/app/models/thredded/topic.rb +17 -0
  26. data/app/models/thredded/user_extender.rb +7 -0
  27. data/app/policies/thredded/post_policy.rb +2 -0
  28. data/app/policies/thredded/topic_policy.rb +6 -6
  29. data/app/view_models/thredded/post_view.rb +19 -1
  30. data/app/view_models/thredded/posts_page_view.rb +1 -0
  31. data/app/view_models/thredded/topic_view.rb +5 -1
  32. data/app/views/thredded/messageboards/_messageboard.html.erb +3 -3
  33. data/app/views/thredded/moderation/_nav.html.erb +16 -0
  34. data/app/views/thredded/moderation/_post.html.erb +9 -2
  35. data/app/views/thredded/moderation/_post_moderation_record.html.erb +22 -19
  36. data/app/views/thredded/moderation/_user_moderation_state.html.erb +3 -0
  37. data/app/views/thredded/moderation/_user_post.html.erb +7 -0
  38. data/app/views/thredded/moderation/_users_search_form.html.erb +10 -0
  39. data/app/views/thredded/moderation/history.html.erb +2 -8
  40. data/app/views/thredded/moderation/pending.html.erb +3 -10
  41. data/app/views/thredded/moderation/user.html.erb +42 -0
  42. data/app/views/thredded/moderation/users.html.erb +38 -0
  43. data/app/views/thredded/posts/_post.html.erb +4 -0
  44. data/app/views/thredded/posts_common/_header.html.erb +1 -0
  45. data/app/views/thredded/posts_common/_header_with_topic.html.erb +15 -0
  46. data/app/views/thredded/posts_common/_header_with_user_and_topic.html.erb +18 -0
  47. data/app/views/thredded/search/_form.html.erb +3 -1
  48. data/app/views/thredded/shared/_content_moderation_blocked_state.html.erb +8 -0
  49. data/app/views/thredded/shared/_nav.html.erb +8 -4
  50. data/app/views/thredded/topics/_topic.html.erb +6 -0
  51. data/app/views/thredded/users/_post.html.erb +6 -0
  52. data/app/views/thredded/users/_posts.html.erb +7 -0
  53. data/config/locales/en.yml +29 -3
  54. data/config/locales/pt-BR.yml +34 -9
  55. data/config/routes.rb +7 -2
  56. data/db/migrate/20160329231848_create_thredded.rb +22 -21
  57. data/db/upgrade_migrations/20160611094616_upgrade_v0_5_to_v0_6.rb +25 -0
  58. data/heroku.gemfile.lock +2 -2
  59. data/lib/thredded.rb +17 -5
  60. data/lib/thredded/version.rb +1 -1
  61. metadata +15 -2
@@ -1,16 +1,9 @@
1
1
  <% content_for :thredded_page_title, t('thredded.nav.moderation') %>
2
2
  <% content_for :thredded_page_id, 'thredded--pending-moderation' %>
3
- <% content_for :thredded_breadcrumbs do %>
4
- <ul class="thredded--navigation-breadcrumbs">
5
- <li><%= link_to t('thredded.nav.all_messageboards'), messageboards_path %></li>
6
- <li><%= link_to t('thredded.nav.moderation'), pending_moderation_path %></li>
7
- </ul>
8
- <% end %>
3
+ <%= render 'nav' %>
9
4
 
10
5
  <%= thredded_page do %>
11
6
  <%= content_tag :section, class: 'thredded--main-section' do %>
12
- <%= link_to t('thredded.nav.moderation_history'), moderation_history_path,
13
- class: 'thredded--link thredded--moderation--history-link' %>
14
7
  <% if @last_moderated_record %>
15
8
  <div class="thredded--moderated-notice">
16
9
  <%= render 'post_moderation_record', post_moderation_record: @last_moderated_record %>
@@ -21,8 +14,8 @@
21
14
  <%= paginate @posts %>
22
15
  <% else %>
23
16
  <div class="thredded--empty">
24
- <h3 class="thredded--empty--title"><%= t 'thredded.moderation.pending_empty.title' %></h3>
25
- <p><%= t 'thredded.moderation.pending_empty.content' %></p>
17
+ <h3 class="thredded--empty--title"><%= t 'thredded.moderation.pending.empty.title' %></h3>
18
+ <p><%= t 'thredded.moderation.pending.empty.content' %></p>
26
19
  </div>
27
20
  <% end %>
28
21
  <% end %>
@@ -0,0 +1,42 @@
1
+ <%
2
+ user = @user
3
+ user_detail = user.thredded_user_detail
4
+ %>
5
+ <% content_for :thredded_page_title, t('thredded.nav.moderation') %>
6
+ <% content_for :thredded_page_id, 'thredded--moderation-user' %>
7
+ <%= render 'nav' %>
8
+ <%= thredded_page do %>
9
+ <h1 class="thredded--moderation--user--title">
10
+ <%= image_tag Thredded.avatar_url.call(user), class: 'thredded--user--avatar' %><%= user %>
11
+ </h1>
12
+ <ul class="thredded--moderation--user--info">
13
+ <li><%= t 'thredded.users.user_since_html', time_ago: time_ago(user.created_at) %></li>
14
+ <% if user_detail.last_seen_at %>
15
+ <li><%= t 'thredded.users.last_active_html', time_ago: time_ago(user_detail.last_seen_at) %></li>
16
+ <% end %>
17
+ <% if user_detail.topics_count > 0 %>
18
+ <li><%= t 'thredded.users.started_topics_count', count: user_detail.topics_count %></li>
19
+ <% end %>
20
+ <% if user_detail.posts_count > 0 %>
21
+ <li><%= t 'thredded.users.posts_count', count: user_detail.posts_count %></li>
22
+ <% end %>
23
+ <li><%= render 'user_moderation_state', user: @user %></li>
24
+ </ul>
25
+ <div class="thredded--user--moderation-actions">
26
+ <% unless user_detail.approved? %>
27
+ <%= button_to t('thredded.moderation.approve_btn'), moderate_user_path,
28
+ class: 'thredded--button',
29
+ params: { id: user.to_model.id, moderation_state: 'approved' } %>
30
+ <% end %>
31
+ <% unless user_detail.blocked? %>
32
+ <%= button_to t('thredded.moderation.block_btn'), moderate_user_path,
33
+ class: 'thredded--button',
34
+ params: { id: user.to_model.id, moderation_state: 'blocked' } %>
35
+ <% end %>
36
+ </div>
37
+ <% if @posts.present? %>
38
+ <h2><%= t 'thredded.users.recent_activity' %></h2>
39
+ <%= render partial: 'user_post', collection: @posts, as: :post %>
40
+ <%= paginate @posts %>
41
+ <% end %>
42
+ <% end %>
@@ -0,0 +1,38 @@
1
+ <% content_for :thredded_page_title, t('thredded.nav.moderation') %>
2
+ <% content_for :thredded_page_id, 'thredded--moderation-users' %>
3
+ <%= render 'nav' %>
4
+
5
+ <%= thredded_page do %>
6
+ <% if @users.present? %>
7
+ <% if @query.present? %>
8
+ <p class="thredded--alert thredded--alert-success">
9
+ <%= t 'thredded.moderation.search_users.results_message', query: "'#{@query}'" %>
10
+ </p>
11
+ <% end %>
12
+ <table class="thredded--moderation--users-table thredded--table">
13
+ <thead>
14
+ <tr>
15
+ <th>User</th>
16
+ <th>Moderation state</th>
17
+ </tr>
18
+ </thead>
19
+ <tbody>
20
+ <% @users.each do |user| %>
21
+ <tr>
22
+ <td>
23
+ <%= link_to user, user_moderation_path(user.id), class: 'thredded--link' %>
24
+ </td>
25
+ <td>
26
+ <%= render 'user_moderation_state', user: user %>
27
+ </td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+ <%= paginate @users %>
33
+ <% else %>
34
+ <p class="thredded--alert thredded--alert-danger">
35
+ <%= t 'thredded.moderation.search_users.no_results_message', query: "'#{@query}'" %>
36
+ </p>
37
+ <% end %>
38
+ <% end %>
@@ -5,6 +5,10 @@
5
5
  <%= render 'thredded/posts_common/actions', post: post %>
6
6
  <% if post.pending_moderation? && !Thredded.content_visible_while_pending_moderation %>
7
7
  <p class="thredded--alert thredded--alert-warning"><%= t 'thredded.posts.pending_moderation_notice' %></p>
8
+ <% elsif post.blocked? && post.can_moderate? %>
9
+ <p class="thredded--alert thredded--alert-danger">
10
+ <%= render 'thredded/shared/content_moderation_blocked_state', moderation_record: post.last_moderation_record %>
11
+ </p>
8
12
  <% end %>
9
13
  <% end %>
10
14
  <% end %>
@@ -1,3 +1,4 @@
1
+ <%# @param post [Thredded::PostView] %>
1
2
  <header>
2
3
  <%= image_tag post.avatar_url, class: 'thredded--post--avatar' if post.user %>
3
4
  <h2 class="thredded--post--user"><%= user_link post.user %></h2>
@@ -0,0 +1,15 @@
1
+ <%# @param post [Thredded::PostView] %>
2
+ <% topic = post.to_model.postable %>
3
+ <header>
4
+ <h2 class="thredded--post--topic">
5
+ <%=
6
+ topic_link = link_to(topic.title, post.permalink_path)
7
+ if topic.first_post == post.to_model
8
+ t 'thredded.users.started_topic_html', topic_link: topic_link
9
+ else
10
+ t 'thredded.users.posted_in_topic_html', topic_link: topic_link
11
+ end
12
+ %>
13
+ </h2>
14
+ <p class="thredded--post--created-at"><%= time_ago post.created_at %></p>
15
+ </header>
@@ -0,0 +1,18 @@
1
+ <%# @param post [Thredded::PostView] %>
2
+ <%# @param post_user_link [String] optional %>
3
+ <% topic = post.to_model.postable %>
4
+ <% post_user_link ||= user_link(post.user) %>
5
+ <header>
6
+ <%= image_tag post.avatar_url, class: 'thredded--post--avatar' if post.user %>
7
+ <h2 class="thredded--post--user-and-topic">
8
+ <%=
9
+ topic_link = link_to(topic.title, post.permalink_path)
10
+ if topic.first_post == post.to_model
11
+ t 'thredded.users.user_started_topic_html', user_link: post_user_link, topic_link: topic_link
12
+ else
13
+ t 'thredded.users.user_posted_in_topic_html', user_link: post_user_link, topic_link: topic_link
14
+ end
15
+ %>
16
+ </h2>
17
+ <p class="thredded--post--created-at"><%= time_ago post.created_at %></p>
18
+ </header>
@@ -1,4 +1,6 @@
1
- <%= form_tag search_path(messageboard), class: 'thredded--form thredded--navigation--search', method: 'get' do %>
1
+ <%= form_tag search_path(messageboard),
2
+ method: 'get',
3
+ class: 'thredded--form thredded--navigation--search thredded--navigation--search-topics' do %>
2
4
  <%= label_tag :q, t('thredded.search.form.label') %>
3
5
  <%= text_field_tag :q, @query,
4
6
  type: 'search',
@@ -0,0 +1,8 @@
1
+ <% # @param moderation_record [Thredded::PostModerationRecord, nil] %>
2
+ <% if moderation_record %>
3
+ <%= t 'thredded.content_moderation_states.content_blocked_notice_with_record_html',
4
+ moderator: user_link(moderation_record.moderator),
5
+ time_ago: time_ago(moderation_record.created_at) %>
6
+ <% else %>
7
+ <%= t 'thredded.content_moderation_states.content_blocked_notice' %>
8
+ <% end %>
@@ -14,8 +14,12 @@
14
14
  <%= render 'thredded/shared/nav/standalone' %>
15
15
  <% end %>
16
16
  </ul>
17
- <div class="thredded--main-navigation">
18
- <%= yield :thredded_breadcrumbs %>
19
- <%= render 'thredded/search/form', messageboard: messageboard_or_nil %>
20
- </div>
17
+ <% if content_for? :thredded_main_navigation %>
18
+ <%= yield :thredded_main_navigation %>
19
+ <% else %>
20
+ <div class="thredded--main-navigation">
21
+ <%= yield :thredded_breadcrumbs %>
22
+ <%= render 'thredded/search/form', messageboard: messageboard_or_nil %>
23
+ </div>
24
+ <% end %>
21
25
  </nav>
@@ -22,4 +22,10 @@
22
22
  <%= time_ago topic.created_at %>
23
23
  <%= user_link topic.user %>
24
24
  </cite>
25
+
26
+ <% if topic.blocked? && topic.can_moderate? %>
27
+ <span class="thredded--topics--moderation-state thredded--alert thredded--alert-danger">
28
+ <%= render 'thredded/shared/content_moderation_blocked_state', moderation_record: topic.last_moderation_record %>
29
+ </span>
30
+ <% end %>
25
31
  <% end %>
@@ -0,0 +1,6 @@
1
+ <%# @param post [Thredded::PostView] %>
2
+ <%= content_tag :article, id: dom_id(post), class: 'thredded--post' do %>
3
+ <%= render 'thredded/posts_common/header_with_topic', post: post %>
4
+ <%= render 'thredded/posts_common/content', post: post %>
5
+ <%= render 'thredded/posts_common/actions', post: post %>
6
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%#
2
+ This partial can be called from the parent app to render the user's posts.
3
+ The parent view context that renders this partial must include Thredded::ApplicationHelper.
4
+ TODO: Use a Cell instead. https://github.com/apotonick/cells
5
+ %>
6
+ <%# @param posts [Thredded::PostsPageView] %>
7
+ <%= render partial: 'thredded/users/post', collection: posts %>
@@ -8,6 +8,9 @@ en:
8
8
  private_topic_not_found: This private topic does not exist.
9
9
  form:
10
10
  update: Update
11
+ content_moderation_states:
12
+ content_blocked_notice: Blocked by a moderator
13
+ content_blocked_notice_with_record_html: Blocked by %{moderator} %{time_ago}
11
14
  messageboard:
12
15
  create: Create a New Messageboard
13
16
  form:
@@ -23,15 +26,21 @@ en:
23
26
  moderation:
24
27
  approve_btn: Approve
25
28
  block_btn: Block
26
- pending_empty:
27
- content: All posts have been moderated.
28
- title: Good job!
29
+ pending:
30
+ empty:
31
+ content: All posts have been moderated.
32
+ title: Good job!
29
33
  post_approved_html: Post approved by %{moderator} %{time_ago}.
30
34
  post_blocked_html: Post blocked by %{moderator} %{time_ago}.
31
35
  post_deleted_notice: This post has been deleted.
32
36
  posts_content_changed_since_moderation_html: >-
33
37
  The <a href="%{post_url}">post's</a> content change since it was moderated. Below is the content at the
34
38
  time it was moderated.
39
+ search_users:
40
+ form_label: Search users
41
+ form_placeholder: :thredded.moderation.search_users.form_label
42
+ results_message: Users with names starting with %{query}
43
+ no_results_message: No users with name starting with %{query}
35
44
  nav:
36
45
  all_messageboards: All Messageboards
37
46
  edit_messageboard: Edit Messageboard
@@ -40,6 +49,8 @@ en:
40
49
  edit_topic: Edit
41
50
  moderation: Moderation
42
51
  moderation_history: History
52
+ moderation_pending: Pending
53
+ moderation_users: Users
43
54
  private_topics: Private Messages
44
55
  settings: Notification Settings
45
56
  null_user_name: Deleted user
@@ -126,3 +137,18 @@ en:
126
137
  started_by_html: Started %{time_ago} by %{user}
127
138
  unfollowed_notice: You are no longer following this topic
128
139
  updated_notice: Topic updated
140
+ users:
141
+ last_active_html: "Last active %{time_ago}"
142
+ posted_in_topic_html: "Posted in %{topic_link}"
143
+ recent_activity: Recent activity
144
+ started_topic_html: "Started %{topic_link}"
145
+ user_posted_in_topic_html: "%{user_link} posted in %{topic_link}"
146
+ user_since_html: "User since %{time_ago}"
147
+ user_started_topic_html: "%{user_link} started %{topic_link}"
148
+ started_topics_count:
149
+ one: "Started one topic"
150
+ other: "Started %{count} topics"
151
+ posts_count:
152
+ one: "Posted once"
153
+ other: "Posted %{count} times"
154
+
@@ -1,6 +1,9 @@
1
1
  ---
2
2
  pt-BR:
3
3
  thredded:
4
+ content_moderation_states:
5
+ content_blocked_notice: Bloqueado por um moderador
6
+ content_blocked_notice_with_record_html: Bloqueados por %{moderator} %{time_ago}
4
7
  errors:
5
8
  login_required: Por favor, autentique-se primeiro.
6
9
  not_authorized: Você não está autorizado a acessar esta página.
@@ -23,15 +26,21 @@ pt-BR:
23
26
  moderation:
24
27
  approve_btn: Aprovar
25
28
  block_btn: Quadra
26
- pending_empty:
27
- content: Todas as mensagens têm sido moderadas.
28
- title: Bom trabalho!
29
+ pending:
30
+ empty:
31
+ content: Todas as mensagens têm sido moderadas.
32
+ title: Bom trabalho!
29
33
  post_approved_html: Pós aprovado por %{moderator} %{time_ago}.
30
34
  post_blocked_html: Pós bloqueado por %{moderator} %{time_ago}.
31
35
  post_deleted_notice: Este post foi apagado.
32
36
  posts_content_changed_since_moderation_html: >-
33
37
  O <a href="%{post_url}">de pós</a> alteração de conteúdo, uma vez que foi moderado. Abaixo está o conteúdo
34
38
  no momento em que foi moderado.
39
+ search_users:
40
+ form_label: Buscar usuários
41
+ form_placeholder: :thredded.moderation.search_users.form_label
42
+ no_results_message: Nenhum usuário com o nome começando com %{query}
43
+ results_message: Os usuários com nomes começando com %{query}
35
44
  nav:
36
45
  all_messageboards: Todos os Fóruns de Mensagens
37
46
  edit_messageboard: Editar Fórum de Mensagem
@@ -40,6 +49,8 @@ pt-BR:
40
49
  edit_topic: Editar
41
50
  moderation: Moderação
42
51
  moderation_history: História
52
+ moderation_pending: Pendente
53
+ moderation_users: Usuários
43
54
  private_topics: Mensagens Privadas
44
55
  settings: Configurações de Notificação
45
56
  null_user_name: Usuário deletado
@@ -107,12 +118,12 @@ pt-BR:
107
118
  delete_topic: Remover Tópico
108
119
  deleted_notice: Tópico removido
109
120
  edit: Editar Tópico
110
- followed_notice: You are now following this topic
121
+ followed_notice: Você agora está acompanhando este tópico
111
122
  following:
112
- manual: You are following this topic.
113
- mentioned: You are following this topic because you were mentioned on it.
114
- posted: You are following this topic because you posted to it.
115
- following_will_receive_emails: You will receive email updates.
123
+ manual: Você está acompanhando este tópico.
124
+ mentioned: Você está acompanhando este tópico porque você foi mencionado nele.
125
+ posted: Você está acompanhando este tópico porque foi você que o publicou.
126
+ following_will_receive_emails: Você irá receber e-mail com atualizações.
116
127
  form:
117
128
  categories_placeholder: Categorias
118
129
  content_label: :thredded.posts.form.content_label
@@ -125,5 +136,19 @@ pt-BR:
125
136
  page_title: Tópicos dos Resultados da Busca
126
137
  results_message: Resultados de Busca para %{query}
127
138
  started_by_html: Iniciado %{time_ago} por %{user}
128
- unfollowed_notice: You are no longer following this topic
139
+ unfollowed_notice: Você não está mais acompanhando este tópico
129
140
  updated_notice: Tópico atualizado
141
+ users:
142
+ last_active_html: Última %{time_ago} ativa
143
+ posted_in_topic_html: Postou em %{topic_link}
144
+ posts_count:
145
+ one: Postado uma vez
146
+ other: vezes %{count} Publicado
147
+ recent_activity: Atividade recente
148
+ started_topic_html: Começou %{topic_link}
149
+ started_topics_count:
150
+ one: Começou um tópico
151
+ other: tópicos iniciados %{count}
152
+ user_posted_in_topic_html: "%{user_link} postou em %{topic_link}"
153
+ user_since_html: Utilizador desde %{time_ago}
154
+ user_started_topic_html: "%{user_link} começou %{topic_link}"
@@ -30,9 +30,14 @@ Thredded::Engine.routes.draw do
30
30
  scope path: 'admin' do
31
31
  resources :messageboard_groups, only: [:new, :create]
32
32
  scope controller: :moderation, path: 'moderation' do
33
- get '(/page-:page)', action: :pending, as: :pending_moderation, constraints: page_constraint
33
+ scope constraints: page_constraint do
34
+ get '(/page-:page)', action: :pending, as: :pending_moderation
35
+ get '/history(/page-:page)', action: :history, as: :moderation_history
36
+ get '/users(/page-:page)', action: :users, as: :users_moderation
37
+ get '/users/:id(/page-:page)', action: :user, as: :user_moderation
38
+ end
34
39
  post '', action: :moderate_post, as: :moderate_post
35
- get '/history(/page-:page)', action: :history, as: :moderation_history, constraints: page_constraint
40
+ post '/user/:id', action: :moderate_user, as: :moderate_user
36
41
  end
37
42
  end
38
43
 
@@ -21,7 +21,7 @@ class CreateThredded < ActiveRecord::Migration
21
21
  end
22
22
 
23
23
  create_table :thredded_categories do |t|
24
- t.integer :messageboard_id, null: false
24
+ t.references :messageboard, null: false
25
25
  t.string :name, limit: 191, null: false
26
26
  t.string :description, limit: 255
27
27
  t.timestamps null: false
@@ -38,6 +38,7 @@ class CreateThredded < ActiveRecord::Migration
38
38
  t.integer :topics_count, default: 0
39
39
  t.integer :posts_count, default: 0
40
40
  t.boolean :closed, default: false, null: false
41
+ t.references :last_topic
41
42
  t.references :messageboard_group
42
43
  t.timestamps null: false
43
44
  t.index [:messageboard_group_id], name: :index_thredded_messageboards_on_messageboard_group_id
@@ -47,7 +48,7 @@ class CreateThredded < ActiveRecord::Migration
47
48
 
48
49
  create_table :thredded_post_notifications do |t|
49
50
  t.string :email, limit: 191, null: false
50
- t.integer :post_id, null: false
51
+ t.references :post, null: false
51
52
  t.timestamps null: false
52
53
  t.string :post_type, limit: 191
53
54
  t.index [:post_id, :post_type], name: :index_thredded_post_notifications_on_post
@@ -58,8 +59,8 @@ class CreateThredded < ActiveRecord::Migration
58
59
  t.text :content, limit: 65_535
59
60
  t.string :ip, limit: 255
60
61
  t.string :source, limit: 255, default: 'web'
61
- t.integer :postable_id, limit: 4
62
- t.integer :messageboard_id, null: false
62
+ t.references :postable, null: false
63
+ t.references :messageboard, null: false
63
64
  t.integer :moderation_state, null: false
64
65
  t.timestamps null: false
65
66
  t.index [:moderation_state, :updated_at],
@@ -73,16 +74,16 @@ class CreateThredded < ActiveRecord::Migration
73
74
  DbTextSearch::FullText.add_index connection, :thredded_posts, :content, name: :thredded_posts_content_fts
74
75
 
75
76
  create_table :thredded_private_posts do |t|
76
- t.integer :user_id, limit: 4
77
+ t.references :user
77
78
  t.text :content, limit: 65_535
79
+ t.references :postable, null: false
78
80
  t.string :ip, limit: 255
79
- t.integer :postable_id, null: false
80
81
  t.timestamps null: false
81
82
  end
82
83
 
83
84
  create_table :thredded_private_topics do |t|
84
- t.integer :user_id, null: false
85
- t.integer :last_user_id, null: false
85
+ t.references :user
86
+ t.references :last_user
86
87
  t.string :title, limit: 255, null: false
87
88
  t.string :slug, limit: 191, null: false
88
89
  t.integer :posts_count, default: 0
@@ -93,26 +94,26 @@ class CreateThredded < ActiveRecord::Migration
93
94
  end
94
95
 
95
96
  create_table :thredded_private_users do |t|
96
- t.integer :private_topic_id, limit: 4
97
- t.integer :user_id, limit: 4
97
+ t.references :private_topic, limit: 4
98
+ t.references :user, limit: 4
98
99
  t.timestamps null: false
99
100
  t.index [:private_topic_id], name: :index_thredded_private_users_on_private_topic_id
100
101
  t.index [:user_id], name: :index_thredded_private_users_on_user_id
101
102
  end
102
103
 
103
104
  create_table :thredded_topic_categories do |t|
104
- t.integer :topic_id, null: false
105
- t.integer :category_id, null: false
105
+ t.references :topic, null: false
106
+ t.references :category, null: false
106
107
  t.index [:category_id], name: :index_thredded_topic_categories_on_category_id
107
108
  t.index [:topic_id], name: :index_thredded_topic_categories_on_topic_id
108
109
  end
109
110
 
110
111
  create_table :thredded_topics do |t|
111
- t.integer :user_id, null: false
112
- t.integer :last_user_id, null: false
112
+ t.references :user
113
+ t.references :last_user
113
114
  t.string :title, limit: 255, null: false
114
115
  t.string :slug, limit: 191, null: false
115
- t.integer :messageboard_id, null: false
116
+ t.references :messageboard, null: false
116
117
  t.integer :posts_count, default: 0, null: false
117
118
  t.boolean :sticky, default: false, null: false
118
119
  t.boolean :locked, default: false, null: false
@@ -131,7 +132,7 @@ class CreateThredded < ActiveRecord::Migration
131
132
  DbTextSearch::FullText.add_index connection, :thredded_topics, :title, name: :thredded_topics_title_fts
132
133
 
133
134
  create_table :thredded_user_details do |t|
134
- t.integer :user_id, null: false
135
+ t.references :user, null: false
135
136
  t.datetime :latest_activity_at
136
137
  t.integer :posts_count, default: 0
137
138
  t.integer :topics_count, default: 0
@@ -157,7 +158,7 @@ class CreateThredded < ActiveRecord::Migration
157
158
  end
158
159
 
159
160
  create_table :thredded_user_preferences do |t|
160
- t.integer :user_id, null: false
161
+ t.references :user, null: false
161
162
  t.boolean :notify_on_mention, default: true, null: false
162
163
  t.boolean :notify_on_message, default: true, null: false
163
164
  t.timestamps null: false
@@ -165,8 +166,8 @@ class CreateThredded < ActiveRecord::Migration
165
166
  end
166
167
 
167
168
  create_table :thredded_user_messageboard_preferences do |t|
168
- t.integer :user_id, null: false
169
- t.integer :messageboard_id, null: false
169
+ t.references :user, null: false
170
+ t.references :messageboard, null: false
170
171
  t.boolean :notify_on_mention, default: true, null: false
171
172
  t.timestamps null: false
172
173
  t.index [:user_id, :messageboard_id],
@@ -177,7 +178,7 @@ class CreateThredded < ActiveRecord::Migration
177
178
  %i(topic private_topic).each do |topics_table|
178
179
  table_name = :"thredded_user_#{topics_table}_read_states"
179
180
  create_table table_name do |t|
180
- t.integer :user_id, null: false
181
+ t.references :user, null: false
181
182
  t.integer :postable_id, null: false
182
183
  t.integer :page, default: 1, null: false
183
184
  t.timestamp :read_at, null: false
@@ -191,7 +192,7 @@ class CreateThredded < ActiveRecord::Migration
191
192
  end
192
193
 
193
194
  create_table :thredded_user_topic_follows do |t|
194
- t.integer :user_id, null: false
195
+ t.references :user, null: false
195
196
  t.integer :topic_id, null: false
196
197
  t.datetime :created_at, null: false
197
198
  t.integer :reason, limit: 1