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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
10e6aa62
Commit
10e6aa62
authored
May 05, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate number of active users at time of upload.
parent
bff1b8f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
app/models/license.rb
app/models/license.rb
+17
-1
No files found.
app/models/license.rb
View file @
10e6aa62
class
License
<
ActiveRecord
::
Base
validates
:data
,
presence:
true
validate
:valid_license
validate
:active_user_count
,
unless: :persisted?
before_validation
:reset_license
,
if: :data_changed?
...
...
@@ -50,6 +51,10 @@ class License < ActiveRecord::Base
@license
||=
Gitlab
::
License
.
import
(
self
.
data
)
end
def
license?
self
.
license
&&
self
.
license
.
valid?
end
def
method_missing
(
method_name
,
*
arguments
,
&
block
)
if
License
.
column_names
.
include?
(
method_name
.
to_s
)
super
...
...
@@ -88,9 +93,20 @@ class License < ActiveRecord::Base
end
def
valid_license
return
if
self
.
license
&&
self
.
license
.
valid
?
return
if
license
?
# TODO: Clearer message
self
.
errors
.
add
(
:license
,
"is invalid."
)
end
def
active_user_count
return
unless
self
.
license?
&&
self
.
restricted?
(
:active_user_count
)
restricted_user_count
=
@license
.
restrictions
[
:active_user_count
]
active_user_count
=
User
.
active
.
count
return
if
active_user_count
<=
restricted_user_count
self
.
errors
.
add
(
:base
,
"This license allows
#{
restricted_user_count
}
active users. This GitLab installation currently has
#{
active_user_count
}
, i.e.
#{
active_user_count
-
restricted_user_count
}
too many."
)
end
end
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