Grosse MàJ
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
class Admin::AdminController < ApplicationController
|
||||
before_filter :login_required
|
||||
end
|
@ -0,0 +1,80 @@
|
||||
#class CustomersController < ApplicationController
|
||||
class Admin::CustomersController < Admin::AdminController
|
||||
# GET /customers
|
||||
# GET /customers.xml
|
||||
def index
|
||||
@customers = Customer.find(:all)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.rhtml
|
||||
format.xml { render :xml => @customers.to_xml }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /customers/1
|
||||
# GET /customers/1.xml
|
||||
def show
|
||||
@customer = Customer.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.rhtml
|
||||
format.xml { render :xml => @customer.to_xml }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /customers/new
|
||||
def new
|
||||
@customer = Customer.new
|
||||
end
|
||||
|
||||
# GET /customers/1;edit
|
||||
def edit
|
||||
@customer = Customer.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /customers
|
||||
# POST /customers.xml
|
||||
def create
|
||||
@customer = Customer.new(params[:customer])
|
||||
|
||||
respond_to do |format|
|
||||
if @customer.save
|
||||
flash[:notice] = 'Customer was successfully created.'
|
||||
format.html { redirect_to customer_url(@customer) }
|
||||
format.xml { head :created, :location => customer_url(@customer) }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @customer.errors.to_xml }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /customers/1
|
||||
# PUT /customers/1.xml
|
||||
def update
|
||||
@customer = Customer.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @customer.update_attributes(params[:customer])
|
||||
flash[:notice] = 'Customer was successfully updated.'
|
||||
format.html { redirect_to customer_url(@customer) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @customer.errors.to_xml }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /customers/1
|
||||
# DELETE /customers/1.xml
|
||||
def destroy
|
||||
@customer = Customer.find(params[:id])
|
||||
@customer.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to customers_url }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,92 @@
|
||||
# ajout de la biblioth<74>que PP
|
||||
require "pp"
|
||||
|
||||
#class ProductsController < ApplicationController
|
||||
class Admin::ProductsController < Admin::AdminController
|
||||
|
||||
in_place_edit_for :product, :designation
|
||||
|
||||
# GET /products
|
||||
# GET /products.xml
|
||||
def index
|
||||
@products = Product.find(:all)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.rhtml
|
||||
format.xml { render :xml => @products.to_xml }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /products/1
|
||||
# GET /products/1.xml
|
||||
def show
|
||||
@product = Product.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.rhtml
|
||||
format.xml { render :xml => @product.to_xml }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /products/new
|
||||
def new
|
||||
@product = Product.new
|
||||
end
|
||||
|
||||
# GET /products/1;edit
|
||||
def edit
|
||||
@product = Product.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /products
|
||||
# POST /products.xml
|
||||
def create
|
||||
@product = Product.new(params[:product])
|
||||
|
||||
@product.type = params[:type] if params[:type]
|
||||
|
||||
respond_to do |format|
|
||||
if @product.save
|
||||
flash[:notice] = 'Le produit a été crée avec succès.'
|
||||
format.html { redirect_to product_url(@product) }
|
||||
format.xml { head :created, :location => product_url(@product) }
|
||||
else #si erreur alors
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @product.errors.to_xml }
|
||||
pp(@product)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /products/1
|
||||
# PUT /products/1.xml
|
||||
def update
|
||||
|
||||
@product = Product.find(params[:id])
|
||||
|
||||
@product.type = params[:type] if params[:type]
|
||||
|
||||
respond_to do |format|
|
||||
if @product.update_attributes(params[:product])
|
||||
flash[:notice] = 'Le produit a été mis à jour avec succès.'
|
||||
format.html { redirect_to product_url(@product) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @product.errors.to_xml }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /products/1
|
||||
# DELETE /products/1.xml
|
||||
def destroy
|
||||
@product = Product.find(params[:id])
|
||||
@product.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to products_url }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,92 @@
|
||||
# ajout de la biblioth<74>que PP
|
||||
require "pp"
|
||||
|
||||
#class ProductsController < ApplicationController
|
||||
class Admin::ProductsController < Admin::AdminController
|
||||
|
||||
in_place_edit_for :product, :designation
|
||||
|
||||
# GET /products
|
||||
# GET /products.xml
|
||||
def index
|
||||
@products = Product.find(:all)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.rhtml
|
||||
format.xml { render :xml => @products.to_xml }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /products/1
|
||||
# GET /products/1.xml
|
||||
def show
|
||||
@product = Product.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.rhtml
|
||||
format.xml { render :xml => @product.to_xml }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /products/new
|
||||
def new
|
||||
@product = Product.new
|
||||
end
|
||||
|
||||
# GET /products/1;edit
|
||||
def edit
|
||||
@product = Product.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /products
|
||||
# POST /products.xml
|
||||
def create
|
||||
@product = Product.new(params[:product])
|
||||
|
||||
@product.type = params[:type] if params[:type]
|
||||
|
||||
respond_to do |format|
|
||||
if @product.save
|
||||
flash[:notice] = 'Le produit a été crée avec succès.'
|
||||
format.html { redirect_to product_url(@product) }
|
||||
format.xml { head :created, :location => product_url(@product) }
|
||||
else #si erreur alors
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @product.errors.to_xml }
|
||||
pp(@product)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /products/1
|
||||
# PUT /products/1.xml
|
||||
def update
|
||||
|
||||
@product = Product.find(params[:id])
|
||||
|
||||
@product.type = params[:type] if params[:type]
|
||||
|
||||
respond_to do |format|
|
||||
if @product.update_attributes(params[:product])
|
||||
flash[:notice] = 'Le produit a été mis à jour avec succès.'
|
||||
format.html { redirect_to product_url(@product) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @product.errors.to_xml }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /products/1
|
||||
# DELETE /products/1.xml
|
||||
def destroy
|
||||
@product = Product.find(params[:id])
|
||||
@product.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to products_url }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,80 @@
|
||||
#class SuppliersController < ApplicationController
|
||||
class Admin::SuppliersController < Admin::AdminController
|
||||
# GET /suppliers
|
||||
# GET /suppliers.xml
|
||||
def index
|
||||
@suppliers = Supplier.find(:all)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.rhtml
|
||||
format.xml { render :xml => @suppliers.to_xml }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /suppliers/1
|
||||
# GET /suppliers/1.xml
|
||||
def show
|
||||
@supplier = Supplier.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.rhtml
|
||||
format.xml { render :xml => @supplier.to_xml }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /suppliers/new
|
||||
def new
|
||||
@supplier = Supplier.new
|
||||
end
|
||||
|
||||
# GET /suppliers/1;edit
|
||||
def edit
|
||||
@supplier = Supplier.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /suppliers
|
||||
# POST /suppliers.xml
|
||||
def create
|
||||
@supplier = Supplier.new(params[:supplier])
|
||||
|
||||
respond_to do |format|
|
||||
if @supplier.save
|
||||
flash[:notice] = 'Supplier was successfully created.'
|
||||
format.html { redirect_to supplier_url(@supplier) }
|
||||
format.xml { head :created, :location => supplier_url(@supplier) }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @supplier.errors.to_xml }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /suppliers/1
|
||||
# PUT /suppliers/1.xml
|
||||
def update
|
||||
@supplier = Supplier.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @supplier.update_attributes(params[:supplier])
|
||||
flash[:notice] = 'Supplier was successfully updated.'
|
||||
format.html { redirect_to supplier_url(@supplier) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @supplier.errors.to_xml }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /suppliers/1
|
||||
# DELETE /suppliers/1.xml
|
||||
def destroy
|
||||
@supplier = Supplier.find(params[:id])
|
||||
@supplier.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to suppliers_url }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user