Commit 5bc07b2ad82492e8438f07363337bb5e80a22dfb
Exists in
master
and in
4 other branches
Merge pull request #5116 from karlhungus/feature-configurable-theme
Make users theme configurable
Showing
4 changed files
with
22 additions
and
10 deletions
Show diff stats
app/models/user.rb
| @@ -211,7 +211,7 @@ class User < ActiveRecord::Base | @@ -211,7 +211,7 @@ class User < ActiveRecord::Base | ||
| 211 | { | 211 | { |
| 212 | projects_limit: Gitlab.config.gitlab.default_projects_limit, | 212 | projects_limit: Gitlab.config.gitlab.default_projects_limit, |
| 213 | can_create_group: Gitlab.config.gitlab.default_can_create_group, | 213 | can_create_group: Gitlab.config.gitlab.default_can_create_group, |
| 214 | - theme_id: Gitlab::Theme::MARS | 214 | + theme_id: Gitlab.config.gitlab.default_theme |
| 215 | } | 215 | } |
| 216 | end | 216 | end |
| 217 | end | 217 | end |
config/gitlab.yml.example
| @@ -42,6 +42,14 @@ production: &base | @@ -42,6 +42,14 @@ production: &base | ||
| 42 | default_projects_limit: 10 | 42 | default_projects_limit: 10 |
| 43 | # default_can_create_group: false # default: true | 43 | # default_can_create_group: false # default: true |
| 44 | # username_changing_enabled: false # default: true - User can change her username/namespace | 44 | # username_changing_enabled: false # default: true - User can change her username/namespace |
| 45 | + ## Default theme | ||
| 46 | + ## BASIC = 1 | ||
| 47 | + ## MARS = 2 | ||
| 48 | + ## MODERN = 3 | ||
| 49 | + ## GRAY = 4 | ||
| 50 | + ## COLOR = 5 | ||
| 51 | + # default_theme: 2 # default: 2 | ||
| 52 | + | ||
| 45 | 53 | ||
| 46 | ## Users management | 54 | ## Users management |
| 47 | # signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled. | 55 | # signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled. |
config/initializers/1_settings.rb
| @@ -52,6 +52,7 @@ Settings['issues_tracker'] ||= {} | @@ -52,6 +52,7 @@ Settings['issues_tracker'] ||= {} | ||
| 52 | Settings['gitlab'] ||= Settingslogic.new({}) | 52 | Settings['gitlab'] ||= Settingslogic.new({}) |
| 53 | Settings.gitlab['default_projects_limit'] ||= 10 | 53 | Settings.gitlab['default_projects_limit'] ||= 10 |
| 54 | Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil? | 54 | Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil? |
| 55 | +Settings.gitlab['default_theme'] = Gitlab::Theme::MARS if Settings.gitlab['default_theme'].nil? | ||
| 55 | Settings.gitlab['host'] ||= 'localhost' | 56 | Settings.gitlab['host'] ||= 'localhost' |
| 56 | Settings.gitlab['https'] = false if Settings.gitlab['https'].nil? | 57 | Settings.gitlab['https'] = false if Settings.gitlab['https'].nil? |
| 57 | Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80 | 58 | Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80 |
spec/models/user_spec.rb
| @@ -221,9 +221,9 @@ describe User do | @@ -221,9 +221,9 @@ describe User do | ||
| 221 | let(:user) { User.build_user({}, as: :admin) } | 221 | let(:user) { User.build_user({}, as: :admin) } |
| 222 | 222 | ||
| 223 | it "should apply defaults to user" do | 223 | it "should apply defaults to user" do |
| 224 | - user.projects_limit.should == 42 | ||
| 225 | - user.can_create_group.should be_false | ||
| 226 | - user.theme_id.should == Gitlab::Theme::MARS | 224 | + user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit |
| 225 | + user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group | ||
| 226 | + user.theme_id.should == Gitlab.config.gitlab.default_theme | ||
| 227 | end | 227 | end |
| 228 | end | 228 | end |
| 229 | 229 | ||
| @@ -231,6 +231,9 @@ describe User do | @@ -231,6 +231,9 @@ describe User do | ||
| 231 | let(:user) { User.build_user({projects_limit: 123, can_create_group: true, can_create_team: true, theme_id: Gitlab::Theme::BASIC}, as: :admin) } | 231 | let(:user) { User.build_user({projects_limit: 123, can_create_group: true, can_create_team: true, theme_id: Gitlab::Theme::BASIC}, as: :admin) } |
| 232 | 232 | ||
| 233 | it "should apply defaults to user" do | 233 | it "should apply defaults to user" do |
| 234 | + Gitlab.config.gitlab.default_projects_limit.should_not == 123 | ||
| 235 | + Gitlab.config.gitlab.default_can_create_group.should_not be_true | ||
| 236 | + Gitlab.config.gitlab.default_theme.should_not == Gitlab::Theme::MARS | ||
| 234 | user.projects_limit.should == 123 | 237 | user.projects_limit.should == 123 |
| 235 | user.can_create_group.should be_true | 238 | user.can_create_group.should be_true |
| 236 | user.theme_id.should == Gitlab::Theme::BASIC | 239 | user.theme_id.should == Gitlab::Theme::BASIC |
| @@ -243,9 +246,9 @@ describe User do | @@ -243,9 +246,9 @@ describe User do | ||
| 243 | let(:user) { User.build_user } | 246 | let(:user) { User.build_user } |
| 244 | 247 | ||
| 245 | it "should apply defaults to user" do | 248 | it "should apply defaults to user" do |
| 246 | - user.projects_limit.should == 42 | ||
| 247 | - user.can_create_group.should be_false | ||
| 248 | - user.theme_id.should == Gitlab::Theme::MARS | 249 | + user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit |
| 250 | + user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group | ||
| 251 | + user.theme_id.should == Gitlab.config.gitlab.default_theme | ||
| 249 | end | 252 | end |
| 250 | end | 253 | end |
| 251 | 254 | ||
| @@ -253,9 +256,9 @@ describe User do | @@ -253,9 +256,9 @@ describe User do | ||
| 253 | let(:user) { User.build_user(projects_limit: 123, can_create_group: true, theme_id: Gitlab::Theme::BASIC) } | 256 | let(:user) { User.build_user(projects_limit: 123, can_create_group: true, theme_id: Gitlab::Theme::BASIC) } |
| 254 | 257 | ||
| 255 | it "should apply defaults to user" do | 258 | it "should apply defaults to user" do |
| 256 | - user.projects_limit.should == 42 | ||
| 257 | - user.can_create_group.should be_false | ||
| 258 | - user.theme_id.should == Gitlab::Theme::MARS | 259 | + user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit |
| 260 | + user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group | ||
| 261 | + user.theme_id.should == Gitlab.config.gitlab.default_theme | ||
| 259 | end | 262 | end |
| 260 | end | 263 | end |
| 261 | end | 264 | end |