Commit 8177803e authored by Sean McGivern's avatar Sean McGivern

Fix license initializer

This would fail after an AR connection was established by
8_metrics.rb (to load the application settings), because it would try to
render a route. For now, just ignore the problem by not creating a link
- the link is less useful in console output anyway.
parent 5eabc1da
......@@ -12,29 +12,43 @@ module LicenseHelper
HistoricalData.max_historical_user_count
end
def license_message(signed_in: signed_in?, is_admin: (current_user && current_user.is_admin?))
# in_html is set to false from an initializer, which shouldn't try to render
# HTML links.
#
def license_message(signed_in: signed_in?, is_admin: (current_user && current_user.is_admin?), in_html: true)
@license_message ||=
if License.current
yes_license_message(signed_in, is_admin)
else
no_license_message(is_admin)
no_license_message(is_admin, in_html: in_html)
end
end
private
def no_license_message(is_admin)
def no_license_message(is_admin, in_html: true)
upload_a_license =
if in_html
link_to('Upload a license', new_admin_license_path)
else
'Upload a license'
end
message = []
message << 'No GitLab Enterprise Edition license has been provided yet.'
message << 'Pushing code and creation of issues and merge requests has been disabled.'
message <<
if is_admin
"#{link_to('Upload a license', new_admin_license_path)} in the admin area to activate this functionality."
"#{upload_a_license} in the admin area to activate this functionality."
else
'Ask an admin to upload a license to activate this functionality.'
end
content_tag(:p, message.join(' ').html_safe)
if in_html
content_tag(:p, message.join(' ').html_safe)
else
message.join(' ')
end
end
def yes_license_message(signed_in, is_admin)
......
......@@ -8,7 +8,7 @@ end
# Needed to run migration
if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.table_exists?('licenses')
message = LicenseHelper.license_message(signed_in: true, is_admin: true)
message = LicenseHelper.license_message(signed_in: true, is_admin: false, in_html: false)
if message.present?
warn "WARNING: #{message}"
end
......
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