Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1d38dd49
Commit
1d38dd49
authored
Jun 27, 2017
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to generate trial license and upload it immediately
parent
4d7b6a6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
9 deletions
+53
-9
app/controllers/trials_controller.rb
app/controllers/trials_controller.rb
+43
-0
app/views/trials/new.html.haml
app/views/trials/new.html.haml
+10
-9
No files found.
app/controllers/trials_controller.rb
View file @
1d38dd49
class
TrialsController
<
ApplicationController
SUBSCRIPTIONS_PORTAL_URL
=
'https://customers.gitlab.com'
before_filter
:check_presence_of_license
def
new
end
def
create
build_license
if
save_license
redirect_to
admin_license_url
else
flash
.
now
[
:alert
]
=
'An error occurred while generating the trial license, please try again a few minutes'
render
:new
end
end
private
def
build_license
@license
=
License
.
new
end
def
save_license
result
=
HTTParty
.
post
(
"
#{
SUBSCRIPTIONS_PORTAL_URL
}
/trials"
,
body:
params
)
if
result
.
ok?
@license
.
data
=
result
[
'license_key'
]
@license
.
save
else
Rails
.
logger
.
error
(
"Error generating trial license:
#{
result
[
'error'
]
}
"
)
@license
.
errors
.
add
(
:base
,
result
[
'error'
])
end
@license
.
persisted?
end
def
check_presence_of_license
current_license
=
License
.
current
if
current_license
&&
!
current_license
.
expired?
redirect_to
admin_license_url
end
end
end
app/views/trials/new.html.haml
View file @
1d38dd49
-
page_title
'Trial license'
%h3
.page-title
Trial License
%main
{
:role
=>
"main"
}
.actions
=
form_tag
oauth_authorization
_path
,
method: :post
do
=
form_tag
trials
_path
,
method: :post
do
.form-group
=
label_tag
:first_name
=
text_field_tag
:first_name
,
nil
,
class:
"form-control"
,
required:
true
=
text_field_tag
:first_name
,
params
[
:first_name
]
,
class:
"form-control"
,
required:
true
.form-group
=
label_tag
:last_name
=
text_field_tag
:last_name
,
nil
,
class:
"form-control"
,
required:
true
=
text_field_tag
:last_name
,
params
[
:last_name
]
,
class:
"form-control"
,
required:
true
.form-group
=
label_tag
:work_email
=
text_field_tag
:work_email
,
nil
,
class:
"form-control"
,
required:
true
=
text_field_tag
:work_email
,
params
[
:work_email
]
,
class:
"form-control"
,
required:
true
.form-group
=
label_tag
:company_name
=
text_field_tag
:company_name
,
nil
,
class:
"form-control"
,
required:
true
=
text_field_tag
:company_name
,
params
[
:company_name
]
,
class:
"form-control"
,
required:
true
.form-group
=
label_tag
:phone_number
=
text_field_tag
:phone_number
,
nil
,
class:
"form-control"
,
required:
true
=
text_field_tag
:phone_number
,
params
[
:phone_number
]
,
class:
"form-control"
,
required:
true
.form-group
=
label_tag
:number_of_developers
=
text_field_tag
:number_of_developers
,
nil
,
class:
"form-control"
,
required:
true
=
text_field_tag
:number_of_developers
,
params
[
:number_of_developers
]
,
class:
"form-control"
,
required:
true
.form-group
=
label_tag
:number_of_users
=
text_field_tag
:number_of_users
,
nil
,
class:
"form-control"
,
required:
true
=
text_field_tag
:number_of_users
,
params
[
:number_of_users
]
,
class:
"form-control"
,
required:
true
.form-group
=
label_tag
:country
=
text_field_tag
:country
,
nil
,
class:
"form-control"
,
required:
true
=
text_field_tag
:country
,
params
[
:country
]
,
class:
"form-control"
,
required:
true
.form-group
=
submit_tag
'Start your free trial'
,
class:
"btn btn-default"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment