From 14e49956f7e85800883580f3b3c4bb3c75259a5e Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 17 Aug 2023 13:44:22 +0200 Subject: [PATCH] Show only default label templates when feature is disabled [SCI-9028] --- app/controllers/label_templates_controller.rb | 2 +- app/models/label_template.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/label_templates_controller.rb b/app/controllers/label_templates_controller.rb index fbdbecbcf..cbc13c7c6 100644 --- a/app/controllers/label_templates_controller.rb +++ b/app/controllers/label_templates_controller.rb @@ -174,7 +174,7 @@ class LabelTemplatesController < ApplicationController end def load_label_templates - @label_templates = LabelTemplate.where(team_id: current_team.id) + @label_templates = LabelTemplate.enabled? ? current_team.label_templates : current_team.label_templates.default end def load_label_template diff --git a/app/models/label_template.rb b/app/models/label_template.rb index 1346ac246..21526f31d 100644 --- a/app/models/label_template.rb +++ b/app/models/label_template.rb @@ -15,6 +15,8 @@ class LabelTemplate < ApplicationRecord validate :ensure_single_default_template! + scope :default, -> { where(default: true) } + def self.enabled? ApplicationSettings.instance.values['label_templates_enabled'] == true end