Skip to content

Commit 41cb9ed

Browse files
authored
Merge pull request #577 from gems-uff/issue_556
Issue 556
2 parents 7850d15 + bb3bbef commit 41cb9ed

5 files changed

Lines changed: 53 additions & 4 deletions

File tree

app/models/custom_variable.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CustomVariable < ApplicationRecord
2525
"past_calendar_range" => :text,
2626
"academic_calendar_range" => :text,
2727
"quadrennial_period" => :text,
28+
"instance_name" => :text,
2829
}
2930

3031
validates :variable, presence: true
@@ -115,6 +116,10 @@ def self.quadrennial_period
115116
config.blank? ? "Not defined" : config.value
116117
end
117118

119+
def self.instance_name
120+
config = CustomVariable.find_by_variable(:instance_name)
121+
config.blank? ? nil : config.value
122+
end
118123

119124
def to_label
120125
self.variable.to_s

app/views/devise/sessions/new.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
html: { id: "login_form" }
1212
) do |f| %>
1313
<%= flash[:name] %>
14+
<% if CustomVariable.instance_name %>
15+
<div style="margin-bottom: 10px;">
16+
Login de acesso para <%= CustomVariable.instance_name %>
17+
</div>
18+
<% end %>
1419

1520
<div id="login_input">
1621
<%= f.label :email, 'Email ou CPF' %>

app/views/layouts/application.html.erb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,18 @@
4141
<% end %>
4242
</div>
4343
<div id="sub" style="display: flex-column;">
44-
<div>
44+
<div style="text-align: right;">
4545
Versão <%= APP_VERSION %> | <%= link_to 'Créditos', credits_show_path %>
46-
</div>
47-
<div id="role_selector" style="float: right">
48-
<%= role_selector(current_user) %>
46+
</div>
47+
<div style="float: right; text-align: right;">
48+
<% if CustomVariable.instance_name %>
49+
<div>
50+
<%= CustomVariable.instance_name %>
51+
</div>
52+
<% end %>
53+
<div id="role_selector">
54+
<%= role_selector(current_user) %>
55+
</div>
4956
</div>
5057
</div>
5158
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class CreateInstanceNameVariable < ActiveRecord::Migration[7.0]
2+
def up
3+
CustomVariable.where(
4+
variable: "instance_name"
5+
).first || CustomVariable.create(
6+
description: "Nome do programa",
7+
variable: "instance_name",
8+
value: nil
9+
)
10+
end
11+
12+
def down
13+
CustomVariable.where(variable: "instance_name").destroy_all
14+
end
15+
end

spec/models/custom_variable_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,22 @@
161161
expect(CustomVariable.notification_footer).to eq("bla")
162162
end
163163
end
164+
165+
context "instance_name" do
166+
it "should return nil when there is no variable defined" do
167+
config = CustomVariable.find_by_variable(:instance_name)
168+
config.delete unless config.nil?
169+
170+
expect(CustomVariable.instance_name).to eq(nil)
171+
end
172+
173+
it "should return 'Computacao' when it is defined to Computacao" do
174+
config = CustomVariable.find_by_variable(:instance_name)
175+
config.delete unless config.nil?
176+
@destroy_later << CustomVariable.create(variable: :instance_name, value: "Computacao")
177+
178+
expect(CustomVariable.instance_name).to eq("Computacao")
179+
end
180+
end
164181
end
165182
end

0 commit comments

Comments
 (0)