108 lines
1.4 KiB
Ruby
108 lines
1.4 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::PlumeArticlesController < ApplicationController
|
|
|
|
before_filter :auth_admin
|
|
|
|
layout "admin"
|
|
|
|
|
|
|
|
before_filter :find_plume_articles
|
|
|
|
def index
|
|
|
|
end
|
|
|
|
|
|
def cible
|
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
|
|
def new
|
|
|
|
@plume_article = PlumeArticle.new(:plume_cat_id => params[:plume_cat_id])
|
|
|
|
end
|
|
|
|
|
|
def edit
|
|
@admin = true
|
|
@plume_article = PlumeArticle.find(params[:id])
|
|
|
|
|
|
end
|
|
|
|
|
|
def create
|
|
|
|
@plume_article = PlumeArticle.new(plume_article_params)
|
|
|
|
|
|
if @plume_article.save
|
|
flash[:notice] = "L'plume_article à été ajouté avec succès."
|
|
@plume_articles = @plume_article.plume_cat.plume_articles.order(:position)
|
|
|
|
else
|
|
render :action => "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
|
|
@plume_article = PlumeArticle.find(params[:id])
|
|
|
|
|
|
if params[:plume_article]
|
|
if @plume_article.update_attributes(plume_article_params)
|
|
flash[:notice] = "L'plume_article à été modifié avec succès."
|
|
else
|
|
render :action => "edit"
|
|
end
|
|
|
|
|
|
elsif params[:tag_id]
|
|
@plume_article.tag_by_tag_ids(params[:tag_id])
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
|
|
@plume_article = PlumeArticle.find(params[:id])
|
|
@plume_article.destroy
|
|
|
|
end
|
|
|
|
protected
|
|
|
|
def find_plume_articles
|
|
|
|
|
|
@plume_articles = PlumeArticle.all
|
|
|
|
|
|
end
|
|
|
|
private
|
|
def plume_article_params
|
|
params.require(:plume_article).permit!
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|