Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
8589b4e1
Commit
8589b4e1
authored
Jan 08, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Init ApplicationSettings resource with defaults from config file
parent
d02a22ba
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
144 additions
and
7 deletions
+144
-7
app/controllers/admin/application_settings_controller.rb
app/controllers/admin/application_settings_controller.rb
+31
-0
app/controllers/registrations_controller.rb
app/controllers/registrations_controller.rb
+3
-1
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+8
-0
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+2
-0
app/models/application_setting.rb
app/models/application_setting.rb
+5
-0
app/services/gravatar_service.rb
app/services/gravatar_service.rb
+1
-1
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+29
-0
app/views/admin/application_settings/edit.html.haml
app/views/admin/application_settings/edit.html.haml
+5
-0
app/views/admin/application_settings/show.html.haml
app/views/admin/application_settings/show.html.haml
+18
-0
app/views/devise/sessions/new.html.haml
app/views/devise/sessions/new.html.haml
+1
-1
app/views/devise/shared/_signin_box.html.haml
app/views/devise/shared/_signin_box.html.haml
+3
-3
config/initializers/8_application_settings.rb
config/initializers/8_application_settings.rb
+12
-0
config/routes.rb
config/routes.rb
+2
-0
db/migrate/20150108073740_create_application_settings.rb
db/migrate/20150108073740_create_application_settings.rb
+13
-0
db/schema.rb
db/schema.rb
+11
-1
No files found.
app/controllers/admin/application_settings_controller.rb
0 → 100644
View file @
8589b4e1
class
Admin::ApplicationSettingsController
<
Admin
::
ApplicationController
before_filter
:set_application_setting
def
show
end
def
edit
end
def
update
@application_setting
.
update_attributes
(
application_setting_params
)
redirect_to
admin_application_settings_path
end
private
def
set_application_setting
@application_setting
=
ApplicationSetting
.
last
end
def
application_setting_params
params
.
require
(
:application_setting
).
permit
(
:default_projects_limit
,
:signup_enabled
,
:signin_enabled
,
:gravatar_enabled
,
:sign_in_text
,
)
end
end
app/controllers/registrations_controller.rb
View file @
8589b4e1
...
@@ -26,7 +26,9 @@ class RegistrationsController < Devise::RegistrationsController
...
@@ -26,7 +26,9 @@ class RegistrationsController < Devise::RegistrationsController
private
private
def
signup_enabled?
def
signup_enabled?
redirect_to
new_user_session_path
unless
Gitlab
.
config
.
gitlab
.
signup_enabled
unless
ApplicationSetting
.
current
.
signup_enabled
redirect_to
new_user_session_path
end
end
end
def
sign_up_params
def
sign_up_params
...
...
app/helpers/application_helper.rb
View file @
8589b4e1
...
@@ -310,4 +310,12 @@ module ApplicationHelper
...
@@ -310,4 +310,12 @@ module ApplicationHelper
request
.
env
[
'rack.session'
][
'user_return_to'
]
==
request
.
env
[
'rack.session'
][
'user_return_to'
]
==
'/'
'/'
end
end
def
signup_enabled?
ApplicationSetting
.
current
.
signup_enabled
end
def
signin_enabled?
ApplicationSetting
.
current
.
signin_enabled
end
end
end
app/helpers/application_settings_helper.rb
0 → 100644
View file @
8589b4e1
module
ApplicationSettingsHelper
end
app/models/application_setting.rb
0 → 100644
View file @
8589b4e1
class
ApplicationSetting
<
ActiveRecord
::
Base
def
self
.
current
ApplicationSetting
.
last
end
end
app/services/gravatar_service.rb
View file @
8589b4e1
class
GravatarService
class
GravatarService
def
execute
(
email
,
size
=
nil
)
def
execute
(
email
,
size
=
nil
)
if
gravatar_config
.
enabled
&&
email
.
present?
if
ApplicationSetting
.
current
.
gravatar_
enabled
&&
email
.
present?
size
=
40
if
size
.
nil?
||
size
<=
0
size
=
40
if
size
.
nil?
||
size
<=
0
sprintf
gravatar_url
,
sprintf
gravatar_url
,
...
...
app/views/admin/application_settings/_form.html.haml
0 → 100644
View file @
8589b4e1
=
form_for
@application_setting
,
url:
admin_application_settings_path
,
html:
{
class:
'form-horizontal fieldset-form'
}
do
|
f
|
-
if
@application_setting
.
errors
.
any?
#error_explanation
.alert.alert-danger
-
@application_setting
.
errors
.
full_messages
.
each
do
|
msg
|
%p
=
msg
.form-group
=
f
.
label
:default_projects_limit
,
class:
'control-label'
.col-sm-10
=
f
.
number_field
:default_projects_limit
,
class:
'form-control'
.form-group
=
f
.
label
:signup_enabled
,
class:
'control-label'
.col-sm-10
=
f
.
check_box
:signup_enabled
,
class:
'checkbox'
.form-group
=
f
.
label
:signin_enabled
,
class:
'control-label'
.col-sm-10
=
f
.
check_box
:signin_enabled
,
class:
'checkbox'
.form-group
=
f
.
label
:gravatar_enabled
,
class:
'control-label'
.col-sm-10
=
f
.
check_box
:gravatar_enabled
,
class:
'checkbox'
.form-group
=
f
.
label
:sign_in_text
,
class:
'control-label'
.col-sm-10
=
f
.
text_area
:sign_in_text
,
class:
'form-control'
.form-actions
=
f
.
submit
'Save'
,
class:
'btn btn-primary'
app/views/admin/application_settings/edit.html.haml
0 → 100644
View file @
8589b4e1
%h1
Editing application_setting
=
render
'form'
=
link_to
'Back'
,
admin_application_settings_path
app/views/admin/application_settings/show.html.haml
0 → 100644
View file @
8589b4e1
%table
.table
%tr
%td
Default projects limit:
%td
=
@application_setting
.
default_projects_limit
%tr
%td
Signup enabled:
%td
=
@application_setting
.
signup_enabled
%tr
%td
Signin enabled:
%td
=
@application_setting
.
signin_enabled
%tr
%td
Gravatar enabled:
%td
=
@application_setting
.
gravatar_enabled
%tr
%td
Sign in text:
%td
=
@application_setting
.
sign_in_text
=
link_to
'Edit'
,
edit_admin_application_settings_path
app/views/devise/sessions/new.html.haml
View file @
8589b4e1
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
.prepend-top-20
.prepend-top-20
=
render
'devise/shared/oauth_box'
=
render
'devise/shared/oauth_box'
-
if
gitlab_config
.
signup_enabled
-
if
signup_enabled?
.prepend-top-20
.prepend-top-20
=
render
'devise/shared/signup_box'
=
render
'devise/shared/signup_box'
...
...
app/views/devise/shared/_signin_box.html.haml
View file @
8589b4e1
...
@@ -7,18 +7,18 @@
...
@@ -7,18 +7,18 @@
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
%li
{
class:
(
:active
if
i
.
zero?
)}
%li
{
class:
(
:active
if
i
.
zero?
)}
=
link_to
server
[
'label'
],
"#tab-
#{
server
[
'provider_name'
]
}
"
,
'data-toggle'
=>
'tab'
=
link_to
server
[
'label'
],
"#tab-
#{
server
[
'provider_name'
]
}
"
,
'data-toggle'
=>
'tab'
-
if
gitlab_config
.
signin_enabled
-
if
signin_enabled?
%li
%li
=
link_to
'Standard'
,
'#tab-signin'
,
'data-toggle'
=>
'tab'
=
link_to
'Standard'
,
'#tab-signin'
,
'data-toggle'
=>
'tab'
.tab-content
.tab-content
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
%div
.tab-pane
{
id:
"tab-#{server['provider_name']}"
,
class:
(
:active
if
i
.
zero?
)}
%div
.tab-pane
{
id:
"tab-#{server['provider_name']}"
,
class:
(
:active
if
i
.
zero?
)}
=
render
'devise/sessions/new_ldap'
,
provider:
server
[
'provider_name'
]
=
render
'devise/sessions/new_ldap'
,
provider:
server
[
'provider_name'
]
-
if
gitlab_config
.
signin_enabled
-
if
signin_enabled?
%div
#tab-signin
.tab-pane
%div
#tab-signin
.tab-pane
=
render
'devise/sessions/new_base'
=
render
'devise/sessions/new_base'
-
elsif
gitlab_config
.
signin_enabled
-
elsif
signin_enabled?
=
render
'devise/sessions/new_base'
=
render
'devise/sessions/new_base'
-
else
-
else
%div
%div
...
...
config/initializers/8_application_settings.rb
0 → 100644
View file @
8589b4e1
begin
unless
ApplicationSetting
.
any?
ApplicationSetting
.
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
rescue
end
config/routes.rb
View file @
8589b4e1
...
@@ -109,6 +109,8 @@ Gitlab::Application.routes.draw do
...
@@ -109,6 +109,8 @@ Gitlab::Application.routes.draw do
end
end
end
end
resource
:application_settings
root
to:
"dashboard#index"
root
to:
"dashboard#index"
end
end
...
...
db/migrate/20150108073740_create_application_settings.rb
0 → 100644
View file @
8589b4e1
class
CreateApplicationSettings
<
ActiveRecord
::
Migration
def
change
create_table
:application_settings
do
|
t
|
t
.
integer
:default_projects_limit
t
.
boolean
:signup_enabled
t
.
boolean
:signin_enabled
t
.
boolean
:gravatar_enabled
t
.
text
:sign_in_text
t
.
timestamps
end
end
end
db/schema.rb
View file @
8589b4e1
...
@@ -11,11 +11,21 @@
...
@@ -11,11 +11,21 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201
41226080412
)
do
ActiveRecord
::
Schema
.
define
(
version:
201
50108073740
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
create_table
"application_settings"
,
force:
true
do
|
t
|
t
.
integer
"default_projects_limit"
t
.
boolean
"signup_enabled"
t
.
boolean
"signin_enabled"
t
.
boolean
"gravatar_enabled"
t
.
text
"sign_in_text"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
end
create_table
"broadcast_messages"
,
force:
true
do
|
t
|
create_table
"broadcast_messages"
,
force:
true
do
|
t
|
t
.
text
"message"
,
null:
false
t
.
text
"message"
,
null:
false
t
.
datetime
"starts_at"
t
.
datetime
"starts_at"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment