diff --git a/app/models/custom_variable.rb b/app/models/custom_variable.rb index a7bb4d8c6..b490d8566 100644 --- a/app/models/custom_variable.rb +++ b/app/models/custom_variable.rb @@ -25,6 +25,7 @@ class CustomVariable < ApplicationRecord "past_calendar_range" => :text, "academic_calendar_range" => :text, "quadrennial_period" => :text, + "instance_name" => :text, } validates :variable, presence: true @@ -115,6 +116,10 @@ def self.quadrennial_period config.blank? ? "Not defined" : config.value end + def self.instance_name + config = CustomVariable.find_by_variable(:instance_name) + config.blank? ? nil : config.value + end def to_label self.variable.to_s diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 27b2cafd2..3d72127c9 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -11,6 +11,11 @@ html: { id: "login_form" } ) do |f| %> <%= flash[:name] %> + <% if CustomVariable.instance_name %> +
+ Login de acesso para <%= CustomVariable.instance_name %> +
+ <% end %>
<%= f.label :email, 'Email ou CPF' %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 01d1756da..868600f73 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -41,11 +41,18 @@ <% end %>
-
+
Versão <%= APP_VERSION %> | <%= link_to 'Créditos', credits_show_path %> -
-
- <%= role_selector(current_user) %> +
+
+ <% if CustomVariable.instance_name %> +
+ <%= CustomVariable.instance_name %> +
+ <% end %> +
+ <%= role_selector(current_user) %> +
diff --git a/db/migrate/20250903205743_create_instance_name_variable.rb b/db/migrate/20250903205743_create_instance_name_variable.rb new file mode 100644 index 000000000..2098f5b33 --- /dev/null +++ b/db/migrate/20250903205743_create_instance_name_variable.rb @@ -0,0 +1,11 @@ +class CreateInstanceNameVariable < ActiveRecord::Migration[7.0] + def up + CustomVariable.where( + variable: "instance_name" + ).first || CustomVariable.create( + description: "Nome do programa", + variable: "instance_name", + value: nil + ) + end +end diff --git a/spec/models/custom_variable_spec.rb b/spec/models/custom_variable_spec.rb index 1c7945b0d..e6331d2f7 100644 --- a/spec/models/custom_variable_spec.rb +++ b/spec/models/custom_variable_spec.rb @@ -161,5 +161,22 @@ expect(CustomVariable.notification_footer).to eq("bla") end end + + context "instance_name" do + it "should return nil when there is no variable defined" do + config = CustomVariable.find_by_variable(:instance_name) + config.delete unless config.nil? + + expect(CustomVariable.instance_name).to eq(nil) + end + + it "should return 'Computacao' when it is defined to Computacao" do + config = CustomVariable.find_by_variable(:instance_name) + config.delete unless config.nil? + @destroy_later << CustomVariable.create(variable: :instance_name, value: "Computacao") + + expect(CustomVariable.instance_name).to eq("Computacao") + end + end end end