diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb
index 1ef53da..0657c29 100644
--- a/app/controllers/settings_controller.rb
+++ b/app/controllers/settings_controller.rb
@@ -81,7 +81,8 @@ private
:username, :email, :password, :password_confirmation, :about,
:email_replies, :email_messages, :email_mentions,
:pushover_replies, :pushover_messages, :pushover_mentions,
- :mailing_list_mode, :show_avatars, :show_story_previews
+ :mailing_list_mode, :show_avatars, :show_story_previews,
+ :show_submitted_story_threads
)
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 9af84d5..6b9f52f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -253,8 +253,18 @@ class User < ActiveRecord::Base
end
def recent_threads(amount)
- self.comments.group(:thread_id).order('MAX(created_at) DESC').limit(
- amount).pluck(:thread_id)
+ thread_ids = self.comments.group(:thread_id).order('MAX(created_at) DESC').
+ limit(amount).pluck(:thread_id)
+
+ if self.show_submitted_story_threads
+ thread_ids += Comment.joins(:story).
+ where(:stories => { :user_id => self.id }).group(:thread_id).
+ order("MAX(comments.created_at) DESC").limit(amount).pluck(:thread_id)
+
+ thread_ids = thread_ids.uniq.sort.reverse[0, amount]
+ end
+
+ thread_ids
end
def stories_submitted_count
diff --git a/app/views/settings/index.html.erb b/app/views/settings/index.html.erb
index 5025922..ef59afd 100644
--- a/app/views/settings/index.html.erb
+++ b/app/views/settings/index.html.erb
@@ -80,7 +80,6 @@
-
Comment Reply Notification Settings
@@ -141,6 +140,18 @@
+
+ Submitted Story Comment Settings
+
+
+
+ <%= f.label :show_submitted_story_threads,
+ "Show in Your Threads:", :class => "required" %>
+ <%= f.check_box :show_submitted_story_threads %>
+
+
+
+
Mailing List Settings
diff --git a/db/migrate/20151207180050_add_user_setting_post_threads.rb b/db/migrate/20151207180050_add_user_setting_post_threads.rb
new file mode 100644
index 0000000..e0fed77
--- /dev/null
+++ b/db/migrate/20151207180050_add_user_setting_post_threads.rb
@@ -0,0 +1,6 @@
+class AddUserSettingPostThreads < ActiveRecord::Migration
+ def change
+ add_column "users", "show_submitted_story_threads", :boolean,
+ :default => true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index fed3557..0d1cd56 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20151015143959) do
+ActiveRecord::Schema.define(version: 20151207180050) do
create_table "comments", force: true do |t|
t.datetime "created_at", null: false
@@ -174,34 +174,35 @@ ActiveRecord::Schema.define(version: 20151015143959) do
add_index "tags", ["tag"], name: "tag", unique: true, using: :btree
create_table "users", force: true do |t|
- t.string "username", limit: 50
- t.string "email", limit: 100
- t.string "password_digest", limit: 75
+ t.string "username", limit: 50
+ t.string "email", limit: 100
+ t.string "password_digest", limit: 75
t.datetime "created_at"
- t.boolean "email_notifications", default: false
- t.boolean "is_admin", default: false
- t.string "password_reset_token", limit: 75
- t.string "session_token", limit: 75, default: "", null: false
- t.text "about", limit: 16777215
+ t.boolean "email_notifications", default: false
+ t.boolean "is_admin", default: false
+ t.string "password_reset_token", limit: 75
+ t.string "session_token", limit: 75, default: "", null: false
+ t.text "about", limit: 16777215
t.integer "invited_by_user_id"
- t.boolean "email_replies", default: false
- t.boolean "pushover_replies", default: false
+ t.boolean "email_replies", default: false
+ t.boolean "pushover_replies", default: false
t.string "pushover_user_key"
- t.boolean "email_messages", default: true
- t.boolean "pushover_messages", default: true
- t.boolean "is_moderator", default: false
- t.boolean "email_mentions", default: false
- t.boolean "pushover_mentions", default: false
- t.string "rss_token", limit: 75
- t.string "mailing_list_token", limit: 75
- t.integer "mailing_list_mode", default: 0
- t.integer "karma", default: 0, null: false
+ t.boolean "email_messages", default: true
+ t.boolean "pushover_messages", default: true
+ t.boolean "is_moderator", default: false
+ t.boolean "email_mentions", default: false
+ t.boolean "pushover_mentions", default: false
+ t.string "rss_token", limit: 75
+ t.string "mailing_list_token", limit: 75
+ t.integer "mailing_list_mode", default: 0
+ t.integer "karma", default: 0, null: false
t.datetime "banned_at"
t.integer "banned_by_user_id"
- t.string "banned_reason", limit: 200
+ t.string "banned_reason", limit: 200
t.datetime "deleted_at"
- t.boolean "show_avatars", default: false
- t.boolean "show_story_previews", default: false
+ t.boolean "show_avatars", default: false
+ t.boolean "show_story_previews", default: false
+ t.boolean "show_submitted_story_threads", default: true
end
add_index "users", ["mailing_list_mode"], name: "mailing_list_enabled", using: :btree