diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-07-27 11:22:35 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-07-27 11:22:35 +0200 |
commit | 0be6debb0b3350f35bf4b6a904c60da826314b3b (patch) | |
tree | 5a9281db4a97d8ffa8f3efc73e17fb0b11b17aef /lib/api | |
parent | d371331a65070ce5b3ab9c210eac697062170c91 (diff) | |
parent | cd6046e1dd347f3a9bd7d062447aa25306a5755b (diff) | |
download | gitlab-ce-0be6debb0b3350f35bf4b6a904c60da826314b3b.tar.gz |
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq into backup-archive-permissions
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/entities.rb | 23 | ||||
-rw-r--r-- | lib/api/groups.rb | 4 | ||||
-rw-r--r-- | lib/api/settings.rb | 35 |
4 files changed, 61 insertions, 2 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index d2a35c78fc1..eebd44ea5b6 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -49,5 +49,6 @@ module API mount Namespaces mount Branches mount Labels + mount Settings end end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 14a8f929d76..ecf1412dee5 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -171,6 +171,7 @@ module API expose :source_project_id, :target_project_id expose :label_names, as: :labels expose :description + expose :work_in_progress?, as: :work_in_progress expose :milestone, using: Entities::Milestone end @@ -277,5 +278,27 @@ module API class BroadcastMessage < Grape::Entity expose :message, :starts_at, :ends_at, :color, :font end + + class ApplicationSetting < Grape::Entity + expose :id + expose :default_projects_limit + expose :signup_enabled + expose :signin_enabled + expose :gravatar_enabled + expose :sign_in_text + expose :created_at + expose :updated_at + expose :home_page_url + expose :default_branch_protection + expose :twitter_sharing_enabled + expose :restricted_visibility_levels + expose :max_attachment_size + expose :session_expire_delay + expose :default_project_visibility + expose :default_snippet_visibility + expose :restricted_signup_domains + expose :user_oauth_applications + expose :after_sign_out_path + end end end diff --git a/lib/api/groups.rb b/lib/api/groups.rb index e88b6e31775..024aeec2e14 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -74,9 +74,9 @@ module API # POST /groups/:id/projects/:project_id post ":id/projects/:project_id" do authenticated_as_admin! - group = Group.find(params[:id]) + group = Group.find_by(id: params[:id]) project = Project.find(params[:project_id]) - result = ::Projects::TransferService.new(project, current_user, namespace_id: group.id).execute + result = ::Projects::TransferService.new(project, current_user).execute(group) if result present group diff --git a/lib/api/settings.rb b/lib/api/settings.rb new file mode 100644 index 00000000000..c885fcd7ea3 --- /dev/null +++ b/lib/api/settings.rb @@ -0,0 +1,35 @@ +module API + class Settings < Grape::API + before { authenticated_as_admin! } + + helpers do + def current_settings + @current_setting ||= + (ApplicationSetting.current || ApplicationSetting.create_from_defaults) + end + end + + # Get current applicaiton settings + # + # Example Request: + # GET /application/settings + get "application/settings" do + present current_settings, with: Entities::ApplicationSetting + end + + # Modify applicaiton settings + # + # Example Request: + # PUT /application/settings + put "application/settings" do + attributes = current_settings.attributes.keys - ["id"] + attrs = attributes_for_keys(attributes) + + if current_settings.update_attributes(attrs) + present current_settings, with: Entities::ApplicationSetting + else + render_validation_error!(current_settings) + end + end + end +end |