71 lines
1.2 KiB
Ruby
71 lines
1.2 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::PetitionsController < ApplicationController
|
|
layout "admin"
|
|
before_filter :authenticate_admin!
|
|
|
|
def index
|
|
@petitions = Petition.all
|
|
|
|
|
|
end
|
|
|
|
def show
|
|
@petition = Petition.find(params[:id])
|
|
|
|
end
|
|
|
|
def new
|
|
@petition = Petition.new
|
|
|
|
end
|
|
|
|
def reconfirm
|
|
@signator = PetitionSignator.find(params[:id])
|
|
PetitionMails.confirmation(@signator).deliver
|
|
redirect_to admin_petition_url(@signator.petition), :notice => "mail de confirmation envoyé de nouveau."
|
|
end
|
|
|
|
def edit
|
|
@petition = Petition.find(params[:id])
|
|
end
|
|
|
|
def create
|
|
@petition = Petition.new(params.require(:petition).permit!)
|
|
|
|
|
|
if @petition.save
|
|
redirect_to admin_petitions_url, notice: 'La pétition a été crée.'
|
|
|
|
else
|
|
render action: "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@petition = Petition.find(params[:id])
|
|
|
|
|
|
if @petition.update_attributes(params.require(:petition).permit!)
|
|
redirect_to admin_petitions_url, notice: 'Les infos sur la pétition ont été mise à jour.'
|
|
|
|
else
|
|
render action: "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@petition = Petition.find(params[:id])
|
|
@petition.destroy
|
|
|
|
redirect_to admin_petitions_url
|
|
|
|
end
|
|
end
|