initial commit

This commit is contained in:
2012-08-22 18:15:37 +02:00
commit 0856528f5e
120 changed files with 3048 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
class ApplicationController < ActionController::Base
protect_from_forgery
private
def active_list
List.find(session[:list_id])
end
helper_method :active_list
end
+30
View File
@@ -0,0 +1,30 @@
class DashboardController < ApplicationController
def home
end
# Testing action
def select_qrcode
@tables = Table.all
end
def create_list
@table = Table.find(params[:table_id])
if @table.occupied?
redirect_to root_path, alert: t('table.is_occupied')
else
@list = List.new(table: @table)
#@list.add_user(current_user)
@list.save
session[:list_id] = @list.id
redirect_to root_path
end
end
def show_products
@supplier = Supplier.first
end
end
+90
View File
@@ -0,0 +1,90 @@
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
end
end
@@ -0,0 +1,102 @@
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
@@ -0,0 +1,91 @@
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
+106
View File
@@ -0,0 +1,106 @@
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
# GET /suppliers/1/product_list
# GET /suppliers/1/product_list.json
def product_list
@supplier = Supplier.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json do
products = @supplier.products
products.include_relation(:product_categories)
h = products.inject({}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
render json: h
end
end
end
private
def set_relation_options
@suppliers = Supplier.all
@lists = List.all
end
end
+102
View File
@@ -0,0 +1,102 @@
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
# GET /tables/qrcode
# GET /tables/qrcode.png
# GET /tables/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
+83
View File
@@ -0,0 +1,83 @@
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