mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Display sponsor pages only if sponsorship levels are defined
This commit is contained in:
parent
02487be6fb
commit
e83b2c3a90
2 changed files with 8 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ module Admin
|
|||
class SponsorsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :sponsor, through: :conference
|
||||
before_action :sponsorship_level_required, only: [:index, :new]
|
||||
|
||||
def index
|
||||
authorize! :index, Sponsor.new(conference_id: @conference.id)
|
||||
|
|
@ -51,5 +52,11 @@ module Admin
|
|||
def sponsor_params
|
||||
params.require(:sponsor).permit(:name, :description, :website_url, :picture, :picture_cache, :sponsorship_level_id, :conference_id)
|
||||
end
|
||||
|
||||
def sponsorship_level_required
|
||||
return unless @conference.sponsorship_levels.empty?
|
||||
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
|
||||
alert: 'You need to create atleast one sponsorship level to add a sponsor'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue