big refactor for test and admin namespace

This commit is contained in:
2012-12-04 18:45:18 +01:00
parent 7d64ab2022
commit d8eef4a047
85 changed files with 1403 additions and 1272 deletions
@@ -0,0 +1,6 @@
module Admin
class ApplicationController < ::ApplicationController
before_filter :authenticate_administrator!
layout 'administrator'
end
end
+94
View File
@@ -0,0 +1,94 @@
# encoding: UTF-8
module Admin
class ListsController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /lists
# GET /lists.json
def index
@lists = List.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @lists }
end
end
# GET /lists/1
# GET /lists/1.json
def show
@list = List.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @list }
end
end
# GET /lists/new
# GET /lists/new.json
def new
@list = List.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @list }
end
end
# GET /lists/1/edit
def edit
@list = List.find(params[:id])
end
# POST /lists
# POST /lists.json
def create
@list = List.new(params[:list])
respond_to do |format|
if @list.save
format.html { redirect_to [:admin, @list], notice: t('action.create.successfull', model: List.model_name.human) }
format.json { render json: @list, status: :created, location: @list }
else
format.html { render action: "new" }
format.json { render json: @list.errors, status: :unprocessable_entity }
end
end
end
# PUT /lists/1
# PUT /lists/1.json
def update
@list = List.find(params[:id])
respond_to do |format|
if @list.update_attributes(params[:list])
format.html { redirect_to [:admin, @list], notice: t('action.update.successfull', model: List.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @list.errors, status: :unprocessable_entity }
end
end
end
# DELETE /lists/1
# DELETE /lists/1.json
def destroy
@list = List.find(params[:id])
@list.destroy
respond_to do |format|
format.html { redirect_to admin_lists_path, notice: t('action.destroy.successfull', model: List.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@tables = Table.all
@suppliers = Supplier.all
end
end
end
@@ -0,0 +1,94 @@
# encoding: UTF-8
module Admin
class OrdersController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /orders
# GET /orders.json
def index
@orders = Order.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }
end
end
# GET /orders/1
# GET /orders/1.json
def show
@order = Order.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @order }
end
end
# GET /orders/new
# GET /orders/new.json
def new
@order = Order.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @order }
end
end
# GET /orders/1/edit
def edit
@order = Order.find(params[:id])
end
# POST /orders
# POST /orders.json
def create
@order = Order.new(params[:order])
respond_to do |format|
if @order.save
format.html { redirect_to [:admin, @order], notice: t('action.create.successfull', model: Order.model_name.human) }
format.json { render json: @order, status: :created, location: @order }
else
format.html { render action: "new" }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end
# PUT /orders/1
# PUT /orders/1.json
def update
@order = Order.find(params[:id])
respond_to do |format|
if @order.update_attributes(params[:order])
format.html { redirect_to [:admin, @order], notice: t('action.update.successfull', model: Order.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end
# DELETE /orders/1
# DELETE /orders/1.json
def destroy
@order = Order.find(params[:id])
@order.destroy
respond_to do |format|
format.html { redirect_to admin_orders_url, notice: t('action.destroy.successfull', model: Order.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@lists = List.all
@suppliers = Supplier.all
end
end
end
@@ -0,0 +1,105 @@
# encoding: UTF-8
module Admin
class ProductCategoriesController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /product_categories
# GET /product_categories.json
def index
@product_categories = ProductCategory.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @product_categories }
end
end
# GET /product_categories/1
# GET /product_categories/1.json
def show
@product_category = ProductCategory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @product_category }
end
end
# GET /product_categories/new
# GET /product_categories/new.json
def new
@product_category = ProductCategory.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @product_category }
end
end
# GET /product_categories/1/edit
def edit
@product_category = ProductCategory.find(params[:id])
end
# POST /product_categories
# POST /product_categories.json
def create
@product_category = ProductCategory.new(params[:product_category])
respond_to do |format|
if @product_category.save
format.html { redirect_to [:admin, @product_category], notice: t('action.create.successfull', model: ProductCategory.model_name.human) }
format.json { render json: @product_category, status: :created, location: @product_category }
else
format.html { render action: "new" }
format.json { render json: @product_category.errors, status: :unprocessable_entity }
end
end
end
# PUT /product_categories/1
# PUT /product_categories/1.json
def update
@product_category = ProductCategory.find(params[:id])
respond_to do |format|
if @product_category.update_attributes(params[:product_category])
format.html { redirect_to [:admin, @product_category], notice: t('action.update.successfull', model: ProductCategory.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @product_category.errors, status: :unprocessable_entity }
end
end
end
# DELETE /product_categories/1
# DELETE /product_categories/1.json
def destroy
@product_category = ProductCategory.find(params[:id])
@product_category.destroy
respond_to do |format|
format.html { redirect_to admin_product_categories_path, notice: t('action.destroy.successfull', model: ProductCategory.model_name.human) }
format.json { head :no_content }
end
end
# GET /product_categories/qrcode
# GET /product_categories/qrcode.png
# GET /product_categories/qrcode.svg
def qrcode
respond_to do |format|
format.html
format.svg { render :qrcode => request.url, :level => :l, :unit => 10 }
format.png { render qrcode: request.url }
end
end
private
def set_relation_options
@suppliers = Supplier.all
@lists = List.all
end
end
end
@@ -0,0 +1,94 @@
# encoding: UTF-8
module Admin
class ProductsController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /products
# GET /products.json
def index
@products = Product.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @products }
end
end
# GET /products/1
# GET /products/1.json
def show
@product = Product.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @product }
end
end
# GET /products/new
# GET /products/new.json
def new
@product = Product.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @product }
end
end
# GET /products/1/edit
def edit
@product = Product.find(params[:id])
end
# POST /products
# POST /products.json
def create
@product = Product.new(params[:product])
respond_to do |format|
if @product.save
format.html { redirect_to [:admin, @product], notice: t('action.create.successfull', model: Product.model_name.human) }
format.json { render json: @product, status: :created, location: @product }
else
format.html { render action: "new" }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end
# PUT /products/1
# PUT /products/1.json
def update
@product = Product.find(params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
format.html { redirect_to [:admin, @product], notice: t('action.update.successfull', model: Product.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end
# DELETE /products/1
# DELETE /products/1.json
def destroy
@product = Product.find(params[:id])
@product.destroy
respond_to do |format|
format.html { redirect_to admin_products_path, notice: t('action.destroy.successfull', model: Product.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
@product_categories = ProductCategory.all
end
end
end
@@ -0,0 +1,93 @@
# encoding: UTF-8
module Admin
class SectionsController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /sections
# GET /sections.json
def index
@sections = Section.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sections }
end
end
# GET /sections/1
# GET /sections/1.json
def show
@section = Section.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @section }
end
end
# GET /sections/new
# GET /sections/new.json
def new
@section = Section.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @section }
end
end
# GET /sections/1/edit
def edit
@section = Section.find(params[:id])
end
# POST /sections
# POST /sections.json
def create
@section = Section.new(params[:section])
respond_to do |format|
if @section.save
format.html { redirect_to [:admin, @section], notice: t('action.create.successfull', model: Section.model_name.human) }
format.json { render json: @section, status: :created, location: @section }
else
format.html { render action: "new" }
format.json { render json: @section.errors, status: :unprocessable_entity }
end
end
end
# PUT /sections/1
# PUT /sections/1.json
def update
@section = Section.find(params[:id])
respond_to do |format|
if @section.update_attributes(params[:section])
format.html { redirect_to [:admin, @section], notice: t('action.update.successfull', model: Section.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @section.errors, status: :unprocessable_entity }
end
end
end
# DELETE /sections/1
# DELETE /sections/1.json
def destroy
@section = Section.find(params[:id])
@section.destroy
respond_to do |format|
format.html { redirect_to admin_sections_path, notice: t('action.destroy.successfull', model: Section.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
end
end
end
@@ -0,0 +1,93 @@
module Admin
class SuppliersController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /suppliers
# GET /suppliers.json
def index
@suppliers = Supplier.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @suppliers }
end
end
# GET /suppliers/1
# GET /suppliers/1.json
def show
@supplier = Supplier.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @supplier }
end
end
# GET /suppliers/new
# GET /suppliers/new.json
def new
@supplier = Supplier.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @supplier }
end
end
# GET /suppliers/1/edit
def edit
@supplier = Supplier.find(params[:id])
end
# POST /suppliers
# POST /suppliers.json
def create
@supplier = Supplier.new(params[:supplier])
respond_to do |format|
if @supplier.save
format.html { redirect_to [:admin, @supplier], notice: t('action.create.successfull', model: Supplier.model_name.human) }
format.json { render json: @supplier, status: :created, location: @supplier }
else
format.html { render action: "new" }
format.json { render json: @supplier.errors, status: :unprocessable_entity }
end
end
end
# PUT /suppliers/1
# PUT /suppliers/1.json
def update
@supplier = Supplier.find(params[:id])
respond_to do |format|
if @supplier.update_attributes(params[:supplier])
format.html { redirect_to [:admin, @supplier], notice: t('action.update.successfull', model: Supplier.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @supplier.errors, status: :unprocessable_entity }
end
end
end
# DELETE /suppliers/1
# DELETE /suppliers/1.json
def destroy
@supplier = Supplier.find(params[:id])
@supplier.destroy
respond_to do |format|
format.html { redirect_to admin_suppliers_path, notice: t('action.destroy.successfull', model: Supplier.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
@lists = List.all
end
end
end
@@ -0,0 +1,94 @@
# encoding: UTF-8
module Admin
class TablesController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /tables
# GET /tables.json
def index
@tables = Table.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tables }
end
end
# GET /tables/1
# GET /tables/1.json
def show
@table = Table.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @table }
end
end
# GET /tables/new
# GET /tables/new.json
def new
@table = Table.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @table }
end
end
# GET /tables/1/edit
def edit
@table = Table.find(params[:id])
end
# POST /tables
# POST /tables.json
def create
@table = Table.new(params[:table])
respond_to do |format|
if @table.save
format.html { redirect_to [:admin, @table], notice: t('action.create.successfull', model: Table.model_name.human) }
format.json { render json: @table, status: :created, location: @table }
else
format.html { render action: "new" }
format.json { render json: @table.errors, status: :unprocessable_entity }
end
end
end
# PUT /tables/1
# PUT /tables/1.json
def update
@table = Table.find(params[:id])
respond_to do |format|
if @table.update_attributes(params[:table])
format.html { redirect_to [:admin, @table], notice: t('action.update.successfull', model: Table.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @table.errors, status: :unprocessable_entity }
end
end
end
# DELETE /tables/1
# DELETE /tables/1.json
def destroy
@table = Table.find(params[:id])
@table.destroy
respond_to do |format|
format.html { redirect_to admin_tables_url, notice: t('action.destroy.successfull', model: Table.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
@lists = List.all
end
end
end
+85
View File
@@ -0,0 +1,85 @@
module Admin
class UsersController < Admin::ApplicationController
# GET /users
# GET /users.json
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @users }
end
end
# GET /users/1
# GET /users/1.json
def show
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user }
end
end
# GET /users/new
# GET /users/new.json
def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user }
end
end
# GET /users/1/edit
def edit
@user = User.find(params[:id])
end
# POST /users
# POST /users.json
def create
@user = User.new(params[:user])
respond_to do |format|
if @user.save
format.html { redirect_to [:admin, @user], notice: t('action.create.successfull', model: User.model_name.human) }
format.json { render json: @user, status: :created, location: @user }
else
format.html { render action: "new" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
# PUT /users/1
# PUT /users/1.json
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to [:admin, @user], notice: t('action.update.successfull', model: User.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
# DELETE /users/1
# DELETE /users/1.json
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to admin_users_url, notice: t('action.destroy.successfull', model: User.model_name.human) }
format.json { head :no_content }
end
end
end
end
-91
View File
@@ -1,91 +0,0 @@
class ListsController < ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /lists
# GET /lists.json
def index
@lists = List.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @lists }
end
end
# GET /lists/1
# GET /lists/1.json
def show
@list = List.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @list }
end
end
# GET /lists/new
# GET /lists/new.json
def new
@list = List.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @list }
end
end
# GET /lists/1/edit
def edit
@list = List.find(params[:id])
end
# POST /lists
# POST /lists.json
def create
@list = List.new(params[:list])
respond_to do |format|
if @list.save
format.html { redirect_to @list, notice: t('action.create.successfull', model: List.model_name.human) }
format.json { render json: @list, status: :created, location: @list }
else
format.html { render action: "new" }
format.json { render json: @list.errors, status: :unprocessable_entity }
end
end
end
# PUT /lists/1
# PUT /lists/1.json
def update
@list = List.find(params[:id])
respond_to do |format|
if @list.update_attributes(params[:list])
format.html { redirect_to @list, notice: t('action.update.successfull', model: List.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @list.errors, status: :unprocessable_entity }
end
end
end
# DELETE /lists/1
# DELETE /lists/1.json
def destroy
@list = List.find(params[:id])
@list.destroy
respond_to do |format|
format.html { redirect_to lists_url, notice: t('action.destroy.successfull', model: List.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@tables = Table.all
@suppliers = Supplier.all
end
end
-91
View File
@@ -1,91 +0,0 @@
class OrdersController < ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /orders
# GET /orders.json
def index
@orders = Order.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }
end
end
# GET /orders/1
# GET /orders/1.json
def show
@order = Order.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @order }
end
end
# GET /orders/new
# GET /orders/new.json
def new
@order = Order.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @order }
end
end
# GET /orders/1/edit
def edit
@order = Order.find(params[:id])
end
# POST /orders
# POST /orders.json
def create
@order = Order.new(params[:order])
respond_to do |format|
if @order.save
format.html { redirect_to @order, notice: t('action.create.successfull', model: Order.model_name.human) }
format.json { render json: @order, status: :created, location: @order }
else
format.html { render action: "new" }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end
# PUT /orders/1
# PUT /orders/1.json
def update
@order = Order.find(params[:id])
respond_to do |format|
if @order.update_attributes(params[:order])
format.html { redirect_to @order, notice: t('action.update.successfull', model: Order.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end
# DELETE /orders/1
# DELETE /orders/1.json
def destroy
@order = Order.find(params[:id])
@order.destroy
respond_to do |format|
format.html { redirect_to orders_url, notice: t('action.destroy.successfull', model: Order.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@lists = List.all
@suppliers = Supplier.all
end
end
@@ -1,102 +0,0 @@
class ProductCategoriesController < ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /product_categories
# GET /product_categories.json
def index
@product_categories = ProductCategory.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @product_categories }
end
end
# GET /product_categories/1
# GET /product_categories/1.json
def show
@product_category = ProductCategory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @product_category }
end
end
# GET /product_categories/new
# GET /product_categories/new.json
def new
@product_category = ProductCategory.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @product_category }
end
end
# GET /product_categories/1/edit
def edit
@product_category = ProductCategory.find(params[:id])
end
# POST /product_categories
# POST /product_categories.json
def create
@product_category = ProductCategory.new(params[:product_category])
respond_to do |format|
if @product_category.save
format.html { redirect_to @product_category, notice: t('action.create.successfull', model: ProductCategory.model_name.human) }
format.json { render json: @product_category, status: :created, location: @product_category }
else
format.html { render action: "new" }
format.json { render json: @product_category.errors, status: :unprocessable_entity }
end
end
end
# PUT /product_categories/1
# PUT /product_categories/1.json
def update
@product_category = ProductCategory.find(params[:id])
respond_to do |format|
if @product_category.update_attributes(params[:product_category])
format.html { redirect_to @product_category, notice: t('action.update.successfull', model: ProductCategory.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @product_category.errors, status: :unprocessable_entity }
end
end
end
# DELETE /product_categories/1
# DELETE /product_categories/1.json
def destroy
@product_category = ProductCategory.find(params[:id])
@product_category.destroy
respond_to do |format|
format.html { redirect_to product_categories_url, notice: t('action.destroy.successfull', model: ProductCategory.model_name.human) }
format.json { head :no_content }
end
end
# GET /product_categories/qrcode
# GET /product_categories/qrcode.png
# GET /product_categories/qrcode.svg
def qrcode
respond_to do |format|
format.html
format.svg { render :qrcode => request.url, :level => :l, :unit => 10 }
format.png { render qrcode: request.url }
end
end
private
def set_relation_options
@suppliers = Supplier.all
@lists = List.all
end
end
-91
View File
@@ -1,91 +0,0 @@
class ProductsController < ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /products
# GET /products.json
def index
@products = Product.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @products }
end
end
# GET /products/1
# GET /products/1.json
def show
@product = Product.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @product }
end
end
# GET /products/new
# GET /products/new.json
def new
@product = Product.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @product }
end
end
# GET /products/1/edit
def edit
@product = Product.find(params[:id])
end
# POST /products
# POST /products.json
def create
@product = Product.new(params[:product])
respond_to do |format|
if @product.save
format.html { redirect_to @product, notice: t('action.create.successfull', model: Product.model_name.human) }
format.json { render json: @product, status: :created, location: @product }
else
format.html { render action: "new" }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end
# PUT /products/1
# PUT /products/1.json
def update
@product = Product.find(params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
format.html { redirect_to @product, notice: t('action.update.successfull', model: Product.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end
# DELETE /products/1
# DELETE /products/1.json
def destroy
@product = Product.find(params[:id])
@product.destroy
respond_to do |format|
format.html { redirect_to products_url, notice: t('action.destroy.successfull', model: Product.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
@product_categories = ProductCategory.all
end
end
-90
View File
@@ -1,90 +0,0 @@
class SectionsController < ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /sections
# GET /sections.json
def index
@sections = Section.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sections }
end
end
# GET /sections/1
# GET /sections/1.json
def show
@section = Section.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @section }
end
end
# GET /sections/new
# GET /sections/new.json
def new
@section = Section.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @section }
end
end
# GET /sections/1/edit
def edit
@section = Section.find(params[:id])
end
# POST /sections
# POST /sections.json
def create
@section = Section.new(params[:section])
respond_to do |format|
if @section.save
format.html { redirect_to @section, notice: t('action.create.successfull', model: Section.model_name.human) }
format.json { render json: @section, status: :created, location: @section }
else
format.html { render action: "new" }
format.json { render json: @section.errors, status: :unprocessable_entity }
end
end
end
# PUT /sections/1
# PUT /sections/1.json
def update
@section = Section.find(params[:id])
respond_to do |format|
if @section.update_attributes(params[:section])
format.html { redirect_to @section, notice: t('action.update.successfull', model: Section.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @section.errors, status: :unprocessable_entity }
end
end
end
# DELETE /sections/1
# DELETE /sections/1.json
def destroy
@section = Section.find(params[:id])
@section.destroy
respond_to do |format|
format.html { redirect_to sections_url, notice: t('action.destroy.successfull', model: Section.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
end
end
-91
View File
@@ -1,91 +0,0 @@
class SuppliersController < ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /suppliers
# GET /suppliers.json
def index
@suppliers = Supplier.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @suppliers }
end
end
# GET /suppliers/1
# GET /suppliers/1.json
def show
@supplier = Supplier.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @supplier }
end
end
# GET /suppliers/new
# GET /suppliers/new.json
def new
@supplier = Supplier.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @supplier }
end
end
# GET /suppliers/1/edit
def edit
@supplier = Supplier.find(params[:id])
end
# POST /suppliers
# POST /suppliers.json
def create
@supplier = Supplier.new(params[:supplier])
respond_to do |format|
if @supplier.save
format.html { redirect_to @supplier, notice: t('action.create.successfull', model: Supplier.model_name.human) }
format.json { render json: @supplier, status: :created, location: @supplier }
else
format.html { render action: "new" }
format.json { render json: @supplier.errors, status: :unprocessable_entity }
end
end
end
# PUT /suppliers/1
# PUT /suppliers/1.json
def update
@supplier = Supplier.find(params[:id])
respond_to do |format|
if @supplier.update_attributes(params[:supplier])
format.html { redirect_to @supplier, notice: t('action.update.successfull', model: Supplier.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @supplier.errors, status: :unprocessable_entity }
end
end
end
# DELETE /suppliers/1
# DELETE /suppliers/1.json
def destroy
@supplier = Supplier.find(params[:id])
@supplier.destroy
respond_to do |format|
format.html { redirect_to suppliers_url, notice: t('action.destroy.successfull', model: Supplier.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
@lists = List.all
end
end
-91
View File
@@ -1,91 +0,0 @@
class TablesController < ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
# GET /tables
# GET /tables.json
def index
@tables = Table.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tables }
end
end
# GET /tables/1
# GET /tables/1.json
def show
@table = Table.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @table }
end
end
# GET /tables/new
# GET /tables/new.json
def new
@table = Table.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @table }
end
end
# GET /tables/1/edit
def edit
@table = Table.find(params[:id])
end
# POST /tables
# POST /tables.json
def create
@table = Table.new(params[:table])
respond_to do |format|
if @table.save
format.html { redirect_to @table, notice: t('action.create.successfull', model: Table.model_name.human) }
format.json { render json: @table, status: :created, location: @table }
else
format.html { render action: "new" }
format.json { render json: @table.errors, status: :unprocessable_entity }
end
end
end
# PUT /tables/1
# PUT /tables/1.json
def update
@table = Table.find(params[:id])
respond_to do |format|
if @table.update_attributes(params[:table])
format.html { redirect_to @table, notice: t('action.update.successfull', model: Table.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @table.errors, status: :unprocessable_entity }
end
end
end
# DELETE /tables/1
# DELETE /tables/1.json
def destroy
@table = Table.find(params[:id])
@table.destroy
respond_to do |format|
format.html { redirect_to tables_url, notice: t('action.destroy.successfull', model: Table.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
@lists = List.all
end
end
-83
View File
@@ -1,83 +0,0 @@
class UsersController < ApplicationController
# GET /users
# GET /users.json
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @users }
end
end
# GET /users/1
# GET /users/1.json
def show
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user }
end
end
# GET /users/new
# GET /users/new.json
def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user }
end
end
# GET /users/1/edit
def edit
@user = User.find(params[:id])
end
# POST /users
# POST /users.json
def create
@user = User.new(params[:user])
respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: t('action.create.successfull', model: User.model_name.human) }
format.json { render json: @user, status: :created, location: @user }
else
format.html { render action: "new" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
# PUT /users/1
# PUT /users/1.json
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to @user, notice: t('action.update.successfull', model: User.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
# DELETE /users/1
# DELETE /users/1.json
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to users_url, notice: t('action.destroy.successfull', model: User.model_name.human) }
format.json { head :no_content }
end
end
end