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

Minor tweaks.

parent d1f2b09f
...@@ -5,7 +5,7 @@ class Admin::LicensesController < Admin::ApplicationController ...@@ -5,7 +5,7 @@ class Admin::LicensesController < Admin::ApplicationController
respond_to :html respond_to :html
def show def show
@previous_licenses = License.all.to_a[0..-2].reverse @previous_licenses = License.previous
end end
def download def download
...@@ -17,12 +17,11 @@ class Admin::LicensesController < Admin::ApplicationController ...@@ -17,12 +17,11 @@ class Admin::LicensesController < Admin::ApplicationController
end end
def create def create
@license = License.new @license = License.new(license_params)
@license.data_file = license_params[:data_file]
respond_with(@license, location: admin_license_path) do respond_with(@license, location: admin_license_path) do
if @license.save 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 end
end end
...@@ -30,7 +29,9 @@ class Admin::LicensesController < Admin::ApplicationController ...@@ -30,7 +29,9 @@ class Admin::LicensesController < Admin::ApplicationController
def destroy def destroy
license.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 end
private private
......
...@@ -78,7 +78,7 @@ class Ability ...@@ -78,7 +78,7 @@ class Ability
def project_abilities(user, project) def project_abilities(user, project)
rules = [] rules = []
key = "/user/#{user.id}/project/#{project.id}" key = "/user/#{user.id}/project/#{project.id}"
rules = RequestStore.store[key] ||= begin RequestStore.store[key] ||= begin
team = project.team team = project.team
# Rules based on role in project # Rules based on role in project
......
...@@ -7,6 +7,8 @@ class License < ActiveRecord::Base ...@@ -7,6 +7,8 @@ class License < ActiveRecord::Base
after_create :reset_current after_create :reset_current
after_destroy :reset_current after_destroy :reset_current
scope :previous, -> { order(created_at: :desc).offset(1) }
class << self class << self
def current def current
return @current if @current return @current if @current
...@@ -27,7 +29,8 @@ class License < ActiveRecord::Base ...@@ -27,7 +29,8 @@ class License < ActiveRecord::Base
end end
def data_filename 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" "#{clean_company_name}.gitlab-license"
end end
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
.form-group .form-group
= f.label :data_file, "License", class: 'control-label col-sm-2' = f.label :data_file, "License", class: 'control-label col-sm-2'
.col-sm-10 .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 .form-actions
= f.submit 'Upload', class: 'btn btn-primary' = f.submit 'Upload', class: 'btn btn-primary'
%h3.page-title %h3.page-title
Your License 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 %hr
...@@ -26,7 +26,11 @@ ...@@ -26,7 +26,11 @@
%span.light Uploaded: %span.light Uploaded:
%strong= time_ago_with_tooltip @license.created_at %strong= time_ago_with_tooltip @license.created_at
%li %li
%span.light Expires: %span.light
- if @license.expired?
Expired:
- else
Expires:
%strong %strong
- if @license.will_expire? - if @license.will_expire?
= time_ago_with_tooltip @license.expires_at = time_ago_with_tooltip @license.expires_at
...@@ -66,8 +70,8 @@ ...@@ -66,8 +70,8 @@
.panel-heading .panel-heading
Download license Download license
.panel-body .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 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, 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 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 %br
= link_to 'Download license', download_admin_license_path, class: "btn btn-info" = link_to 'Download license', download_admin_license_path, class: "btn btn-info"
...@@ -79,10 +83,10 @@ ...@@ -79,10 +83,10 @@
%p If you remove this license, GitLab will fall back on the previous license, if any. %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. %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 %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? - if @previous_licenses.any?
%h4 Previous Licenses %h4 License History
.panel.panel-default .panel.panel-default
%table.table %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