Commit c2ee6862 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

API to set application settings for admin

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent a6a0792e
......@@ -49,5 +49,6 @@ module API
mount Namespaces
mount Branches
mount Labels
mount Settings
end
end
......@@ -277,5 +277,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
module API
class Settings < Grape::API
before { authenticate! }
before { authorize_admin_project }
helpers do
def current_settings
@current_setting ||= ApplicationSetting.current
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
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