Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authortiagonbotelho <tiagonbotelho@hotmail.com>2016-08-28 12:41:31 +0300
committertiagonbotelho <tiagonbotelho@hotmail.com>2016-08-31 21:02:21 +0300
commitf12e9cb0d6384ef742ed4c712909df3e31c2c892 (patch)
tree0e2a71f6266fb0e52bc46164b14f20c3ad6f3c1c /app
parentcf852ecf870cabdb98527fee1c4d16767eee07ba (diff)
adds migration and controller updating for repository_size_limit
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/application_settings_controller.rb2
-rw-r--r--app/models/application_setting.rb4
-rw-r--r--app/models/project.rb9
-rw-r--r--app/views/admin/application_settings/_form.html.haml5
4 files changed, 15 insertions, 5 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index be483459f70..42e5a288710 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -118,7 +118,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:container_registry_token_expire_delay,
:repository_storage,
:enabled_git_access_protocol,
- :project_size_limit,
+ :repository_size_limit,
restricted_visibility_levels: [],
import_sources: [],
disabled_oauth_sign_in_sources: []
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 36d8bfa36ef..73c4d639335 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -63,9 +63,9 @@ class ApplicationSetting < ActiveRecord::Base
presence: true,
numericality: { only_integer: true, greater_than: 0 }
- validates :project_size_limit,
+ validates :repository_size_limit,
presence: true,
- numericality: { only_integer: true, greater_than: 0 }
+ numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :container_registry_token_expire_delay,
presence: true,
diff --git a/app/models/project.rb b/app/models/project.rb
index e5027af4a0e..41122caf4ae 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1286,6 +1286,15 @@ class Project < ActiveRecord::Base
end
end
+ def above_size_limit?
+ return false if current_application_settings.repository_size_limit == 0
+ repository_size >= current_application_settings.repository_size_limit
+ end
+
+ def size_to_remove
+ return repository_size - current_application_settings.repository_size_limit
+ end
+
private
def default_branch_protected?
diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml
index 7410e6d883e..e8dde039c1b 100644
--- a/app/views/admin/application_settings/_form.html.haml
+++ b/app/views/admin/application_settings/_form.html.haml
@@ -89,9 +89,10 @@
.col-sm-10
= f.number_field :max_attachment_size, class: 'form-control'
.form-group
- = f.label :project_size_limit, 'Project size limit (MB)', class: 'control-label col-sm-2'
+ = f.label :repository_size_limit, 'Repository size limit (MB)', class: 'control-label col-sm-2'
.col-sm-10
- = f.number_field :project_size_limit, class: 'form-control'
+ = f.number_field :repository_size_limit, class: 'form-control'
+ %span.help-block#repository_size_limit_help_block This limit is per repository. This includes LFS storage. 0 for unlimited
.form-group
= f.label :session_expire_delay, 'Session duration (minutes)', class: 'control-label col-sm-2'
.col-sm-10