Commit 962f9efe authored by Lin Jen-Shin's avatar Lin Jen-Shin
parent a538b0da
...@@ -80,6 +80,7 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -80,6 +80,7 @@ class ApplicationSetting < ActiveRecord::Base
presence: true, presence: true,
numericality: { only_integer: true, greater_than: 0 } numericality: { only_integer: true, greater_than: 0 }
validates :default_artifacts_expire_in, presence: true
validate :check_default_artifacts_expire_in validate :check_default_artifacts_expire_in
validates :container_registry_token_expire_delay, validates :container_registry_token_expire_delay,
...@@ -222,6 +223,14 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -222,6 +223,14 @@ class ApplicationSetting < ActiveRecord::Base
create(defaults) create(defaults)
end end
def self.human_attribute_name(attr, _options = {})
if attr == :default_artifacts_expire_in
'Default artifacts expiration'
else
super
end
end
def home_page_url_column_exist def home_page_url_column_exist
ActiveRecord::Base.connection.column_exists?(:application_settings, :home_page_url) ActiveRecord::Base.connection.column_exists?(:application_settings, :home_page_url)
end end
...@@ -298,12 +307,8 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -298,12 +307,8 @@ class ApplicationSetting < ActiveRecord::Base
end end
def check_default_artifacts_expire_in def check_default_artifacts_expire_in
if default_artifacts_expire_in.blank? ChronicDuration.parse(default_artifacts_expire_in)
errors.add(:default_artifacts_expiration, "is not presented")
else
ChronicDuration.parse(default_artifacts_expire_in)
end
rescue ChronicDuration::DurationParseError rescue ChronicDuration::DurationParseError
errors.add(:default_artifacts_expiration, "is invalid") errors.add(:default_artifacts_expiration, "is not a correct duration")
end end
end end
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