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
01b2bb37
Commit
01b2bb37
authored
Jul 06, 2017
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add small fixes and refactors after last code review
parent
2f031c25
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
23 deletions
+23
-23
app/controllers/admin/trials_controller.rb
app/controllers/admin/trials_controller.rb
+8
-4
app/helpers/license_helper.rb
app/helpers/license_helper.rb
+9
-14
app/models/license.rb
app/models/license.rb
+1
-1
app/views/admin/licenses/_upload_buy_license.html.haml
app/views/admin/licenses/_upload_buy_license.html.haml
+1
-1
app/views/admin/licenses/show.html.haml
app/views/admin/licenses/show.html.haml
+1
-1
lib/gitlab.rb
lib/gitlab.rb
+1
-0
spec/controllers/admin/licenses_controller_spec.rb
spec/controllers/admin/licenses_controller_spec.rb
+1
-1
spec/models/license_spec.rb
spec/models/license_spec.rb
+1
-1
No files found.
app/controllers/admin/trials_controller.rb
View file @
01b2bb37
...
...
@@ -10,9 +10,13 @@ class Admin::TrialsController < Admin::ApplicationController
if
save_license
redirect_to
admin_license_url
,
notice:
'Your trial license was successfully activated'
else
flash
.
now
[
:alert
]
=
"An error occurred while generating the trial license, please try again a few minutes.<br>
If the error persist please try by creating the license from
<a href='https://about.gitlab.com/free-trial/' target='_blank'>this page</a>."
.
html_safe
message
=
<<~
MSG
An error occurred while generating the trial license, please try again a few minutes.<br>
If the error persist please try by creating the license from
<a href="https://about.gitlab.com/free-trial/" target="_blank">this page</a>.
MSG
flash
.
now
[
:alert
]
=
message
.
html_safe
render
:new
end
end
...
...
@@ -24,7 +28,7 @@ class Admin::TrialsController < Admin::ApplicationController
def
save_license
result
=
HTTParty
.
post
(
"
#{
Gitlab
::
SUBSCRIPTIONS_URL
}
/trials"
,
body:
params
)
if
false
if
result
.
ok?
@license
.
data
=
result
[
'license_key'
]
@license
.
save
else
...
...
app/helpers/license_helper.rb
View file @
01b2bb37
...
...
@@ -12,19 +12,8 @@ module LicenseHelper
HistoricalData
.
max_historical_user_count
end
def
license_message
(
signed_in:
signed_in?
,
is_admin:
(
current_user
&
.
admin?
))
yes_license_message
(
signed_in
,
is_admin
)
if
current_license
end
private
def
current_license
return
@current_license
if
defined?
(
@current_license
)
@current_license
=
License
.
current
end
def
yes_license_message
(
signed_in
,
is_admin
)
def
license_message
(
signed_in:
signed_in?
,
is_admin:
current_user
&
.
admin?
)
return
unless
current_license
return
unless
signed_in
return
unless
(
is_admin
&&
current_license
.
notify_admins?
)
||
current_license
.
notify_users?
...
...
@@ -37,7 +26,7 @@ module LicenseHelper
message
<<
"will expire in
#{
pluralize
(
current_license
.
remaining_days
,
'day'
)
}
."
end
message
<<
link_to
(
'Buy now!'
,
"
#{
Gitlab
::
SUBSCRIPTIONS_URL
}
/plans"
,
target:
'_blank'
)
if
is_trial
message
<<
link_to
(
'Buy now!'
,
Gitlab
::
SUBSCRIPTIONS_PLANS_URL
,
target:
'_blank'
)
if
is_trial
if
current_license
.
expired?
&&
current_license
.
will_block_changes?
message
<<
'Pushing code and creation of issues and merge requests'
...
...
@@ -64,5 +53,11 @@ module LicenseHelper
message
.
join
(
' '
).
html_safe
end
def
current_license
return
@current_license
if
defined?
(
@current_license
)
@current_license
=
License
.
current
end
extend
self
end
app/models/license.rb
View file @
01b2bb37
...
...
@@ -157,7 +157,7 @@ class License < ActiveRecord::Base
end
def
block_changes?
!!
current
&
.
block_changes?
current
&
.
block_changes?
end
def
load_license
...
...
app/views/admin/licenses/_upload_buy_license.html.haml
View file @
01b2bb37
=
link_to
'Buy License'
,
"
#{
Gitlab
::
SUBSCRIPTIONS_URL
}
/plans"
,
target:
'_blank'
,
rel:
'noopener noreferrer nofollow'
,
class:
"btn btn-new btn-inverted pull-right btn-buy-license"
=
link_to
'Buy License'
,
Gitlab
::
SUBSCRIPTIONS_PLANS_URL
,
target:
'_blank'
,
rel:
'noopener noreferrer nofollow'
,
class:
"btn btn-new btn-inverted pull-right btn-buy-license"
=
link_to
'Upload New License'
,
new_admin_license_path
,
class:
"btn pull-right btn-upload-license append-right-10"
app/views/admin/licenses/show.html.haml
View file @
01b2bb37
...
...
@@ -35,7 +35,7 @@
Expired:
-
else
Expires:
-
if
@license
.
will_expire?
-
if
@license
.
will_expire?
&&
@license
.
active?
%strong
=
time_ago_with_tooltip
(
@license
.
expires_at
)
-
if
@license
.
trial?
%span
Free trial will expire in
#{
pluralize
(
@license
.
remaining_days
,
'day'
)
}
...
...
lib/gitlab.rb
View file @
01b2bb37
...
...
@@ -4,6 +4,7 @@ module Gitlab
SUBDOMAIN_REGEX
=
%r{
\A
https://[a-z0-9]+
\.
gitlab
\.
com
\z
}
COM_URL
=
'https://gitlab.com'
.
freeze
SUBSCRIPTIONS_URL
=
'https://customers.gitlab.com'
.
freeze
SUBSCRIPTIONS_PLANS_URL
=
"
#{
SUBSCRIPTIONS_URL
}
/plans"
.
freeze
def
self
.
com?
# Check `gl_subdomain?` as well to keep parity with gitlab.com
...
...
spec/controllers/admin/licenses_controller_spec.rb
View file @
01b2bb37
...
...
@@ -16,7 +16,7 @@ describe Admin::LicensesController do
end
end
describe
'GET
#
show'
do
describe
'GET show'
do
context
'with an existent license'
do
it
'renders the license details'
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
create
(
:license
))
...
...
spec/models/license_spec.rb
View file @
01b2bb37
...
...
@@ -293,7 +293,7 @@ describe License do
end
it
"returns false"
do
expect
(
described_class
.
block_changes?
).
to
eq
(
false
)
expect
(
described_class
.
block_changes?
).
to
be_falsey
end
end
...
...
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