FIX: do not allow posting of category topic template without any changes

FIX: do not allow posting of category topic template without any changes

diff --git a/app/assets/javascripts/discourse/models/composer.js.es6 b/app/assets/javascripts/discourse/models/composer.js.es6
index 903d61b..2df885d 100644
--- a/app/assets/javascripts/discourse/models/composer.js.es6
+++ b/app/assets/javascripts/discourse/models/composer.js.es6
@@ -358,6 +358,17 @@ const Composer = RestModel.extend({
       }
     }
 
+    if (topicFirstPost) {
+      // user should modify topic template
+      const category = this.category;
+      if (category && category.topic_template) {
+        if (this.reply.trim() === category.topic_template.trim()) {
+          bootbox.alert(I18n.t("composer.error.topic_template_not_modified"))
+          return true;
+        }
+      }
+    }
+
     if (this.privateMessage) {
       // need at least one user when sending a PM
       return (
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 50b1517..241b724 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1626,6 +1626,7 @@ en:
         try_like: "Have you tried the {{heart}} button?"
         category_missing: "You must choose a category"
         tags_missing: "You must choose at least {{count}} tags"
+        topic_template_not_modified: "You have not modified the topic template. Please update the topic."
 
       save_edit: "Save Edit"
       overwrite_edit: "Overwrite Edit"

GitHub sha: 671ffc4e

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: