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