Commit 257f8057 authored by Douwe Maan's avatar Douwe Maan

Minor tweaks.

parent d1f2b09f
......@@ -5,7 +5,7 @@ class Admin::LicensesController < Admin::ApplicationController
respond_to :html
def show
@previous_licenses = License.all.to_a[0..-2].reverse
@previous_licenses = License.previous
end
def download
......@@ -17,12 +17,11 @@ class Admin::LicensesController < Admin::ApplicationController
end
def create
@license = License.new
@license.data_file = license_params[:data_file]
@license = License.new(license_params)
respond_with(@license, location: admin_license_path) do
if @license.save
flash[:notice] = "The license was successfully uploaded."
flash[:notice] = "The license was successfully uploaded. You can see the details below."
end
end
end
......@@ -30,7 +29,9 @@ class Admin::LicensesController < Admin::ApplicationController
def destroy
license.destroy
redirect_to admin_license_path, notice: "The license was removed."
message = "The license was removed."
redirect_to admin_license_path, notice: message
end
private
......
......@@ -78,7 +78,7 @@ class Ability
def project_abilities(user, project)
rules = []
key = "/user/#{user.id}/project/#{project.id}"
rules = RequestStore.store[key] ||= begin
RequestStore.store[key] ||= begin
team = project.team
# Rules based on role in project
......
......@@ -7,6 +7,8 @@ class License < ActiveRecord::Base
after_create :reset_current
after_destroy :reset_current
scope :previous, -> { order(created_at: :desc).offset(1) }
class << self
def current
return @current if @current
......@@ -27,7 +29,8 @@ class License < ActiveRecord::Base
end
def data_filename
clean_company_name = self.licensee.values.first.gsub(/[^A-Za-z0-9]/, "")
company_name = self.licensee["Company"] || self.licensee.values.first
clean_company_name = company_name.gsub(/[^A-Za-z0-9]/, "")
"#{clean_company_name}.gitlab-license"
end
......
......@@ -14,7 +14,7 @@
.form-group
= f.label :data_file, "License", class: 'control-label col-sm-2'
.col-sm-10
= f.file_field :data_file, accept: ".gitlab-license,.gitlab_license"
= f.file_field :data_file, accept: ".gitlab-license,.gitlab_license,.txt"
.form-actions
= f.submit 'Upload', class: 'btn btn-primary'
%h3.page-title
Your License
= link_to 'Upload License', new_admin_license_path, class: "btn btn-new pull-right"
= link_to 'Upload New License', new_admin_license_path, class: "btn btn-new pull-right"
%hr
......@@ -26,7 +26,11 @@
%span.light Uploaded:
%strong= time_ago_with_tooltip @license.created_at
%li
%span.light Expires:
%span.light
- if @license.expired?
Expired:
- else
Expires:
%strong
- if @license.will_expire?
= time_ago_with_tooltip @license.expires_at
......@@ -66,8 +70,8 @@
.panel-heading
Download license
.panel-body
%p Your license will be included in your GitLab backup and will survive upgrades, so in normal usage you should never need to re-upload your <code>.gitlab-license</code>.
%p Still, we recommend keeping it save somewhere, because if you ever need it and have lost it, you will need to request GitLab B.V. to send it to you again.
%p Your license will be included in your GitLab backup and will survive upgrades, so in normal usage you should never need to re-upload your <code>.gitlab-license</code> file.
%p Still, we recommend keeping it save somewhere. Otherwise, if you ever need it and have lost it, you will need to request GitLab B.V. to send it to you again.
%br
= link_to 'Download license', download_admin_license_path, class: "btn btn-info"
......@@ -79,10 +83,10 @@
%p If you remove this license, GitLab will fall back on the previous license, if any.
%p If there is no previous license or if the previous license has expired, some GitLab functionality will be blocked until a new, valid license is uploaded.
%br
= link_to 'Remove license', admin_license_path, data: { confirm: "LICENSE WILL BE REMOVED! Are you sure?" }, method: :delete, class: "btn btn-remove"
= link_to 'Remove license', admin_license_path, data: { confirm: "Are you sure you want to remove the license?" }, method: :delete, class: "btn btn-remove"
- if @previous_licenses.any?
%h4 Previous Licenses
%h4 License History
.panel.panel-default
%table.table
......
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