This commit is contained in:
Nicolas Bally 2016-05-31 00:05:59 +02:00
parent eb5a05c328
commit b8ad9dbc8d
3 changed files with 14 additions and 14 deletions

View File

@ -8,14 +8,14 @@ class Admin::DomainsController < ApplicationController
end end
def new def new
@category = Domain.new() @domain = Domain.new()
end end
def create def create
@category = Domain.new(domain_params) @domain = Domain.new(domain_params)
if @category.save if @domain.save
flash[:notice] = "Catégorie créée avec succès." flash[:notice] = "Catégorie créée avec succès."
redirect_to admin_domains_path redirect_to admin_domains_path
else else
@ -25,13 +25,13 @@ class Admin::DomainsController < ApplicationController
end end
def edit def edit
@category = Domain.find(params[:id]) @domain = Domain.find(params[:id])
end end
def update def update
@category = Domain.find(params[:id]) @domain = Domain.find(params[:id])
if @category.update_attributes(domain_params) if @domain.update_attributes(domain_params)
flash[:notice] = "Catégorie modifiée avec succès." flash[:notice] = "Catégorie modifiée avec succès."
redirect_to admin_domains_path redirect_to admin_domains_path
else else
@ -41,14 +41,14 @@ class Admin::DomainsController < ApplicationController
end end
def destroy def destroy
@category = Domain.find(params[:id]) @domain = Domain.find(params[:id])
if @category.destroy if !@domain.superadmin and @domain.destroy
flash[:notice] = "Catégorie supprimée avec succès." flash[:notice] = "Domaine supprimée avec succès."
else else
flash[:error] = "Impossible de supprimer cette catégorie." flash[:error] = "Impossible de supprimer ce domaine."
end end
render "index" redirect_to :action => :index
end end
def domain_params def domain_params

View File

@ -3,5 +3,5 @@
%td %td
= domain.name = domain.name
%td.actions{:style => "width:150px;text-align:right"} %td.actions{:style => "width:150px;text-align:right"}
= link_to i(:"trash-o"), [:admin, domain], :data => {:confirm => 'Voulez-vous vraiment supprimer cette catégorie ?'}, :method => :delete = link_to i(:"trash-o"), [:admin, domain], :data => {:confirm => 'Voulez-vous vraiment supprimer ce domaine ?'}, :method => :delete
= link_to i(:pencil), edit_admin_domain_path(domain) = link_to i(:pencil), edit_admin_domain_path(domain)

View File

@ -1,8 +1,8 @@
=semantic_form_for [:admin, @category] do |f| =semantic_form_for [:admin, @domain] do |f|
.content .content
=f.inputs do =f.inputs do
=f.input :name, :label => "Nom de la catégorie : " =f.input :name, :label => "Nom du domaine : "
.actions= f.submit "Sauvegarder", :class => "btn btn-primary" .actions= f.submit "Sauvegarder", :class => "btn btn-primary"