Skip to content

Commit 3d30377

Browse files
authored
DEV: Scope topic voting tables to avoid confusion with post voting (#196)
Renaming discourse_voting to topic_voting since there are two forms of voting in Discourse - posts and topics. This PR also moves a OnceOff into a post migration. The post migration will be executed, but should ideally be a no-op. This allows us to not have to maintain the OnceOff as it had to be modified before with a previous migration. I considered removing this file altogether, but I don't think there is anything negative from just converting it into a migration, and it might be useful in the unlikely scenario that a forum from the past has never ran the OnceOff before.
1 parent fdb1f98 commit 3d30377

File tree

76 files changed

+608
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+608
-519
lines changed

.discourse-compatibility

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
< 3.3.0.beta5-dev: fdb1f98a963adac049ffe9cd4fc506d77dd38cca
12
< 3.3.0.beta1-dev: ba41633e0abe0535fd358a0809e0b4e0c79be128
23
< 3.2.0.beta2-dev: ca2449f243ba3de5182fead8c66c2346cd25ed2c
34
3.1.999: 6449fc15658d972e20086a3f1fae3dbac9cd9eeb

app/controllers/discourse_topic_voting/votes_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def unvote
8686
protected
8787

8888
def who_voted(topic)
89-
return nil unless SiteSetting.voting_show_who_voted
89+
return nil unless SiteSetting.topic_voting_show_who_voted
9090

9191
ActiveModel::ArraySerializer.new(
9292
topic.who_voted,

app/jobs/onceoff/voting_ensure_consistency.rb

-94
This file was deleted.

app/models/discourse_topic_voting/category_setting.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module DiscourseTopicVoting
44
class CategorySetting < ActiveRecord::Base
5-
self.table_name = "discourse_voting_category_settings"
5+
self.table_name = "topic_voting_category_settings"
66

77
belongs_to :category, inverse_of: :discourse_topic_voting_category_setting
88

@@ -12,24 +12,24 @@ class CategorySetting < ActiveRecord::Base
1212

1313
def unarchive_votes
1414
DB.exec(<<~SQL, { category_id: self.category_id })
15-
UPDATE discourse_voting_votes
15+
UPDATE topic_voting_votes
1616
SET archive=false
1717
FROM topics
1818
WHERE topics.category_id = :category_id
1919
AND topics.deleted_at is NULL
2020
AND NOT topics.closed
2121
AND NOT topics.archived
22-
AND discourse_voting_votes.topic_id = topics.id
22+
AND topic_voting_votes.topic_id = topics.id
2323
SQL
2424
end
2525

2626
def archive_votes
2727
DB.exec(<<~SQL, { category_id: self.category_id })
28-
UPDATE discourse_voting_votes
28+
UPDATE topic_voting_votes
2929
SET archive=true
3030
FROM topics
3131
WHERE topics.category_id = :category_id
32-
AND discourse_voting_votes.topic_id = topics.id
32+
AND topic_voting_votes.topic_id = topics.id
3333
SQL
3434
end
3535

@@ -41,7 +41,7 @@ def reset_voting_cache
4141

4242
# == Schema Information
4343
#
44-
# Table name: discourse_voting_category_settings
44+
# Table name: topic_voting_category_settings
4545
#
4646
# id :bigint not null, primary key
4747
# category_id :integer
@@ -50,5 +50,5 @@ def reset_voting_cache
5050
#
5151
# Indexes
5252
#
53-
# index_discourse_voting_category_settings_on_category_id (category_id) UNIQUE
53+
# index_topic_voting_category_settings_on_category_id (category_id) UNIQUE
5454
#

app/models/discourse_topic_voting/topic_vote_count.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
module DiscourseTopicVoting
44
class TopicVoteCount < ActiveRecord::Base
5-
self.table_name = "discourse_voting_topic_vote_count"
5+
self.table_name = "topic_voting_topic_vote_count"
66

77
belongs_to :topic
88
end
99
end
1010

1111
# == Schema Information
1212
#
13-
# Table name: discourse_voting_topic_vote_count
13+
# Table name: topic_voting_topic_vote_count
1414
#
1515
# id :bigint not null, primary key
1616
# topic_id :integer
@@ -20,5 +20,5 @@ class TopicVoteCount < ActiveRecord::Base
2020
#
2121
# Indexes
2222
#
23-
# index_discourse_voting_topic_vote_count_on_topic_id (topic_id) UNIQUE
23+
# index_topic_voting_topic_vote_count_on_topic_id (topic_id) UNIQUE
2424
#

app/models/discourse_topic_voting/vote.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module DiscourseTopicVoting
44
class Vote < ActiveRecord::Base
5-
self.table_name = "discourse_voting_votes"
5+
self.table_name = "topic_voting_votes"
66

77
belongs_to :user
88
belongs_to :topic
@@ -11,7 +11,7 @@ class Vote < ActiveRecord::Base
1111

1212
# == Schema Information
1313
#
14-
# Table name: discourse_voting_votes
14+
# Table name: topic_voting_votes
1515
#
1616
# id :bigint not null, primary key
1717
# topic_id :integer
@@ -22,5 +22,5 @@ class Vote < ActiveRecord::Base
2222
#
2323
# Indexes
2424
#
25-
# index_discourse_voting_votes_on_user_id_and_topic_id (user_id,topic_id) UNIQUE
25+
# index_topic_voting_votes_on_user_id_and_topic_id (user_id,topic_id) UNIQUE
2626
#

assets/javascripts/discourse/initializers/discourse-topic-voting.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
initialize() {
99
withPluginApi("0.8.32", (api) => {
1010
const siteSettings = api.container.lookup("service:site-settings");
11-
if (siteSettings.voting_enabled) {
11+
if (siteSettings.topic_voting_enabled) {
1212
const pageSearchController = api.container.lookup(
1313
"controller:full-page-search"
1414
);
@@ -61,7 +61,7 @@ export default {
6161

6262
withPluginApi("0.11.7", (api) => {
6363
const siteSettings = api.container.lookup("service:site-settings");
64-
if (siteSettings.voting_enabled) {
64+
if (siteSettings.topic_voting_enabled) {
6565
api.addSearchSuggestion("order:votes");
6666
}
6767
});

assets/javascripts/discourse/templates/connectors/user-activity-bottom/user-voted-topics.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{#if siteSettings.voting_show_votes_on_profile}}
1+
{{#if siteSettings.topic_voting_show_votes_on_profile}}
22
<LinkTo @route="userActivity.votes">
33
{{d-icon "heart"}}
44
{{i18n "topic_voting.vote_title_plural"}}

assets/javascripts/discourse/widgets/vote-box.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default createWidget("vote-box", {
99
buildKey: () => "vote-box",
1010

1111
buildClasses() {
12-
if (this.siteSettings.voting_show_who_voted) {
12+
if (this.siteSettings.topic_voting_show_who_voted) {
1313
return "show-pointer";
1414
}
1515
},

assets/javascripts/discourse/widgets/vote-button.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default createWidget("vote-button", {
2121
}
2222
}
2323
}
24-
if (this.siteSettings.voting_show_who_voted) {
24+
if (this.siteSettings.topic_voting_show_who_voted) {
2525
buttonClass += " show-pointer";
2626
}
2727
return buttonClass;

assets/javascripts/discourse/widgets/vote-count.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default createWidget("vote-count", {
2222
let voteCount = h("div.vote-count", attrs.vote_count.toString());
2323
let whoVoted = null;
2424
if (
25-
this.siteSettings.voting_show_who_voted &&
25+
this.siteSettings.topic_voting_show_who_voted &&
2626
this.state.whoVotedUsers &&
2727
this.state.whoVotedUsers.length > 0
2828
) {
@@ -47,7 +47,10 @@ export default createWidget("vote-count", {
4747
return;
4848
}
4949

50-
if (this.siteSettings.voting_show_who_voted && this.attrs.vote_count > 0) {
50+
if (
51+
this.siteSettings.topic_voting_show_who_voted &&
52+
this.attrs.vote_count > 0
53+
) {
5154
if (this.state.whoVotedUsers === null) {
5255
return this.getWhoVoted();
5356
} else {

config/locales/server.ar.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
ar:
88
site_settings:
9-
voting_enabled: 'السماح للأعضاء بالتصويت على الموضوعات؟'
10-
voting_tl0_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 0؟'
11-
voting_tl1_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 1؟'
12-
voting_tl2_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 2؟'
13-
voting_tl3_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 3؟'
14-
voting_tl4_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 4؟'
15-
voting_show_who_voted: 'هل تريد السماح للأعضاء برؤية من صوَّتوا؟'
16-
voting_show_votes_on_profile: 'هل تريد السماح للأعضاء برؤية أصواتهم في موجز النشاط؟'
17-
voting_alert_votes_left: 'تنبيه المستخدم عندما يتبقى هذا العدد من الأصوات'
9+
topic_voting_enabled: 'السماح للأعضاء بالتصويت على الموضوعات؟'
10+
topic_voting_tl0_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 0؟'
11+
topic_voting_tl1_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 1؟'
12+
topic_voting_tl2_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 2؟'
13+
topic_voting_tl3_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 3؟'
14+
topic_voting_tl4_vote_limit: 'ما عدد الأصوات النشطة المسموح بها للمستخدمين من مستوى الثقة 4؟'
15+
topic_voting_show_who_voted: 'هل تريد السماح للأعضاء برؤية من صوَّتوا؟'
16+
topic_voting_show_votes_on_profile: 'هل تريد السماح للأعضاء برؤية أصواتهم في موجز النشاط؟'
17+
topic_voting_alert_votes_left: 'تنبيه المستخدم عندما يتبقى هذا العدد من الأصوات'
1818
topic_voting:
1919
votes_moved:
2020
zero: "تم نقل %{count} صوت."

config/locales/server.bg.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
bg:
88
site_settings:
9-
voting_enabled: 'Да се разреши ли на потребителите да гласуват по теми?'
10-
voting_tl0_vote_limit: 'Колко активни гласа са позволени на потребителите на TL0?'
11-
voting_tl1_vote_limit: 'Колко активни гласа са позволени на потребителите на TL1?'
12-
voting_tl2_vote_limit: 'Колко активни гласа са позволени на потребителите на TL2?'
13-
voting_tl3_vote_limit: 'Колко активни гласа са позволени на потребителите на TL3?'
14-
voting_tl4_vote_limit: 'Колко активни гласа са позволени на потребителите на TL4?'
15-
voting_show_who_voted: 'Позволяване ли на потребителите да видят кой е гласувал?'
16-
voting_show_votes_on_profile: 'Позволяване на потребителите да виждат своите гласове в потока на активността си?'
17-
voting_alert_votes_left: 'Уведомете потребителя, когато останат толкова гласове'
9+
topic_voting_enabled: 'Да се разреши ли на потребителите да гласуват по теми?'
10+
topic_voting_tl0_vote_limit: 'Колко активни гласа са позволени на потребителите на TL0?'
11+
topic_voting_tl1_vote_limit: 'Колко активни гласа са позволени на потребителите на TL1?'
12+
topic_voting_tl2_vote_limit: 'Колко активни гласа са позволени на потребителите на TL2?'
13+
topic_voting_tl3_vote_limit: 'Колко активни гласа са позволени на потребителите на TL3?'
14+
topic_voting_tl4_vote_limit: 'Колко активни гласа са позволени на потребителите на TL4?'
15+
topic_voting_show_who_voted: 'Позволяване ли на потребителите да видят кой е гласувал?'
16+
topic_voting_show_votes_on_profile: 'Позволяване на потребителите да виждат своите гласове в потока на активността си?'
17+
topic_voting_alert_votes_left: 'Уведомете потребителя, когато останат толкова гласове'
1818
topic_voting:
1919
votes_moved:
2020
one: "Един глас беше преместен."

config/locales/server.bs_BA.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
bs_BA:
88
site_settings:
9-
voting_enabled: 'Dozvoli korisnicima da glasaju u temama?'
10-
voting_tl0_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 0?'
11-
voting_tl1_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 1?'
12-
voting_tl2_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 2?'
13-
voting_tl3_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 3?'
14-
voting_tl4_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 4?'
15-
voting_show_who_voted: 'Dozvoli korisnicima da vide ko je glasao?'
16-
voting_show_votes_on_profile: 'Dozvoli korisnicima da vide svoje glasove u svojem pregledu aktivnosti?'
17-
voting_alert_votes_left: 'Upozorite korisnike kada do naksimalnog broja glasova ostano još'
9+
topic_voting_enabled: 'Dozvoli korisnicima da glasaju u temama?'
10+
topic_voting_tl0_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 0?'
11+
topic_voting_tl1_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 1?'
12+
topic_voting_tl2_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 2?'
13+
topic_voting_tl3_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 3?'
14+
topic_voting_tl4_vote_limit: 'Koliko aktivnih glasova je dozvoljeno korisnicima sa nivoom povjerenja 4?'
15+
topic_voting_show_who_voted: 'Dozvoli korisnicima da vide ko je glasao?'
16+
topic_voting_show_votes_on_profile: 'Dozvoli korisnicima da vide svoje glasove u svojem pregledu aktivnosti?'
17+
topic_voting_alert_votes_left: 'Upozorite korisnike kada do naksimalnog broja glasova ostano još'
1818
topic_voting:
1919
votes_moved:
2020
one: "Glas je maknut."

config/locales/server.ca.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
ca:
88
site_settings:
9-
voting_enabled: 'Voleu permetre als usuaris votar sobre temes?'
10-
voting_tl0_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 0?'
11-
voting_tl1_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 1?'
12-
voting_tl2_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 2?'
13-
voting_tl3_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 3?'
14-
voting_tl4_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 4?'
15-
voting_show_who_voted: 'Voleu permetre que els usuaris vegin qui ha votat?'
16-
voting_show_votes_on_profile: 'Voleu permetre als usuaris veure els seus vots en el seu canal d''activitat?'
17-
voting_alert_votes_left: 'Alerta l''usuari quan quedi aquesta quantitat de vots'
9+
topic_voting_enabled: 'Voleu permetre als usuaris votar sobre temes?'
10+
topic_voting_tl0_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 0?'
11+
topic_voting_tl1_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 1?'
12+
topic_voting_tl2_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 2?'
13+
topic_voting_tl3_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 3?'
14+
topic_voting_tl4_vote_limit: 'Quants vots actius són permesos als usuaris del nivell de confiança 4?'
15+
topic_voting_show_who_voted: 'Voleu permetre que els usuaris vegin qui ha votat?'
16+
topic_voting_show_votes_on_profile: 'Voleu permetre als usuaris veure els seus vots en el seu canal d''activitat?'
17+
topic_voting_alert_votes_left: 'Alerta l''usuari quan quedi aquesta quantitat de vots'
1818
topic_voting:
1919
votes_moved:
2020
one: "S'ha mogut un vot"

0 commit comments

Comments
 (0)