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
4a0f1a11
Commit
4a0f1a11
authored
Jul 04, 2017
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper method to get remaining days before expiration of the license
parent
bcd814ac
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
4 deletions
+9
-4
app/controllers/trials_controller.rb
app/controllers/trials_controller.rb
+1
-1
app/helpers/license_helper.rb
app/helpers/license_helper.rb
+1
-1
app/models/license.rb
app/models/license.rb
+6
-0
app/views/admin/licenses/show.html.haml
app/views/admin/licenses/show.html.haml
+1
-2
No files found.
app/controllers/trials_controller.rb
View file @
4a0f1a11
class
TrialsController
<
ApplicationController
before_
filter
:check_presence_of_license
before_
action
:check_presence_of_license
def
new
end
...
...
app/helpers/license_helper.rb
View file @
4a0f1a11
...
...
@@ -18,7 +18,7 @@ module LicenseHelper
def
trial_license_message
return
unless
signed_in?
&&
current_license
&
.
trial?
return
unless
7
.
days
.
since
(
Date
.
today
)
>=
current_license
.
expires_at
return
if
current_license
.
remaining_days
>
7
buy_now_link
=
link_to
(
'Buy now!'
,
"
#{
Gitlab
::
SUBSCRIPTIONS_URL
}
/plans"
,
target:
'_blank'
)
message
=
...
...
app/models/license.rb
View file @
4a0f1a11
...
...
@@ -265,6 +265,12 @@ class License < ActiveRecord::Base
restricted_attr
(
:trial
)
end
def
remaining_days
return
if
expired?
(
expires_at
-
Date
.
today
).
to_i
end
private
def
restricted_attr
(
name
,
default
=
nil
)
...
...
app/views/admin/licenses/show.html.haml
View file @
4a0f1a11
...
...
@@ -39,8 +39,7 @@
-
if
@license
.
will_expire?
%strong
=
time_ago_with_tooltip
(
@license
.
expires_at
)
-
if
@license
.
trial?
-
remaining_days
=
(
@license
.
expires_at
-
Date
.
today
).
to_i
%span
=
"(Free trial will expire in
#{
pluralize
(
remaining_days
,
'day'
)
}
)"
%span
=
"(Free trial will expire in
#{
pluralize
(
@license
.
remaining_days
,
'day'
)
}
)"
-
else
%strong
Never
...
...
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