mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #1006 from nishanthvijayan/restrict-sponsor-access
Display sponsor pages only if sponsorship levels are defined
This commit is contained in:
commit
0fd48f103b
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
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@
|
|||
- if can? :update, @conference.sponsorship_levels.build
|
||||
%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)
|
||||
- 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))}
|
||||
= link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title)
|
||||
- if can? :update, @conference.tickets.build
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue