Commit d00eb7e2 authored by Douwe Maan's avatar Douwe Maan

Tweak presentation and error around historical user count.

parent 4ffa34a4
......@@ -5,7 +5,6 @@ class Admin::LicensesController < Admin::ApplicationController
respond_to :html
def show
@historical_active_user_count = HistoricalData.during(license.issued_at..Date.today).maximum(:active_user_count)
@previous_licenses = License.previous
end
......
......@@ -95,27 +95,26 @@ class License < ActiveRecord::Base
restricted_user_count = self.restrictions[:active_user_count]
active_user_count = User.active.count
historical_active_user_count = HistoricalData.maximum(:active_user_count) || 0
if active_user_count > restricted_user_count
message = "This license allows #{restricted_user_count} active users. "
message << "This GitLab installation currently has #{active_user_count}, "
message << "i.e. #{active_user_count - restricted_user_count} too many."
max_active_user_count = [active_user_count, historical_active_user_count].max
self.errors.add(:base, message)
return
end
return if max_active_user_count < restricted_user_count
if License.current
historical_active_user_count = HistoricalData.during(License.current.issued_at..Date.today).maximum(:active_user_count)
too_many = max_active_user_count - restricted_user_count
if historical_active_user_count && historical_active_user_count > restricted_user_count
message = "This license allows #{restricted_user_count} active users. "
message << "At one point during the life of the previous license, this GitLab installation had "
message << "#{historical_active_user_count} active users, "
message << "i.e. #{historical_active_user_count - restricted_user_count} too many."
self.errors.add(:base, message)
message = "This license allows #{restricted_user_count} active users. "
message <<
if historical_active_user_count > active_user_count
"At one point, this GitLab installation had "
else
"Currently, this GitLab installation has "
end
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."
self.errors.add(:base, message)
end
def not_expired
......
......@@ -35,38 +35,45 @@
%strong
- if @license.will_expire?
= time_ago_with_tooltip @license.expires_at
- if @license.expired?
%span.label.label-danger.pull-right
%strong Expired
- else
Never
- if @license.expired?
%span.label.label-danger.pull-right
%strong Expired
.panel.panel-default
.panel-heading
Restrictions
Users
%ul.well-list
%li
%span.light Active users:
%span.light Licensed users:
%strong
- if @license.restricted?(:active_user_count)
- restricted = @license.restrictions[:active_user_count]
- current = User.active.count
- historical = @historical_active_user_count
#{restricted} users
- else
Unlimited
%li
%span.light Current active users:
%strong
- current = User.active.count
#{current} users
- if historical && historical > restricted && current < restricted
%span.label.label-danger.pull-right.prepend-left-10
%strong
Maximum during license life: #{historical} users
- if restricted && current > restricted
%span.label.label-danger.pull-right
%strong Exceeds license
- label_class = current > restricted ? "danger" : restricted > current ? "success" : "info"
%span.label.pull-right{class: "label-#{label_class}"}
%strong
Current: #{current} users
- historical = HistoricalData.maximum(:active_user_count)
- if historical
%li
%span.light Maximum active users:
%strong
#{historical} users
- else
Unlimited
- if restricted && historical > restricted
%span.label.label-danger.pull-right
%strong Exceeds license
.col-md-6
.panel.panel-info
......
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