Commit 80a12e64 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'license-as-key' into 'master'

Allow license to be uploaded as text rather than file

RE gitlab-com/www-gitlab-com#423

See merge request !63
parents c2d03df8 531f3ac4
......@@ -206,7 +206,7 @@ gem 'request_store', '~> 1.2.0'
gem 'select2-rails', '~> 3.5.9'
gem 'virtus', '~> 1.0.1'
gem "gitlab-license", "~> 0.0.2"
gem "gitlab-license", "~> 0.0.4"
group :development do
gem "foreman"
......
......@@ -287,7 +287,7 @@ GEM
diff-lcs (~> 1.1)
mime-types (~> 1.15)
posix-spawn (~> 0.3)
gitlab-license (0.0.3)
gitlab-license (0.0.4)
gitlab_emoji (0.1.1)
gemojione (~> 2.0)
gitlab_git (7.2.20)
......@@ -840,7 +840,7 @@ DEPENDENCIES
github-linguist (~> 4.7.0)
github-markup (~> 1.3.1)
gitlab-flowdock-git-hook (~> 1.0.1)
gitlab-license (~> 0.0.2)
gitlab-license (~> 0.0.4)
gitlab_emoji (~> 0.1)
gitlab_git (~> 7.2.20)
gitlab_meta (= 7.0)
......
......@@ -61,3 +61,7 @@
@extend .broadcast-message;
margin-bottom: 20px;
}
.license-key-field {
font-family: monospace;
}
......@@ -63,6 +63,8 @@ class Admin::LicensesController < Admin::ApplicationController
end
def license_params
params.require(:license).permit(:data_file)
license_params = params.require(:license).permit(:data_file, :data)
license_params.delete(:data) if license_params[:data_file]
license_params
end
end
......@@ -44,7 +44,7 @@ class License < ActiveRecord::Base
def license
return nil unless self.data
@license ||=
@license ||=
begin
Gitlab::License.import(self.data)
rescue Gitlab::License::ImportError
......@@ -89,7 +89,7 @@ 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 key is invalid. Make sure it is exactly as you received it from GitLab Inc.")
end
def active_user_count
......@@ -99,7 +99,7 @@ class License < ActiveRecord::Base
date_range = (self.starts_at - 1.year)..self.starts_at
active_user_count = HistoricalData.during(date_range).maximum(:active_user_count) || 0
return unless active_user_count
return if active_user_count < restricted_user_count
......
......@@ -2,7 +2,7 @@
%h3.page-title Upload License
%p.light
To #{License.current ? "continue" : "start"} using GitLab Enterprise Edition, upload the <code>.gitlab-license</code> file you have received from GitLab B.V..
To #{License.current ? "continue" : "start"} using GitLab Enterprise Edition, upload the <code>.gitlab-license</code> file or enter the license key you have received from GitLab Inc.
%hr
= form_for @license, url: admin_license_path, html: { multipart: true, class: 'form-horizontal fieldset-form' } do |f|
......@@ -13,9 +13,46 @@
%p= msg
.form-group
= f.label :data_file, "License", class: 'control-label col-sm-2'
.col-sm-2
.col-sm-10
= f.file_field :data_file, accept: ".gitlab-license,.gitlab_license,.txt"
.radio
= label_tag :license_type_file do
= radio_button_tag :license_type, :file, @license.data.blank?
.option-title
Upload <code>.gitlab-license</code> file
.radio
= label_tag :license_type_key do
= radio_button_tag :license_type, :key, @license.data.present?
.option-title
Enter license key
.form-group.license-file
= f.label :data_file, "License file", class: 'control-label col-sm-2'
.col-sm-10
= f.file_field :data_file, accept: ".gitlab-license,.gitlab_license,.txt", class: "form-control"
.form-group.license-key
= f.label :data, "License key", class: 'control-label col-sm-2'
.col-sm-10
= f.text_area :data, class: "form-control license-key-field", rows: 20
.form-actions
= f.submit 'Upload license', class: 'btn btn-primary'
:javascript
function showLicenseType() {
if ($("input[name='license_type']:checked").val() == "file")
{
$(".license-file").show();
$(".license-key").hide();
}
else
{
$(".license-file").hide();
$(".license-key").show();
}
}
$("input[name='license_type']").click(showLicenseType);
showLicenseType();
......@@ -6,7 +6,7 @@
= form_tag callback_import_google_code_path, class: 'form-horizontal', multipart: true do
%p
Follow the steps below to export your Google Code project data.
Follow the steps below to export your Google Code project data.
In the next step, you'll be able to select the projects you want to import.
%ol
%li
......
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