Commit 4a0f1a11 authored by Ruben Davila's avatar Ruben Davila

Add helper method to get remaining days before expiration of the license

parent bcd814ac
class TrialsController < ApplicationController
before_filter :check_presence_of_license
before_action :check_presence_of_license
def new
end
......
......@@ -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 =
......
......@@ -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)
......
......@@ -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
......
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