mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-16 21:24:05 +00:00
Implement role authorization
This commit is contained in:
parent
6755328c4c
commit
e2fb434dc7
122 changed files with 1386 additions and 751 deletions
|
|
@ -1,16 +1,15 @@
|
|||
module Admin
|
||||
class CampaignsController < ApplicationController
|
||||
before_filter :verify_organizer
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :campaign, through: :conference
|
||||
|
||||
def index
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
authorize! :show, Campaign.new(conference_id: @conference.id)
|
||||
@campaigns = @conference.campaigns
|
||||
end
|
||||
|
||||
def create
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
@campaign = @conference.campaigns.new(params[:campaign])
|
||||
@campaign.conference_id = @conference.id
|
||||
@campaign.attributes = params[:campaign]
|
||||
|
||||
if @conference.save
|
||||
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title),
|
||||
|
|
@ -23,19 +22,12 @@ module Admin
|
|||
end
|
||||
|
||||
def new
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
@campaign = @conference.campaigns.new
|
||||
end
|
||||
|
||||
def edit
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
@campaign = Campaign.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
@campaign = Campaign.find(params[:id])
|
||||
|
||||
if @campaign.update_attributes(params[:campaign])
|
||||
redirect_to(admin_conference_campaigns_path(
|
||||
conference_id: @conference.short_title),
|
||||
|
|
@ -50,8 +42,6 @@ module Admin
|
|||
end
|
||||
|
||||
def destroy
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
@campaign = Campaign.find(params[:id])
|
||||
if @campaign.destroy
|
||||
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title),
|
||||
notice: "Campaign '#{@campaign.name}' successfully deleted.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue