mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 21:21:50 +08:00
Merge pull request #1132 from okriuchykhin/ok_SCI_2301
Move REPOSITORIES_LIMIT from constants to env variables [SCI-2301]
This commit is contained in:
commit
3b4d9fe744
5 changed files with 11 additions and 7 deletions
|
@ -44,7 +44,8 @@ class AtWhoController < ApplicationController
|
|||
end
|
||||
|
||||
def repositories
|
||||
repositories = @team.repositories.limit(Constants::REPOSITORIES_LIMIT)
|
||||
repositories =
|
||||
@team.repositories.limit(Rails.configuration.x.repositories_limit)
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {
|
||||
|
|
|
@ -300,8 +300,10 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def check_create_permissions
|
||||
render_403 unless can_create_repositories?(@team) ||
|
||||
@team.repositories.count < Constants::REPOSITORIES_LIMIT
|
||||
unless can_create_repositories?(@team) ||
|
||||
@team.repositories.count < Rails.configuration.x.repositories_limit
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def check_manage_permissions
|
||||
|
|
|
@ -44,7 +44,7 @@ Canaid::Permissions.register_for(Team) do
|
|||
# repository: create, copy
|
||||
can :create_repositories do |user, team|
|
||||
user.is_admin_of_team?(team) &&
|
||||
team.repositories.count < Constants::REPOSITORIES_LIMIT
|
||||
team.repositories.count < Rails.configuration.x.repositories_limit
|
||||
end
|
||||
|
||||
# repository: create/import record
|
||||
|
|
|
@ -58,9 +58,6 @@ class Constants
|
|||
# Max characters for repository name in Atwho modal
|
||||
ATWHO_REP_NAME_LIMIT = 16
|
||||
|
||||
# Maximum number of repositories per team allowed
|
||||
REPOSITORIES_LIMIT = 5
|
||||
|
||||
#=============================================================================
|
||||
# File and data memory size
|
||||
#=============================================================================
|
||||
|
|
4
config/initializers/repositories.rb
Normal file
4
config/initializers/repositories.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
Rails.application.configure do
|
||||
# Maximum number of repositories per team allowed
|
||||
config.x.repositories_limit = ENV['REPOSITORIES_LIMIT'].to_i || 5
|
||||
end
|
Loading…
Reference in a new issue