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
5615f039
Commit
5615f039
authored
May 12, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak text.
parent
3f323725
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
15 deletions
+21
-15
app/models/license.rb
app/models/license.rb
+12
-8
app/views/admin/licenses/show.html.haml
app/views/admin/licenses/show.html.haml
+9
-7
No files found.
app/models/license.rb
View file @
5615f039
class
License
<
ActiveRecord
::
Base
include
ActionView
::
Helpers
::
NumberHelper
validate
:valid_license
validate
:active_user_count
,
unless: :persisted?
validate
:not_expired
,
unless: :persisted?
...
...
@@ -87,32 +89,34 @@ class License < ActiveRecord::Base
def
valid_license
return
if
license?
self
.
errors
.
add
(
:base
,
"The license file is invalid. Make sure it is exactly as you received it from GitLab B.V."
)
self
.
errors
.
add
(
:base
,
"The license file is invalid. Make sure it is exactly as you received it from GitLab B.V.
.
"
)
end
def
active_user_count
return
unless
self
.
license?
&&
self
.
restricted?
(
:active_user_count
)
restricted_user_count
=
self
.
restrictions
[
:active_user_count
]
active_user_count
=
User
.
active
.
count
active_user_count
=
1050
;
User
.
active
.
count
historical_active_user_count
=
HistoricalData
.
maximum
(
:active_user_count
)
||
0
max_active_user_count
=
[
active_user_count
,
historical_active_user_count
].
max
return
if
max_active_user_count
<
restricted_user_count
too_many
=
max_active_user_count
-
restricted_user_count
overage
=
max_active_user_count
-
restricted_user_count
message
=
"
This license allows
#{
restricted_user_count
}
active users.
"
message
=
""
message
<<
if
historical_active_user_count
>
active_user_count
"At one point, this GitLab installation had "
else
"
Currently, t
his GitLab installation has "
"
T
his GitLab installation has "
end
message
<<
"
#{
max_active_user_count
}
active users, "
message
<<
"i.e.
#{
too_many
}
too many. "
message
<<
"Please upload a license for at least
#{
max_active_user_count
}
users."
message
<<
"
#{
number_with_delimiter
max_active_user_count
}
active
#{
"user"
.
pluralize
(
max_active_user_count
)
}
, "
message
<<
"exceeding this license's limit of
#{
number_with_delimiter
restricted_user_count
}
by "
message
<<
"
#{
number_with_delimiter
overage
}
#{
"user"
.
pluralize
(
overage
)
}
. "
message
<<
"Please upload a license for at least "
message
<<
"
#{
number_with_delimiter
max_active_user_count
}
#{
"user"
.
pluralize
(
max_active_user_count
)
}
."
self
.
errors
.
add
(
:base
,
message
)
end
...
...
app/views/admin/licenses/show.html.haml
View file @
5615f039
...
...
@@ -47,33 +47,35 @@
Users
%ul
.well-list
%li
%span
.light
License
d users
:
%span
.light
License
limit
:
%strong
-
if
@license
.
restricted?
(
:active_user_count
)
-
restricted
=
@license
.
restrictions
[
:active_user_count
]
#{
restricted
}
users
#{
number_with_delimiter
restricted
}
#{
"users"
.
pluralize
(
restricted
)
}
-
else
Unlimited
%li
%span
.light
Current active users:
%strong
-
current
=
User
.
active
.
count
#{
current
}
users
#{
number_with_delimiter
current
}
#{
"users"
.
pluralize
(
current
)
}
-
if
restricted
&&
current
>
restricted
%span
.label.label-danger.pull-right
%strong
Exceeds license
%strong
Exceeds license limit
-
historical
=
HistoricalData
.
maximum
(
:active_user_count
)
-
historical
=
1050
;
HistoricalData
.
maximum
(
:active_user_count
)
-
if
historical
%li
%span
.light
Maximum active users:
%strong
#{
historical
}
users
#{
number_with_delimiter
historical
}
#{
"users"
.
pluralize
(
historical
)
}
-
if
restricted
&&
historical
>
restricted
%span
.label.label-danger.pull-right
%strong
Exceeds licensed amount
%strong
Exceeds license limit
.col-md-6
.panel.panel-info
...
...
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