From e22cfe8c242eb0235ca913e4356a0dedd94d9bab Mon Sep 17 00:00:00 2001
From: ArtOfCode- <hello@artofcode.co.uk>
Date: Thu, 2 Jul 2020 00:55:41 +0100
Subject: [PATCH] Uniqueness for warning templates

---
 app/models/warning_template.rb | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/models/warning_template.rb b/app/models/warning_template.rb
index 08c4d3a36..a1de737c5 100644
--- a/app/models/warning_template.rb
+++ b/app/models/warning_template.rb
@@ -3,6 +3,8 @@ require 'base64'
 class WarningTemplate < ApplicationRecord
   include CommunityRelated
 
+  validate :name, uniqueness: { scope: [:community_id] }
+
   def body_as_b64
     body_with_site_replacements = body.gsub '$SiteName', SiteSetting['SiteName']
 
-- 
GitLab