Commit 531f3ac4 authored by Douwe Maan's avatar Douwe Maan

Allow license to be uploaded as text rather than file

parent 2c7563c9
...@@ -206,7 +206,7 @@ gem 'request_store', '~> 1.2.0' ...@@ -206,7 +206,7 @@ gem 'request_store', '~> 1.2.0'
gem 'select2-rails', '~> 3.5.9' gem 'select2-rails', '~> 3.5.9'
gem 'virtus', '~> 1.0.1' gem 'virtus', '~> 1.0.1'
gem "gitlab-license", "~> 0.0.2" gem "gitlab-license", "~> 0.0.4"
group :development do group :development do
gem "foreman" gem "foreman"
......
...@@ -287,7 +287,7 @@ GEM ...@@ -287,7 +287,7 @@ GEM
diff-lcs (~> 1.1) diff-lcs (~> 1.1)
mime-types (~> 1.15) mime-types (~> 1.15)
posix-spawn (~> 0.3) posix-spawn (~> 0.3)
gitlab-license (0.0.3) gitlab-license (0.0.4)
gitlab_emoji (0.1.1) gitlab_emoji (0.1.1)
gemojione (~> 2.0) gemojione (~> 2.0)
gitlab_git (7.2.20) gitlab_git (7.2.20)
...@@ -840,7 +840,7 @@ DEPENDENCIES ...@@ -840,7 +840,7 @@ DEPENDENCIES
github-linguist (~> 4.7.0) github-linguist (~> 4.7.0)
github-markup (~> 1.3.1) github-markup (~> 1.3.1)
gitlab-flowdock-git-hook (~> 1.0.1) gitlab-flowdock-git-hook (~> 1.0.1)
gitlab-license (~> 0.0.2) gitlab-license (~> 0.0.4)
gitlab_emoji (~> 0.1) gitlab_emoji (~> 0.1)
gitlab_git (~> 7.2.20) gitlab_git (~> 7.2.20)
gitlab_meta (= 7.0) gitlab_meta (= 7.0)
......
...@@ -61,3 +61,7 @@ ...@@ -61,3 +61,7 @@
@extend .broadcast-message; @extend .broadcast-message;
margin-bottom: 20px; margin-bottom: 20px;
} }
.license-key-field {
font-family: monospace;
}
...@@ -63,6 +63,8 @@ class Admin::LicensesController < Admin::ApplicationController ...@@ -63,6 +63,8 @@ class Admin::LicensesController < Admin::ApplicationController
end end
def license_params 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
end end
...@@ -89,7 +89,7 @@ class License < ActiveRecord::Base ...@@ -89,7 +89,7 @@ class License < ActiveRecord::Base
def valid_license def valid_license
return if 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 end
def active_user_count def active_user_count
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
%h3.page-title Upload License %h3.page-title Upload License
%p.light %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 %hr
= form_for @license, url: admin_license_path, html: { multipart: true, class: 'form-horizontal fieldset-form' } do |f| = form_for @license, url: admin_license_path, html: { multipart: true, class: 'form-horizontal fieldset-form' } do |f|
...@@ -13,9 +13,46 @@ ...@@ -13,9 +13,46 @@
%p= msg %p= msg
.form-group .form-group
= f.label :data_file, "License", class: 'control-label col-sm-2' .col-sm-2
.col-sm-10 .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 .form-actions
= f.submit 'Upload license', class: 'btn btn-primary' = 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();
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