Verified Commit db6c2e1d authored by Martin Mladenov's avatar Martin Mladenov
Browse files

Rename ConfigurationParameter to SystemConfigurationParameter

parent 809f1568
......@@ -16,14 +16,14 @@ module Admin
def set_banner
banner_content = params[:content]
ConfigurationParameter.set!(ConfigurationParameter::BANNER_CONTENT_KEY, banner_content)
ConfigurationParameter.set!(ConfigurationParameter::BANNER_ENABLE_KEY, 'true')
SystemConfigurationParameter.set!(SystemConfigurationParameter::BANNER_CONTENT_KEY, banner_content)
SystemConfigurationParameter.set!(SystemConfigurationParameter::BANNER_ENABLE_KEY, 'true')
flash[:success] = 'Successfully enabled banner'
redirect_to admin_administration_path
end
def disable_banner
ConfigurationParameter.set!(ConfigurationParameter::BANNER_ENABLE_KEY, 'false')
SystemConfigurationParameter.set!(SystemConfigurationParameter::BANNER_ENABLE_KEY, 'false')
flash[:success] = 'Successfully disabled banner'
redirect_to admin_administration_path
end
......
class ConfigurationParameter < ApplicationRecord
class SystemConfigurationParameter < ApplicationRecord
validates :key, presence: true, length: { maximum: 64 }
# ===========================================================================
......@@ -11,11 +11,11 @@ class ConfigurationParameter < ApplicationRecord
# Methods
# ===========================================================================
def self.get(key)
ConfigurationParameter.find_by(key: key)&.value
SystemConfigurationParameter.find_by(key: key)&.value
end
def self.set!(key, value)
param = ConfigurationParameter.find_or_initialize_by(key: key)
param = SystemConfigurationParameter.find_or_initialize_by(key: key)
param.value = value
param.save!
end
......
<% enabled = ConfigurationParameter.get(ConfigurationParameter::BANNER_ENABLE_KEY) === 'true' %>
<% enabled = SystemConfigurationParameter.get(SystemConfigurationParameter::BANNER_ENABLE_KEY) === 'true' %>
<div class="panel panel-default">
<div class="panel-heading">
......@@ -9,7 +9,7 @@
<form action="<%= admin_administration_set_banner_path %>" method="post" id="banner-form">
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<%= text_area_tag :content,
ConfigurationParameter.get(ConfigurationParameter::BANNER_CONTENT_KEY),
SystemConfigurationParameter.get(SystemConfigurationParameter::BANNER_CONTENT_KEY),
class: 'toastui-editor-init', 'data-height': '300px' %>
</form>
<div class="pull-right mtm">
......
<% enabled = ConfigurationParameter.get(ConfigurationParameter::BANNER_ENABLE_KEY) === 'true' %>
<% enabled = SystemConfigurationParameter.get(SystemConfigurationParameter::BANNER_ENABLE_KEY) === 'true' %>
<% if enabled %>
<% content = ConfigurationParameter.get(ConfigurationParameter::BANNER_CONTENT_KEY) %>
<% content = SystemConfigurationParameter.get(SystemConfigurationParameter::BANNER_CONTENT_KEY) %>
<%= content_tag :div, class:
controller.class.module_parent == Admin ?
'alert alert-warning ptm pbz mam' :
......
......@@ -41,7 +41,7 @@
url: admin_administration_path,
icon: :'wrench',
label: 'Administration',
resources: [ConfigurationParameter]
resources: [SystemConfigurationParameter]
}
}.each do |name, data| %>
<%= render 'layouts/navigation_item', name: name, data: data %>
......
class AddConfigurationParameters < ActiveRecord::Migration[6.1]
class AddSystemConfigurationParameters < ActiveRecord::Migration[6.1]
def change
create_table :configuration_parameters do |t|
create_table :system_configuration_parameters do |t|
t.string :key, null: false, limit: 64
t.text :value
t.datetime "created_at", null: false
......
......@@ -99,7 +99,7 @@ ActiveRecord::Schema.define(version: 2022_11_20_155522) do
t.index ["company_id"], name: "index_company_user_email_suffixes_on_company_id"
end
create_table "configuration_parameters", force: :cascade do |t|
create_table "system_configuration_parameters", force: :cascade do |t|
t.string "key", limit: 64, null: false
t.text "value"
t.datetime "created_at", null: false
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment