From 48cb386d58d7e5b2d31b8377ff488271b05d4bf8 Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Fri, 12 Feb 2016 22:02:24 -0800 Subject: [PATCH 1/5] Take filename to write to as optional parameter to export_category My discourse instance will be making regular automated public backups of specific categories. It's preferred to be able to directly control the path and filename of the output, rather than letting discourse choose for me. This was already mostly supported, a filename parameter just needed to be passed through the cli app. --- lib/import_export/import_export.rb | 4 ++-- script/discourse | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/import_export/import_export.rb b/lib/import_export/import_export.rb index 715a4bea5e5..4bb6fa9250d 100644 --- a/lib/import_export/import_export.rb +++ b/lib/import_export/import_export.rb @@ -6,8 +6,8 @@ require "json" module ImportExport - def self.export_category(category_id) - ImportExport::CategoryExporter.new(category_id).perform.save_to_file + def self.export_category(category_id, filename=nil) + ImportExport::CategoryExporter.new(category_id).perform.save_to_file(filename) end def self.import_category(filename) diff --git a/script/discourse b/script/discourse index fb91f986f4f..af03de89b35 100755 --- a/script/discourse +++ b/script/discourse @@ -135,12 +135,12 @@ class DiscourseCLI < Thor end desc "export_category", "Export a category, all its topics, and all users who posted in those topics" - def export_category(category_id) + def export_category(category_id, filename=nil) raise "Category id argument is missing!" unless category_id load_rails load_import_export - ImportExport.export_category(category_id) + ImportExport.export_category(category_id, filename) puts "", "Done", "" end From c75360f8098673a5fdbdffd4a2f3cadf6b746639 Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Mon, 15 Feb 2016 15:59:31 -0800 Subject: [PATCH 2/5] Capitalize "ip" in "ip address" --- config/locales/client.en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 97dbc78ac3a..cfab4a6dc0a 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -299,7 +299,7 @@ en: other: "This topic has {{count}} posts awaiting approval" confirm: "Save Changes" - delete_prompt: "Are you sure you want to delete %{username}? This will remove all of their posts and block their email and ip address." + delete_prompt: "Are you sure you want to delete %{username}? This will remove all of their posts and block their email and IP address." approval: title: "Post Needs Approval" From 0c6e5befe462a233fb52570b5d6b7e86bcd2b697 Mon Sep 17 00:00:00 2001 From: Erick Guan Date: Tue, 16 Feb 2016 12:37:59 +0100 Subject: [PATCH 3/5] FIX: topic summary description text was conflicts with reply counter --- .../discourse/templates/components/toggle-summary.hbs | 4 ++-- config/locales/client.en.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/templates/components/toggle-summary.hbs b/app/assets/javascripts/discourse/templates/components/toggle-summary.hbs index 6eed02a1cd2..671b85d945e 100644 --- a/app/assets/javascripts/discourse/templates/components/toggle-summary.hbs +++ b/app/assets/javascripts/discourse/templates/components/toggle-summary.hbs @@ -3,9 +3,9 @@ {{else}} {{#if topic.estimatedReadingTime}} -

{{{i18n 'summary.description_time' count=topic.posts_count readingTime=topic.estimatedReadingTime}}}

+

{{{i18n 'summary.description_time' replyCount=topic.replyCount readingTime=topic.estimatedReadingTime}}}

{{else}} -

{{{i18n 'summary.description' count=topic.posts_count}}}

+

{{{i18n 'summary.description' replyCount=topic.replyCount}}}

{{/if}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index cfab4a6dc0a..cdb5b7bc88b 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -804,8 +804,8 @@ en: summary: enabled_description: "You're viewing a summary of this topic: the most interesting posts as determined by the community." - description: "There are {{count}} replies." - description_time: "There are {{count}} replies with an estimated read time of {{readingTime}} minutes." + description: "There are {{replyCount}} replies." + description_time: "There are {{replyCount}} replies with an estimated read time of {{readingTime}} minutes." enable: 'Summarize This Topic' disable: 'Show All Posts' From 81c6fb318b9648dbccf682579a049fb583660ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 16 Feb 2016 16:09:05 +0100 Subject: [PATCH 4/5] FIX: show name in preferences when SSO is enabled and is used to override names --- app/assets/javascripts/discourse/templates/user/preferences.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/templates/user/preferences.hbs b/app/assets/javascripts/discourse/templates/user/preferences.hbs index 37966945a30..636227b757b 100644 --- a/app/assets/javascripts/discourse/templates/user/preferences.hbs +++ b/app/assets/javascripts/discourse/templates/user/preferences.hbs @@ -28,7 +28,7 @@ {{#if model.can_edit_name}} {{text-field value=newNameInput classNames="input-xxlarge"}} {{else}} - {{name}} + {{model.name}} {{/if}}
From bf96025507dd76ab6dc93762b6a8ca2510baac26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 16 Feb 2016 16:35:57 +0100 Subject: [PATCH 5/5] link email logs to the post that generate the email notification when available --- .../javascripts/admin/templates/email-sent.hbs | 8 +++++++- .../javascripts/admin/templates/email-skipped.hbs | 8 +++++++- app/controllers/admin/email_controller.rb | 2 +- app/jobs/regular/user_email.rb | 9 +++++---- app/serializers/email_log_serializer.rb | 12 +++++++++++- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/admin/templates/email-sent.hbs b/app/assets/javascripts/admin/templates/email-sent.hbs index 4e4f5dbf77a..2f8785c6f59 100644 --- a/app/assets/javascripts/admin/templates/email-sent.hbs +++ b/app/assets/javascripts/admin/templates/email-sent.hbs @@ -30,7 +30,13 @@ {{l.to_address}} {{l.email_type}} - {{l.reply_key}} + + {{#if l.post_url}} + {{l.reply_key}} + {{else}} + {{l.reply_key}} + {{/if}} + {{else}} {{i18n 'admin.email.logs.none'}} diff --git a/app/assets/javascripts/admin/templates/email-skipped.hbs b/app/assets/javascripts/admin/templates/email-skipped.hbs index d983b093785..6ef48725668 100644 --- a/app/assets/javascripts/admin/templates/email-skipped.hbs +++ b/app/assets/javascripts/admin/templates/email-skipped.hbs @@ -30,7 +30,13 @@ {{l.to_address}} {{l.email_type}} - {{l.skipped_reason}} + + {{#if l.post_url}} + {{l.skipped_reason}} + {{else}} + {{l.skipped_reason}} + {{/if}} + {{else}} {{i18n 'admin.email.logs.none'}} diff --git a/app/controllers/admin/email_controller.rb b/app/controllers/admin/email_controller.rb index 4b685c48e24..8ca208afb8d 100644 --- a/app/controllers/admin/email_controller.rb +++ b/app/controllers/admin/email_controller.rb @@ -67,7 +67,7 @@ class Admin::EmailController < Admin::AdminController private def filter_email_logs(email_logs, params) - email_logs = email_logs.includes(:user) + email_logs = email_logs.includes(:user, { post: :topic }) .references(:user) .order(created_at: :desc) .offset(params[:offset] || 0) diff --git a/app/jobs/regular/user_email.rb b/app/jobs/regular/user_email.rb index 404dd07f8e5..6830ec2e64a 100644 --- a/app/jobs/regular/user_email.rb +++ b/app/jobs/regular/user_email.rb @@ -15,7 +15,7 @@ module Jobs user = User.find_by(id: args[:user_id]) to_address = args[:to_address].presence || user.try(:email).presence || "no_email_found" - set_skip_context(type, args[:user_id], to_address) + set_skip_context(type, args[:user_id], to_address, args[:post_id]) return skip(I18n.t("email_log.no_user", user_id: args[:user_id])) unless user @@ -44,8 +44,8 @@ module Jobs end end - def set_skip_context(type, user_id, to_address) - @skip_context = { type: type, user_id: user_id, to_address: to_address } + def set_skip_context(type, user_id, to_address, post_id) + @skip_context = { type: type, user_id: user_id, to_address: to_address, post_id: post_id } end NOTIFICATIONS_SENT_BY_MAILING_LIST ||= Set.new %w{posted replied mentioned group_mentioned quoted} @@ -54,7 +54,7 @@ module Jobs notification_type=nil, notification_data_hash=nil, email_token=nil, to_address=nil) - set_skip_context(type, user.id, to_address || user.email) + set_skip_context(type, user.id, to_address || user.email, post.try(:id)) return skip_message(I18n.t("email_log.anonymous_user")) if user.anonymous? return skip_message(I18n.t("email_log.suspended_not_pm")) if user.suspended? && type != :user_private_message @@ -142,6 +142,7 @@ module Jobs email_type: @skip_context[:type], to_address: @skip_context[:to_address], user_id: @skip_context[:user_id], + post_id: @skip_context[:post_id], skipped: true, skipped_reason: "[UserEmail] #{reason}", ) diff --git a/app/serializers/email_log_serializer.rb b/app/serializers/email_log_serializer.rb index 977e3ee93bf..07f336d4e37 100644 --- a/app/serializers/email_log_serializer.rb +++ b/app/serializers/email_log_serializer.rb @@ -7,11 +7,21 @@ class EmailLogSerializer < ApplicationSerializer :user_id, :created_at, :skipped, - :skipped_reason + :skipped_reason, + :post_url has_one :user, serializer: BasicUserSerializer, embed: :objects def include_skipped_reason? object.skipped end + + def post_url + object.post.url + end + + def include_post_url? + object.post.present? + end + end