From 8589b4e137f50293952923bb07e2814257d7784d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 00:22:50 -0800 Subject: Init ApplicationSettings resource with defaults from config file --- app/models/application_setting.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/models/application_setting.rb (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb new file mode 100644 index 00000000000..4b885461cbb --- /dev/null +++ b/app/models/application_setting.rb @@ -0,0 +1,5 @@ +class ApplicationSetting < ActiveRecord::Base + def self.current + ApplicationSetting.last + end +end -- cgit v1.2.1 From d0a50985ec613584821806062df4eaa39337449c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 11:26:16 -0800 Subject: Create ApplicationSettings if does not exist in runtime --- app/models/application_setting.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 4b885461cbb..47fa6f1071c 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -2,4 +2,14 @@ class ApplicationSetting < ActiveRecord::Base def self.current ApplicationSetting.last end + + def self.create_from_defaults + create( + default_projects_limit: Settings.gitlab['default_projects_limit'], + signup_enabled: Settings.gitlab['signup_enabled'], + signin_enabled: Settings.gitlab['signin_enabled'], + gravatar_enabled: Settings.gravatar['enabled'], + sign_in_text: Settings.extra['sign_in_text'], + ) + end end -- cgit v1.2.1 From 41d7be3ce1ae9a4bff93b62322f35989b6ad4cf6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 16 Jan 2015 16:01:15 -0800 Subject: Allow to specify home page for non logged-in users --- app/models/application_setting.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 47fa6f1071c..d9c73559098 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -1,4 +1,7 @@ class ApplicationSetting < ActiveRecord::Base + validates :home_page_url, allow_blank: true, + format: { with: URI::regexp(%w(http https)), message: "should be a valid url" } + def self.current ApplicationSetting.last end -- cgit v1.2.1 From 38600e328bf4bacf2d3e4288943fb7652ee6c674 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 16 Jan 2015 17:22:17 -0800 Subject: Validate application settings only if column exists --- app/models/application_setting.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index d9c73559098..aed4068f309 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -1,6 +1,7 @@ class ApplicationSetting < ActiveRecord::Base validates :home_page_url, allow_blank: true, - format: { with: URI::regexp(%w(http https)), message: "should be a valid url" } + format: { with: URI::regexp(%w(http https)), message: "should be a valid url" }, + if: :home_page_url_column_exist def self.current ApplicationSetting.last @@ -15,4 +16,8 @@ class ApplicationSetting < ActiveRecord::Base sign_in_text: Settings.extra['sign_in_text'], ) end + + def home_page_url_column_exist + ActiveRecord::Base.connection.column_exists?(:application_settings, :home_page_url) + end end -- cgit v1.2.1 From 98ee4a1fa73183cacf6c470b56e34afccec1c5dc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 22 Jan 2015 09:40:03 -0800 Subject: Annotate models --- app/models/application_setting.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index aed4068f309..45ae79a75cc 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: application_settings +# +# id :integer not null, primary key +# default_projects_limit :integer +# signup_enabled :boolean +# signin_enabled :boolean +# gravatar_enabled :boolean +# sign_in_text :text +# created_at :datetime +# updated_at :datetime +# home_page_url :string(255) +# + class ApplicationSetting < ActiveRecord::Base validates :home_page_url, allow_blank: true, format: { with: URI::regexp(%w(http https)), message: "should be a valid url" }, -- cgit v1.2.1 From aad6ceaef9ccfba8e058012a0877b80c103a3838 Mon Sep 17 00:00:00 2001 From: Marco Wessel Date: Sun, 25 Jan 2015 16:33:54 +0100 Subject: Allow configuring protection of the default branch upon first push --- app/models/application_setting.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 45ae79a75cc..3285a1a248e 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -4,6 +4,7 @@ # # id :integer not null, primary key # default_projects_limit :integer +# default_branch_protection :integer # signup_enabled :boolean # signin_enabled :boolean # gravatar_enabled :boolean @@ -25,6 +26,7 @@ class ApplicationSetting < ActiveRecord::Base def self.create_from_defaults create( default_projects_limit: Settings.gitlab['default_projects_limit'], + default_branch_protection: Settings.gitlab['default_branch_protection'], signup_enabled: Settings.gitlab['signup_enabled'], signin_enabled: Settings.gitlab['signin_enabled'], gravatar_enabled: Settings.gravatar['enabled'], -- cgit v1.2.1 From cc39bca3fa71930421f1c46844b4d02d5ff93e8b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:15:44 -0800 Subject: Rubocop: Style/AlignHash enabled --- app/models/application_setting.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 45ae79a75cc..0b3d430add0 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -14,7 +14,8 @@ # class ApplicationSetting < ActiveRecord::Base - validates :home_page_url, allow_blank: true, + validates :home_page_url, + allow_blank: true, format: { with: URI::regexp(%w(http https)), message: "should be a valid url" }, if: :home_page_url_column_exist -- cgit v1.2.1 From ce08f919bfab73178b2f8c584f34fd8849834365 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 13 Feb 2015 12:02:17 +0100 Subject: Add link to share via twitter to "created project" event. --- app/models/application_setting.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 6d4e220b16c..f1d918e5457 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -8,6 +8,7 @@ # signup_enabled :boolean # signin_enabled :boolean # gravatar_enabled :boolean +# twitter_sharing_enabled :boolean # sign_in_text :text # created_at :datetime # updated_at :datetime @@ -30,6 +31,7 @@ class ApplicationSetting < ActiveRecord::Base default_branch_protection: Settings.gitlab['default_branch_protection'], signup_enabled: Settings.gitlab['signup_enabled'], signin_enabled: Settings.gitlab['signin_enabled'], + twitter_sharing_enabled: Settings.gitlab['twitter_sharing_enabled'], gravatar_enabled: Settings.gravatar['enabled'], sign_in_text: Settings.extra['sign_in_text'], ) -- cgit v1.2.1