Grosse MàJ

This commit is contained in:
olivier
2008-11-25 22:11:16 +01:00
parent 53195fdfcd
commit 3e719157ea
2980 changed files with 343846 additions and 0 deletions

View File

@ -0,0 +1,79 @@
class AddressesController < ApplicationController
# GET /addresses
# GET /addresses.xml
def index
@addresses = Address.find(:all)
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @addresses.to_xml }
end
end
# GET /addresses/1
# GET /addresses/1.xml
def show
@address = Address.find(params[:id])
respond_to do |format|
format.html # show.rhtml
format.xml { render :xml => @address.to_xml }
end
end
# GET /addresses/new
def new
@address = Address.new
end
# GET /addresses/1;edit
def edit
@address = Address.find(params[:id])
end
# POST /addresses
# POST /addresses.xml
def create
@address = Address.new(params[:address])
respond_to do |format|
if @address.save
flash[:notice] = 'Address was successfully created.'
format.html { redirect_to address_url(@address) }
format.xml { head :created, :location => address_url(@address) }
else
format.html { render :action => "new" }
format.xml { render :xml => @address.errors.to_xml }
end
end
end
# PUT /addresses/1
# PUT /addresses/1.xml
def update
@address = Address.find(params[:id])
respond_to do |format|
if @address.update_attributes(params[:address])
flash[:notice] = 'Address was successfully updated.'
format.html { redirect_to address_url(@address) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @address.errors.to_xml }
end
end
end
# DELETE /addresses/1
# DELETE /addresses/1.xml
def destroy
@address = Address.find(params[:id])
@address.destroy
respond_to do |format|
format.html { redirect_to addresses_url }
format.xml { head :ok }
end
end
end

View File

@ -0,0 +1,3 @@
class Admin::AdminController < ApplicationController
before_filter :login_required
end

View File

@ -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

View File

@ -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 &#233;t&#233; cr&#233;e avec succ&#232;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 &#233;t&#233; mis &#224; jour avec succ&#232;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

View File

@ -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 &#233;t&#233; cr&#233;e avec succ&#232;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 &#233;t&#233; mis &#224; jour avec succ&#232;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

View File

@ -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

View File

@ -0,0 +1,9 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
# Pick a unique cookie name to distinguish our session data from others'
session :session_key => '_mon_projet_session_id'
end

View File

@ -0,0 +1,22 @@
class ProductsController < ApplicationController
def index
#@products = Product.find(:all)
@products = Product.paginate :page => params[:page], :per_page => 3
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @products.to_xml }
end
end
def show
@product = Product.find(params[:id])
respond_to do |format|
format.html # show.rhtml
format.xml { render :xml => @product.to_xml }
end
end
end

View File

@ -0,0 +1,22 @@
class ProductsController < ApplicationController
def index
#@products = Product.find(:all)
@posts = Product.paginate :page => params[:page], :per_page => 3
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @products.to_xml }
end
end
def show
@product = Product.find(params[:id])
respond_to do |format|
format.html # show.rhtml
format.xml { render :xml => @product.to_xml }
end
end
end

View File

@ -0,0 +1,31 @@
# This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
# render new.rhtml
def new
end
def create
self.current_utilisateur = Utilisateur.authenticate(params[:login], params[:password])
if logged_in?
if params[:remember_me] == "1"
self.current_utilisateur.remember_me
cookies[:auth_token] = { :value => self.current_utilisateur.remember_token , :expires => self.current_utilisateur.remember_token_expires_at }
end
redirect_back_or_default('/')
flash[:notice] = "Logged in successfully"
else
render :action => 'new'
end
end
def destroy
self.current_utilisateur.forget_me if logged_in?
cookies.delete :auth_token
reset_session
flash[:notice] = "You have been logged out."
redirect_back_or_default('/')
end
end

View File

@ -0,0 +1,28 @@
class UtilisateursController < ApplicationController
# render new.rhtml
def new
end
def create
cookies.delete :auth_token
reset_session
@utilisateur = Utilisateur.new(params[:utilisateur])
@utilisateur.save!
self.current_utilisateur = @utilisateur
redirect_back_or_default('/')
flash[:notice] = "Thanks for signing up!"
rescue ActiveRecord::RecordInvalid
render :action => 'new'
end
def activate
self.current_utilisateur = params[:activation_code].blank? ? :false : Utilisateur.find_by_activation_code(params[:activation_code])
if logged_in? && !current_utilisateur.activated?
current_utilisateur.activate
flash[:notice] = "Signup complete!"
end
redirect_back_or_default('/')
end
end