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
|
class SponsorsController < Admin::BaseController
|
||||||
load_and_authorize_resource :conference, find_by: :short_title
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
load_and_authorize_resource :sponsor, through: :conference
|
load_and_authorize_resource :sponsor, through: :conference
|
||||||
|
before_action :sponsorship_level_required, only: [:index, :new]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize! :index, Sponsor.new(conference_id: @conference.id)
|
authorize! :index, Sponsor.new(conference_id: @conference.id)
|
||||||
|
|
@ -51,5 +52,11 @@ module Admin
|
||||||
def sponsor_params
|
def sponsor_params
|
||||||
params.require(:sponsor).permit(:name, :description, :website_url, :picture, :picture_cache, :sponsorship_level_id, :conference_id)
|
params.require(:sponsor).permit(:name, :description, :website_url, :picture, :picture_cache, :sponsorship_level_id, :conference_id)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@
|
||||||
- if can? :update, @conference.sponsorship_levels.build
|
- if can? :update, @conference.sponsorship_levels.build
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))}" }
|
%li{:class=> "#{active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))}" }
|
||||||
= link_to 'Sponsorship Levels', admin_conference_sponsorship_levels_path(@conference.short_title)
|
= link_to 'Sponsorship Levels', admin_conference_sponsorship_levels_path(@conference.short_title)
|
||||||
- if can? :update, @conference.sponsors.build
|
- if !@conference.sponsorship_levels.empty? && @conference.sponsorship_levels.first.persisted? && (can? :update, @conference.sponsors.build)
|
||||||
%li{:class=> active_nav_li(admin_conference_sponsors_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_sponsors_path(@conference.short_title))}
|
||||||
= link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title)
|
= link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title)
|
||||||
- if can? :update, @conference.tickets.build
|
- if can? :update, @conference.tickets.build
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue