big refactor for test and admin namespace
This commit is contained in:
@@ -15,6 +15,7 @@ group :assets do
|
||||
gem 'sass-rails', '~> 3.2.3'
|
||||
gem 'coffee-rails', '~> 3.2.1'
|
||||
gem 'twitter-bootstrap-rails'
|
||||
gem 'bootstrap-sass'
|
||||
gem 'compass-rails'
|
||||
|
||||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||
|
||||
@@ -49,6 +49,8 @@ GEM
|
||||
addressable (2.3.2)
|
||||
arel (3.0.2)
|
||||
bcrypt-ruby (3.0.1)
|
||||
bootstrap-sass (2.2.1.1)
|
||||
sass (~> 3.2)
|
||||
builder (3.0.4)
|
||||
capybara (2.0.1)
|
||||
mime-types (>= 1.16)
|
||||
@@ -268,6 +270,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
bootstrap-sass
|
||||
coffee-rails (~> 3.2.1)
|
||||
compass-rails
|
||||
couch_potato!
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# More info at https://github.com/guard/guard#readme
|
||||
|
||||
guard 'rspec' do
|
||||
watch(%r{^spec/.+_spec\.rb$})
|
||||
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
||||
watch('spec/spec_helper.rb') { "spec" }
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
//= require mustache
|
||||
//= require faye
|
||||
//= require supplier/base
|
||||
//= require qwaiter
|
||||
//= require_directory .
|
||||
//= require_self
|
||||
var path_mapping = {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
||||
*
|
||||
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
||||
* compiled file, but it's generally better to create a new file per style scope.
|
||||
*
|
||||
*= require_directory .
|
||||
* require 'bootstrap-devise-rails'
|
||||
*= require_self
|
||||
*/
|
||||
@@ -0,0 +1,3 @@
|
||||
@import bootstrap
|
||||
body
|
||||
padding-top: 60px !important
|
||||
@@ -12,13 +12,13 @@ body {
|
||||
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
|
||||
// Note: If you use asset_path() here, your compiled boostrap_and_overrides.css will not
|
||||
// have the proper paths. So for now we use the absolute path.
|
||||
@fontAwesomeEotPath: '/assets/fontawesome-webfont.eot';
|
||||
@fontAwesomeWoffPath: '/assets/fontawesome-webfont.woff';
|
||||
@fontAwesomeTtfPath: '/assets/fontawesome-webfont.ttf';
|
||||
@fontAwesomeSvgPath: '/assets/fontawesome-webfont.svg';
|
||||
//@fontAwesomeEotPath: '/assets/fontawesome-webfont.eot';
|
||||
//@fontAwesomeWoffPath: '/assets/fontawesome-webfont.woff';
|
||||
//@fontAwesomeTtfPath: '/assets/fontawesome-webfont.ttf';
|
||||
//@fontAwesomeSvgPath: '/assets/fontawesome-webfont.svg';
|
||||
|
||||
// Font Awesome
|
||||
@import "fontawesome";
|
||||
//@import "fontawesome";
|
||||
|
||||
// Your custom LESS stylesheets goes here
|
||||
//
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
module Admin
|
||||
class ApplicationController < ::ApplicationController
|
||||
before_filter :authenticate_administrator!
|
||||
layout 'administrator'
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -93,4 +93,8 @@ module ApplicationHelper
|
||||
script.present? ? (@onload_javascripts ||= []) << script : (@onload_javascripts || []).join(';')
|
||||
end
|
||||
|
||||
def mustache_template(template)
|
||||
render(template, handlers: [:mustache])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -24,6 +24,7 @@ class Order
|
||||
}
|
||||
}], reduce_function: '_sum'
|
||||
view :by_supplier_id_and_id, key: [:supplier_id, :_id]
|
||||
view :by_list_id, key: :list_id
|
||||
|
||||
# Return all currently active orders for a given supplier
|
||||
def self.active_for_supplier(supplier_id)
|
||||
|
||||
@@ -11,6 +11,8 @@ class Product
|
||||
has_many :product_orders
|
||||
|
||||
validates :supplier_id, presence: true
|
||||
validates :price, presence: true, numericality: true
|
||||
|
||||
after_save :persist_product_category_ids
|
||||
|
||||
def product_category_ids=(ids)
|
||||
|
||||
@@ -7,4 +7,6 @@ class ProductOrder
|
||||
belongs_to :product
|
||||
belongs_to :order
|
||||
|
||||
view :by_product_id, key: :product_id
|
||||
|
||||
end
|
||||
|
||||
@@ -26,6 +26,8 @@ class Supplier
|
||||
|
||||
after_create :add_section_on_create
|
||||
|
||||
view :by_email, key: :email
|
||||
|
||||
def location=(val)
|
||||
lat, lng = val.strip.split(/[ ,]+/).map(&:to_f)
|
||||
self.lat = lat
|
||||
|
||||
+3
-1
@@ -14,7 +14,9 @@ class Table
|
||||
validates :supplier_id, presence: true
|
||||
#validates :list_id, presence: true
|
||||
validates :number, numericality: {greater_than: 0}
|
||||
validates_uniqueness_of :number
|
||||
|
||||
#validates_uniqueness_of :number
|
||||
#view :by_number, key: :number # For uniqueness validation
|
||||
|
||||
def occupied?
|
||||
return @is_occupied if instance_variable_defined?(:'@is_occupied')
|
||||
|
||||
@@ -12,6 +12,7 @@ class User
|
||||
before_save :ensure_authentication_token
|
||||
|
||||
view :by_authentication_token, key: :authentication_token
|
||||
view :by_email, key: :email
|
||||
|
||||
def list_is_closed!
|
||||
self.active_list_id = nil
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
= form_for @order, html: {class: 'form-horizontal' } do |f|
|
||||
= simple_form_for [:admin, @order], html: {class: 'form-horizontal' } do |f|
|
||||
= render 'error_messages', target: @order
|
||||
.control-group class=(@order.errors[:state].any? ? 'error' : nil)
|
||||
= f.label :state, class: 'control-label'
|
||||
@@ -11,4 +11,4 @@
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), orders_path, class: 'btn'
|
||||
= link_to t("helpers.links.cancel"), admin_orders_path, class: 'btn'
|
||||
@@ -11,14 +11,14 @@ div.page-header= title :index, model_class
|
||||
tbody
|
||||
- @orders.each do |order|
|
||||
tr
|
||||
td= link_to order.state, order
|
||||
td= link_to_if order.supplier.present?, order.supplier.try(:name), order.supplier
|
||||
td= link_to order.state, [:admin, order]
|
||||
td= link_to_if order.supplier.present?, order.supplier.try(:name), [:admin, order.supplier]
|
||||
td=l order.created_at, format: :short
|
||||
td
|
||||
= link_to t('helpers.links.edit'), [:edit, order], class: 'btn btn-mini'
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, order], class: 'btn btn-mini'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), order, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
= link_to t("helpers.links.destroy"), [:admin, order], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
- else
|
||||
= no_content_given model_class
|
||||
= link_to t("helpers.links.new"), new_order_path, class: 'btn btn-primary'
|
||||
= link_to t("helpers.links.new"), new_admin_order_path, class: 'btn btn-primary'
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
- model_class = Order
|
||||
.page-header= title :show, @order
|
||||
|
||||
dl.dl-horizontal.show-list
|
||||
dt= model_class.human_attribute_name(:state)
|
||||
dd= @order.state
|
||||
- if @order.supplier.present?
|
||||
dt= Supplier.model_name.human
|
||||
dd= link_to @order.supplier.name, [:admin, @order.supplier]
|
||||
|
||||
.form-actions
|
||||
= link_to t("helpers.links.back"), admin_orders_path, class: 'btn'
|
||||
'
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, @order], class: 'btn'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:admin, @order], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
@@ -0,0 +1,13 @@
|
||||
= simple_form_for [:admin, @product], html: {class: 'form-horizontal' } do |f|
|
||||
= render 'error_messages', target: @product
|
||||
= f.input :name
|
||||
= f.input :code
|
||||
= f.input :price
|
||||
.control-group class=(@product.errors[:supplier_id].any? ? 'error' : nil)
|
||||
= f.label :supplier_id, Supplier.model_name.human, class: 'control-label'
|
||||
.controls
|
||||
= f.collection_select :supplier_id, @suppliers, :id, :name, include_blank: nil
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), admin_products_path, class: 'btn'
|
||||
@@ -0,0 +1,3 @@
|
||||
- model_class = Product
|
||||
.page-header= title :edit, model_class
|
||||
= render 'form'
|
||||
@@ -7,24 +7,22 @@
|
||||
th= model_class.human_attribute_name(:name)
|
||||
th= model_class.human_attribute_name(:code)
|
||||
th= model_class.human_attribute_name(:price)
|
||||
th= ProductCategory.model_name.human
|
||||
th= Supplier.model_name.human
|
||||
th.timestamp= model_class.human_attribute_name(:created_at)
|
||||
th.actions=t 'helpers.actions'
|
||||
tbody
|
||||
- @products.each do |product|
|
||||
tr
|
||||
td.link= link_to product.name, product
|
||||
td.link= link_to product.name, [:admin, product]
|
||||
td= product.code
|
||||
td= product.price
|
||||
td.link= link_to_if product.product_category.present?, product.product_category.try(:name), product.product_category
|
||||
td.link= link_to_if product.supplier.present?, product.supplier.try(:name), product.supplier
|
||||
td.link= link_to_if product.supplier.present?, product.supplier.try(:name), [:admin, product.supplier]
|
||||
td.timestamp=l product.created_at, format: :short
|
||||
td.actions
|
||||
= link_to t('helpers.links.edit'), [:edit, product], class: 'btn btn-mini'
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, product], class: 'btn btn-mini'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), product, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
= link_to t("helpers.links.destroy"), [:admin, product], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
- else
|
||||
= no_content_given model_class
|
||||
= link_to t("helpers.links.new"), new_product_path, class: 'btn btn-primary'
|
||||
= link_to t("helpers.links.new"), new_admin_product_path, class: 'btn btn-primary'
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
- model_class = Product
|
||||
.page-header= title :show, @product
|
||||
|
||||
dl.dl-horizontal.show-list
|
||||
dt= model_class.human_attribute_name(:name)
|
||||
dd= @product.name
|
||||
dt= model_class.human_attribute_name(:code)
|
||||
dd= @product.code
|
||||
dt= model_class.human_attribute_name(:price)
|
||||
dd= @product.price
|
||||
- if @product.supplier.present?
|
||||
dt= Supplier.model_name.human
|
||||
dd= link_to @product.supplier.name, [:admin, @product.supplier]
|
||||
|
||||
.form-actions
|
||||
= link_to t("helpers.links.back"), admin_products_path, class: 'btn'
|
||||
'
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, @product], class: 'btn'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:admin, @product], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
@@ -0,0 +1,24 @@
|
||||
- model_class = Supplier
|
||||
.page-header= title :index, model_class
|
||||
- if @suppliers.any?
|
||||
table.table.table-striped.table-hover
|
||||
thead
|
||||
tr
|
||||
th= model_class.human_attribute_name(:email)
|
||||
th= model_class.human_attribute_name(:name)
|
||||
th= model_class.human_attribute_name(:created_at)
|
||||
th=t 'helpers.actions'
|
||||
tbody
|
||||
- @suppliers.each do |supplier|
|
||||
tr
|
||||
td= link_to supplier.email, [:admin, supplier]
|
||||
td= supplier.name
|
||||
td=l supplier.created_at, format: :short
|
||||
td
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, supplier], class: 'btn btn-mini'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:admin, supplier], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
- else
|
||||
= no_content_given model_class
|
||||
= link_to t("helpers.links.new"), new_admin_supplier_path, class: 'btn btn-primary'
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
.page-header= title :show, @supplier
|
||||
|
||||
dl.dl-horizontal.show-list
|
||||
dt= model_class.human_attribute_name(:name)
|
||||
dd= @supplier.name
|
||||
dt= model_class.human_attribute_name(:email)
|
||||
dd= @supplier.email
|
||||
dt= model_class.human_attribute_name(:encrypted_password)
|
||||
@@ -22,12 +24,10 @@ dl.dl-horizontal.show-list
|
||||
dd= @supplier.current_sign_in_ip
|
||||
dt= model_class.human_attribute_name(:last_sign_in_ip)
|
||||
dd= @supplier.last_sign_in_ip
|
||||
dt= model_class.human_attribute_name(:name)
|
||||
dd= @supplier.name
|
||||
|
||||
.form-actions
|
||||
= link_to t("helpers.links.back"), suppliers_path, class: 'btn'
|
||||
= link_to t("helpers.links.back"), admin_suppliers_path, class: 'btn'
|
||||
'
|
||||
= link_to t('helpers.links.edit'), [:edit, @supplier], class: 'btn'
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, @supplier], class: 'btn'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), @supplier, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
= link_to t("helpers.links.destroy"), [:admin, @supplier], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
@@ -1,9 +1,6 @@
|
||||
= form_for @table, html: {class: 'form-horizontal' } do |f|
|
||||
= simple_form_for [:admin, @table], html: {class: 'form-horizontal' } do |f|
|
||||
= render 'error_messages', target: @table
|
||||
.control-group class=(@table.errors[:number].any? ? 'error' : nil)
|
||||
= f.label :number, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :number, class: 'text_field'
|
||||
= f.input :number
|
||||
.control-group class=(@table.errors[:supplier_id].any? ? 'error' : nil)
|
||||
= f.label :supplier_id, Supplier.model_name.human, class: 'control-label'
|
||||
.controls
|
||||
@@ -11,4 +8,4 @@
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), tables_path, class: 'btn'
|
||||
= link_to t("helpers.links.cancel"), admin_tables_path, class: 'btn'
|
||||
@@ -0,0 +1,3 @@
|
||||
- model_class = Table
|
||||
.page-header= title :edit, model_class
|
||||
= render 'form'
|
||||
@@ -11,14 +11,14 @@ div.page-header= title :index, model_class
|
||||
tbody
|
||||
- @tables.each do |table|
|
||||
tr
|
||||
td= link_to table.number, table
|
||||
td= link_to table.supplier.name, table.supplier
|
||||
td= link_to table.number, [:admin, table]
|
||||
td= link_to table.supplier.name, [:admin, table.supplier]
|
||||
td=l table.created_at, format: :short
|
||||
td
|
||||
= link_to t('helpers.links.edit'), [:edit, table], class: 'btn btn-mini'
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, table], class: 'btn btn-mini'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), table, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
= link_to t("helpers.links.destroy"), [:admin, table], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
- else
|
||||
= no_content_given model_class
|
||||
= link_to t("helpers.links.new"), new_table_path, class: 'btn btn-primary'
|
||||
= link_to t("helpers.links.new"), new_admin_table_path, class: 'btn btn-primary'
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
- model_class = Table
|
||||
.page-header= title :show, @table
|
||||
|
||||
dl.dl-horizontal.show-list
|
||||
dt= model_class.human_attribute_name(:number)
|
||||
dd= @table.number
|
||||
- if @table.supplier.present?
|
||||
dt= Supplier.model_name.human
|
||||
dd= link_to @table.supplier.name, [:admin, @table.supplier]
|
||||
|
||||
.form-actions
|
||||
= link_to t("helpers.links.back"), admin_tables_path, class: 'btn'
|
||||
'
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, @table], class: 'btn'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:admin, @table], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
@@ -0,0 +1,7 @@
|
||||
= simple_form_for [:admin, @user], html: {class: 'form-horizontal' } do |f|
|
||||
= render 'error_messages', target: @user
|
||||
= f.input :email
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), admin_users_path, class: 'btn'
|
||||
@@ -0,0 +1,3 @@
|
||||
- model_class = User
|
||||
.page-header= title :edit, model_class
|
||||
= render 'form'
|
||||
@@ -10,13 +10,13 @@
|
||||
tbody
|
||||
- @users.each do |user|
|
||||
tr
|
||||
td= link_to user.email, user
|
||||
td= link_to user.email, [:admin, user]
|
||||
td=l user.created_at, format: :short
|
||||
td
|
||||
= link_to t('helpers.links.edit'), [:edit, user], class: 'btn btn-mini'
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, user], class: 'btn btn-mini'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), user, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
= link_to t("helpers.links.destroy"), [:admin, user], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
- else
|
||||
= no_content_given model_class
|
||||
= link_to t("helpers.links.new"), new_user_path, class: 'btn btn-primary'
|
||||
= link_to t("helpers.links.new"), new_admin_user_path, class: 'btn btn-primary'
|
||||
|
||||
@@ -24,8 +24,8 @@ dl.dl-horizontal.show-list
|
||||
dd= @user.last_sign_in_ip
|
||||
|
||||
.form-actions
|
||||
= link_to t("helpers.links.back"), users_path, class: 'btn'
|
||||
= link_to t("helpers.links.back"), admin_users_path, class: 'btn'
|
||||
'
|
||||
= link_to t('helpers.links.edit'), [:edit, @user], class: 'btn'
|
||||
= link_to t('helpers.links.edit'), [:edit, :admin, @user], class: 'btn'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), @user, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
= link_to t("helpers.links.destroy"), [:admin, @user], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
@@ -10,7 +10,7 @@ html lang="en"
|
||||
/! Le HTML5 shim, for IE6-8 support of HTML elements
|
||||
/[if lt IE 9]
|
||||
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||
= stylesheet_link_tag "application", :media => "all"
|
||||
= stylesheet_link_tag "admin/application", :media => "all"
|
||||
link href="images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
|
||||
link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
|
||||
link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
||||
@@ -25,16 +25,29 @@ html lang="en"
|
||||
span.icon-bar
|
||||
span.icon-bar
|
||||
span.icon-bar
|
||||
a.brand href=root_path = application_title
|
||||
a.brand href=admin_root_path = application_title
|
||||
.container.nav-collapse
|
||||
ul.nav
|
||||
li= link_to User.model_name.human_plural, users_path
|
||||
li= link_to Supplier.model_name.human_plural, suppliers_path
|
||||
li= link_to Table.model_name.human_plural, tables_path
|
||||
li= link_to Product.model_name.human_plural, products_path
|
||||
li= link_to List.model_name.human_plural, lists_path
|
||||
li= link_to Order.model_name.human_plural, orders_path
|
||||
li= link_to ProductCategory.model_name.human_plural, product_categories_path
|
||||
li= link_to User.model_name.human_plural, admin_users_path
|
||||
li.dropdown
|
||||
a.dropdown-toggle href="#" data-toggle="dropdown"
|
||||
span = Supplier.model_name.human_plural
|
||||
b.caret
|
||||
ul.child-menu.dropdown-menu
|
||||
li= link_to Supplier.model_name.human_plural, admin_suppliers_path
|
||||
li= link_to Table.model_name.human_plural, admin_tables_path
|
||||
li= link_to Product.model_name.human_plural, admin_products_path
|
||||
li= link_to List.model_name.human_plural, admin_lists_path
|
||||
li= link_to Order.model_name.human_plural, admin_orders_path
|
||||
li= link_to ProductCategory.model_name.human_plural, admin_product_categories_path
|
||||
- if administrator_signed_in?
|
||||
.btn-group.pull-right
|
||||
a.btn.dropdown-toggle[data-toggle="dropdown" href="#"]
|
||||
i.icon-user
|
||||
= current_administrator.email
|
||||
span.caret
|
||||
ul.dropdown-menu
|
||||
li.log-out= link_to t('helpers.links.logout'), destroy_administrator_session_path
|
||||
|
||||
.container
|
||||
|
||||
@@ -55,7 +68,7 @@ html lang="en"
|
||||
h3= application_title
|
||||
ul.nav.nav-list
|
||||
li.nav-header Links
|
||||
li= link_to "Home", root_path
|
||||
li= link_to "Qwaiter website", root_path
|
||||
li= link_to "Companytools", 'http://www.companytools.nl/'
|
||||
= yield :sidebar
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
- model_class = Order
|
||||
.page-header= title :show, @order
|
||||
|
||||
dl.dl-horizontal.show-list
|
||||
dt= model_class.human_attribute_name(:state)
|
||||
dd= @order.state
|
||||
- if @order.supplier.present?
|
||||
dt= Supplier.model_name.human
|
||||
dd= link_to @order.supplier.name, @order.supplier
|
||||
|
||||
.form-actions
|
||||
= link_to t("helpers.links.back"), orders_path, class: 'btn'
|
||||
'
|
||||
= link_to t('helpers.links.edit'), [:edit, @order], class: 'btn'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), @order, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
@@ -1,26 +0,0 @@
|
||||
= form_for @product, html: {class: 'form-horizontal' } do |f|
|
||||
= render 'error_messages', target: @product
|
||||
.control-group class=(@product.errors[:name].any? ? 'error' : nil)
|
||||
= f.label :name, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :name, class: 'text_field'
|
||||
.control-group class=(@product.errors[:code].any? ? 'error' : nil)
|
||||
= f.label :code, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :code, class: 'text_field'
|
||||
.control-group class=(@product.errors[:price].any? ? 'error' : nil)
|
||||
= f.label :price, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :price, class: 'text_field'
|
||||
/.control-group class=(@product.errors[:product_category_id].any? ? 'error' : nil)
|
||||
= f.label :product_category_id, ProductCategory.model_name.human, class: 'control-label'
|
||||
.controls
|
||||
= f.collection_select :product_category_id, @product_categories, :id, :name, include_blank: ''
|
||||
.control-group class=(@product.errors[:supplier_id].any? ? 'error' : nil)
|
||||
= f.label :supplier_id, Supplier.model_name.human, class: 'control-label'
|
||||
.controls
|
||||
= f.collection_select :supplier_id, @suppliers, :id, :name, include_blank: nil
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), products_path, class: 'btn'
|
||||
@@ -1,4 +0,0 @@
|
||||
- model_class = Product
|
||||
.page-header
|
||||
= title :edit, model_class
|
||||
= render 'form'
|
||||
@@ -1,23 +0,0 @@
|
||||
- model_class = Product
|
||||
.page-header= title :show, @product
|
||||
|
||||
dl.dl-horizontal.show-list
|
||||
dt= model_class.human_attribute_name(:name)
|
||||
dd= @product.name
|
||||
dt= model_class.human_attribute_name(:code)
|
||||
dd= @product.code
|
||||
dt= model_class.human_attribute_name(:price)
|
||||
dd= @product.price
|
||||
- if @product.product_category.present?
|
||||
dt= ProductCategory.model_name.human
|
||||
dd= link_to @product.product_category.name, @product.product_category
|
||||
- if @product.supplier.present?
|
||||
dt= Supplier.model_name.human
|
||||
dd= link_to @product.supplier.name, @product.supplier
|
||||
|
||||
.form-actions
|
||||
= link_to t("helpers.links.back"), products_path, class: 'btn'
|
||||
'
|
||||
= link_to t('helpers.links.edit'), [:edit, @product], class: 'btn'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), @product, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
@@ -10,5 +10,4 @@
|
||||
th.currency= t('supplier.active_lists.price')
|
||||
th.actions
|
||||
tbody
|
||||
script#active-list-template[type="text/html"]= render 'active_list.mustache'
|
||||
|
||||
script#active-list-template[type="text/html"]= mustache_template 'active_list'
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
th.currency= t('supplier.active_orders.price')
|
||||
th.actions
|
||||
tbody
|
||||
script#active-order-template[type="text/html"]= render 'active_order.mustache'
|
||||
script#active-order-template[type="text/html"]= mustache_template 'active_order'
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
- model_class = Supplier
|
||||
div.page-header= title :index, model_class
|
||||
- if @suppliers.any?
|
||||
table.table.table-striped
|
||||
thead
|
||||
tr
|
||||
th= model_class.human_attribute_name(:email)
|
||||
th= model_class.human_attribute_name(:encrypted_password)
|
||||
th= model_class.human_attribute_name(:remember_created_at)
|
||||
th= model_class.human_attribute_name(:reset_password_token)
|
||||
th= model_class.human_attribute_name(:reset_password_sent_at)
|
||||
th= model_class.human_attribute_name(:sign_in_count)
|
||||
th= model_class.human_attribute_name(:current_sign_in_at)
|
||||
th= model_class.human_attribute_name(:last_sign_in_at)
|
||||
th= model_class.human_attribute_name(:current_sign_in_ip)
|
||||
th= model_class.human_attribute_name(:last_sign_in_ip)
|
||||
th= model_class.human_attribute_name(:name)
|
||||
th= model_class.human_attribute_name(:created_at)
|
||||
th=t 'helpers.actions'
|
||||
tbody
|
||||
- @suppliers.each do |supplier|
|
||||
tr
|
||||
td= link_to supplier.email, supplier
|
||||
td= supplier.encrypted_password
|
||||
td= supplier.remember_created_at
|
||||
td= supplier.reset_password_token
|
||||
td= supplier.reset_password_sent_at
|
||||
td= supplier.sign_in_count
|
||||
td= supplier.current_sign_in_at
|
||||
td= supplier.last_sign_in_at
|
||||
td= supplier.current_sign_in_ip
|
||||
td= supplier.last_sign_in_ip
|
||||
td= supplier.name
|
||||
td=l supplier.created_at, format: :short
|
||||
td
|
||||
= link_to t('helpers.links.edit'), [:edit, supplier], class: 'btn btn-mini'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), supplier, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
- else
|
||||
= no_content_given model_class
|
||||
= link_to t("helpers.links.new"), new_supplier_path, class: 'btn btn-primary'
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
- model_class = Table
|
||||
.page-header
|
||||
= title :edit, model_class
|
||||
= render 'form'
|
||||
@@ -1,16 +0,0 @@
|
||||
- model_class = Table
|
||||
.page-header= title :show, @table
|
||||
|
||||
dl.dl-horizontal.show-list
|
||||
dt= model_class.human_attribute_name(:number)
|
||||
dd= @table.number
|
||||
- if @table.supplier.present?
|
||||
dt= Supplier.model_name.human
|
||||
dd= link_to @table.supplier.name, @table.supplier
|
||||
|
||||
.form-actions
|
||||
= link_to t("helpers.links.back"), tables_path, class: 'btn'
|
||||
'
|
||||
= link_to t('helpers.links.edit'), [:edit, @table], class: 'btn'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), @table, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||
@@ -1,46 +0,0 @@
|
||||
= form_for @user, html: {class: 'form-horizontal' } do |f|
|
||||
= render 'error_messages', target: @user
|
||||
.control-group class=(@user.errors[:email].any? ? 'error' : nil)
|
||||
= f.label :email, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :email, class: 'text_field'
|
||||
.control-group class=(@user.errors[:encrypted_password].any? ? 'error' : nil)
|
||||
= f.label :encrypted_password, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :encrypted_password, class: 'text_field'
|
||||
.control-group class=(@user.errors[:remember_created_at].any? ? 'error' : nil)
|
||||
= f.label :remember_created_at, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :remember_created_at, class: 'text_field'
|
||||
.control-group class=(@user.errors[:reset_password_token].any? ? 'error' : nil)
|
||||
= f.label :reset_password_token, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :reset_password_token, class: 'text_field'
|
||||
.control-group class=(@user.errors[:reset_password_sent_at].any? ? 'error' : nil)
|
||||
= f.label :reset_password_sent_at, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :reset_password_sent_at, class: 'text_field'
|
||||
.control-group class=(@user.errors[:sign_in_count].any? ? 'error' : nil)
|
||||
= f.label :sign_in_count, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :sign_in_count, class: 'text_field'
|
||||
.control-group class=(@user.errors[:current_sign_in_at].any? ? 'error' : nil)
|
||||
= f.label :current_sign_in_at, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :current_sign_in_at, class: 'text_field'
|
||||
.control-group class=(@user.errors[:last_sign_in_at].any? ? 'error' : nil)
|
||||
= f.label :last_sign_in_at, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :last_sign_in_at, class: 'text_field'
|
||||
.control-group class=(@user.errors[:current_sign_in_ip].any? ? 'error' : nil)
|
||||
= f.label :current_sign_in_ip, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :current_sign_in_ip, class: 'text_field'
|
||||
.control-group class=(@user.errors[:last_sign_in_ip].any? ? 'error' : nil)
|
||||
= f.label :last_sign_in_ip, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :last_sign_in_ip, class: 'text_field'
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), users_path, class: 'btn'
|
||||
@@ -1,4 +0,0 @@
|
||||
- model_class = User
|
||||
.page-header
|
||||
= title :edit, model_class
|
||||
= render 'form'
|
||||
+10
-14
@@ -2,20 +2,16 @@ Qwaiter::Application.routes.draw do
|
||||
devise_for :users
|
||||
devise_for :suppliers
|
||||
devise_for :administrators
|
||||
|
||||
authenticate :administrator do
|
||||
namespace :admin do
|
||||
resources :users
|
||||
resources :tables
|
||||
resources :orders do
|
||||
member do
|
||||
post :is_being_processed
|
||||
post :is_delivered
|
||||
end
|
||||
end
|
||||
resources :suppliers
|
||||
resources :tables
|
||||
resources :orders
|
||||
|
||||
resources :lists
|
||||
resources :products
|
||||
resources :product_categories
|
||||
root to: 'users#index'
|
||||
end
|
||||
|
||||
# SUPPLIER
|
||||
@@ -39,16 +35,16 @@ Qwaiter::Application.routes.draw do
|
||||
# USER
|
||||
#default_url_options format: 'html'
|
||||
get '/user/home' => 'user#home', as: :user_root
|
||||
match '/user' => 'user#home'
|
||||
get '/user' => 'user#home'
|
||||
get '/user/active_list(.:format)' => 'user#active_list', as: :user_active_list
|
||||
match '/user/list_info' => 'user#list_info', as: :user_list_info, via: [:get, :options]
|
||||
get '/user/list_info' => 'user#list_info', as: :user_list_info, via: [:get, :options]
|
||||
post '/user/needs_help' => 'user#needs_help', as: :user_needs_help
|
||||
post '/user/list_needs_payment' => 'user#list_needs_payment', as: :user_list_needs_payment
|
||||
match '/user/create_list' => 'user#create_list', as: :user_create_list
|
||||
post '/user/create_list' => 'user#create_list', as: :user_create_list
|
||||
get '/user/list_products' => 'user#list_products', as: :user_list_products
|
||||
get '/user/list_products_for_table' => 'user#list_products_for_table', as: :user_list_products_for_table
|
||||
match '/user/list_history' => 'user#list_history', as: :user_list_history
|
||||
match '/user/history_list' => 'user#history_list', as: :user_history_list
|
||||
get '/user/list_history' => 'user#list_history', as: :user_list_history
|
||||
get '/user/history_list' => 'user#history_list', as: :user_history_list
|
||||
post '/user/order_selected_products' => 'user#order_selected_products', as: :user_order_selected_products
|
||||
post '/user/move_table' => 'user#move_table', as: :user_move_table
|
||||
get '/user/table_info' => 'user#table_info', as: :user_table_info
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
require 'rails/generators'
|
||||
require 'rails/generators/generated_attribute'
|
||||
module BjController
|
||||
module Generators
|
||||
class SpecGenerator < ::Rails::Generators::Base
|
||||
source_root File.expand_path('../templates', __FILE__)
|
||||
argument :controller_name, :type => :string, :required => true
|
||||
|
||||
def copy_views
|
||||
generate_views
|
||||
end
|
||||
protected
|
||||
def generate_views
|
||||
template 'controller_spec.rb', File.join('spec/controllers', controller_namespace_path, "#{controller_base_name}_controller_spec.rb")
|
||||
end
|
||||
def controller_namespace_path
|
||||
controller_name.sub(/[^\/]+\Z/, '')
|
||||
end
|
||||
|
||||
def model_plural_name
|
||||
controller_base_name
|
||||
end
|
||||
def model_name
|
||||
model_plural_name.singularize
|
||||
end
|
||||
|
||||
def controller_base_name
|
||||
controller_name.split('/').last.pluralize
|
||||
end
|
||||
|
||||
def controller_class_name
|
||||
"#{controller_name.classify.pluralize}Controller"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,108 @@
|
||||
# encoding: UTF-8
|
||||
require 'spec_helper'
|
||||
|
||||
describe <%= controller_class_name %> do
|
||||
before :each do
|
||||
@administrator = Administrator.find_by_email('administrator@qwaiter.com') || Administrator.create(email: 'administrator@qwaiter.com', password: 'secret')
|
||||
sign_in @administrator
|
||||
end
|
||||
|
||||
describe "GET #index" do
|
||||
it "populates an array of <%= model_plural_name %>" do
|
||||
<%= model_name %> = create :<%= model_name %>
|
||||
get :index
|
||||
assigns(:<%= model_plural_name %>).should eq([<%= model_name %>])
|
||||
end
|
||||
|
||||
it "should render without errors when no objects are present" do
|
||||
get :index
|
||||
expect{ render_template :index }.not_to raise_error
|
||||
end
|
||||
|
||||
it "renders the :index view" do
|
||||
get :index
|
||||
response.should render_template :index
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested <%= model_name %> to @<%= model_name %>" do
|
||||
<%= model_name %> = create :<%= model_name %>
|
||||
get :show, id: <%= model_name %>
|
||||
assigns(:<%= model_name %>).should eq(<%= model_name %>)
|
||||
end
|
||||
|
||||
it "renders the #show view" do
|
||||
<%= model_name %> = create :<%= model_name %>
|
||||
get :show, id: <%= model_name %>
|
||||
response.should render_template :show
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new <%= model_name %> to @<%= model_name %>" do
|
||||
get :new
|
||||
assigns(:<%= model_name %>).should be_a <%= model_name.classify %>
|
||||
end
|
||||
|
||||
it "renders the #show view" do
|
||||
get :new
|
||||
response.should render_template :new
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid attributes" do
|
||||
it "creates a new <%= model_name %>" do
|
||||
expect{
|
||||
post :create, <%= model_name %>: attributes_for(:<%= model_name %>)
|
||||
}.to change(<%= model_name.classify %>, :count).by(1)
|
||||
end
|
||||
|
||||
it "redirects to the new <%= model_name %>" do
|
||||
post :create, <%= model_name %>: attributes_for(:<%= model_name %>)
|
||||
response.should redirect_to <%= controller_namespace_path.present? ? "[#{controller_namespace_path.split('/').map{|n| ":#{n}"}.join(', ')}, #{model_name.classify}.last]" : "#{model_name.classify}.last" %>
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid attributes" do
|
||||
it "does not save the new <%= model_name %>" do
|
||||
expect{
|
||||
post :create, <%= model_name %>: {}
|
||||
}.to_not change(<%= model_name.classify %>, :count)
|
||||
end
|
||||
|
||||
it "re-renders the new method" do
|
||||
post :create, <%= model_name %>: {}
|
||||
response.should render_template :new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT update' do
|
||||
before :each do
|
||||
@<%= model_name %> = create :<%= model_name %>
|
||||
end
|
||||
|
||||
context "valid attributes" do
|
||||
it "located the requested <%= model_name %>" do
|
||||
put :update, id: @<%= model_name %>, <%= model_name %>: attributes_for(:<%= model_name %>)
|
||||
assigns(:<%= model_name %>).should eq(@<%= model_name %>)
|
||||
end
|
||||
|
||||
it "changes @<%= model_name %>'s attributes" do
|
||||
attributes = attributes_for(:<%= model_name %>)
|
||||
attribute_to_change = attributes.keys.find{|k| k !~ /_id$/}
|
||||
attributes[attribute_to_change] = "ChangedByTest"
|
||||
put :update, id: @<%= model_name %>, <%= model_name %>: attributes
|
||||
@<%= model_name %>.reload
|
||||
@<%= model_name %>.send(attribute_to_change).should eq("ChangedByTest")
|
||||
end
|
||||
|
||||
it "redirects to the updated <%= model_name %>" do
|
||||
put :update, id: @<%= model_name %>, <%= model_name %>: attributes_for(:<%= model_name %>)
|
||||
response.should redirect_to <%= controller_namespace_path.present? ? "[#{controller_namespace_path.split('/').map{|n| ":#{n}"}.join(', ')}, @#{model_name}]" : "@#{model_name}" %>
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,21 +0,0 @@
|
||||
require 'acceptance/acceptance_helper'
|
||||
|
||||
feature 'Supplier main board spec.rb', %q{
|
||||
In order to manage active orders
|
||||
As a supplier
|
||||
I want to have control
|
||||
} do
|
||||
background do
|
||||
create_supplier 'supplier@qwaiter.com'
|
||||
create_user 'user@qwaiter.com'
|
||||
end
|
||||
def create_active_list(options = {})
|
||||
|
||||
end
|
||||
|
||||
scenario 'loaded orders should have a list_id present for handling actions' do
|
||||
create_active_list
|
||||
login_supplier_as 'supplier@qwaiter.com'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,46 @@
|
||||
require 'acceptance/acceptance_helper'
|
||||
|
||||
@javascript
|
||||
feature 'Supplier main board spec.rb', %q{
|
||||
In order to manage active orders
|
||||
As a supplier
|
||||
I want to have control
|
||||
} do
|
||||
background do
|
||||
CouchPotato.couchrest_database.recreate!
|
||||
create_supplier 'supplier@qwaiter.com'
|
||||
create_user 'user@qwaiter.com'
|
||||
end
|
||||
def create_active_list(options = {})
|
||||
@table = create :table, supplier: @supplier
|
||||
@list = create :list, supplier: @supplier, table: @table, user_ids: [@user.id]
|
||||
|
||||
end
|
||||
context "using javascript", js: true do
|
||||
scenario 'the active list should be present and contained in row having its id' do
|
||||
create_active_list
|
||||
login_supplier_as 'supplier@qwaiter.com'
|
||||
visit '/supplier'
|
||||
page.should have_selector "#list-row-#{@list.id}"
|
||||
end
|
||||
|
||||
scenario 'order is added to the list before visiting the page' do
|
||||
create_active_list
|
||||
login_supplier_as 'supplier@qwaiter.com'
|
||||
product = create :product, supplier: @supplier
|
||||
sleep 0.1
|
||||
@list.place_order @user, {product.id => 369}
|
||||
visit '/supplier'
|
||||
page.should have_selector ".of-list-#{@list.id}"
|
||||
end
|
||||
|
||||
scenario 'order is added to the list after visiting the page' do
|
||||
create_active_list
|
||||
login_supplier_as 'supplier@qwaiter.com'
|
||||
product = create :product, supplier: @supplier
|
||||
visit '/supplier'
|
||||
@list.place_order @user, {product.id => 369}
|
||||
page.should have_selector ".of-list-#{@list.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,108 @@
|
||||
# encoding: UTF-8
|
||||
require 'spec_helper'
|
||||
|
||||
describe Admin::ProductsController do
|
||||
before :each do
|
||||
@administrator = Administrator.find_by_email('administrator@qwaiter.com') || Administrator.create(email: 'administrator@qwaiter.com', password: 'secret')
|
||||
sign_in @administrator
|
||||
end
|
||||
|
||||
describe "GET #index" do
|
||||
it "populates an array of products" do
|
||||
product = create :product
|
||||
get :index
|
||||
assigns(:products).should eq([product])
|
||||
end
|
||||
|
||||
it "should render without errors when no objects are present" do
|
||||
get :index
|
||||
expect{ render_template :index }.not_to raise_error
|
||||
end
|
||||
|
||||
it "renders the :index view" do
|
||||
get :index
|
||||
response.should render_template :index
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested product to @product" do
|
||||
product = create :product
|
||||
get :show, id: product
|
||||
assigns(:product).should eq(product)
|
||||
end
|
||||
|
||||
it "renders the #show view" do
|
||||
product = create :product
|
||||
get :show, id: product
|
||||
response.should render_template :show
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new product to @product" do
|
||||
get :new
|
||||
assigns(:product).should be_a Product
|
||||
end
|
||||
|
||||
it "renders the #show view" do
|
||||
get :new
|
||||
response.should render_template :new
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid attributes" do
|
||||
it "creates a new product" do
|
||||
expect{
|
||||
post :create, product: attributes_for(:product)
|
||||
}.to change(Product, :count).by(1)
|
||||
end
|
||||
|
||||
it "redirects to the new product" do
|
||||
post :create, product: attributes_for(:product)
|
||||
response.should redirect_to [:admin, Product.last]
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid attributes" do
|
||||
it "does not save the new product" do
|
||||
expect{
|
||||
post :create, product: {}
|
||||
}.to_not change(Product, :count)
|
||||
end
|
||||
|
||||
it "re-renders the new method" do
|
||||
post :create, product: {}
|
||||
response.should render_template :new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT update' do
|
||||
before :each do
|
||||
@product = create :product
|
||||
end
|
||||
|
||||
context "valid attributes" do
|
||||
it "located the requested product" do
|
||||
put :update, id: @product, product: attributes_for(:product)
|
||||
assigns(:product).should eq(@product)
|
||||
end
|
||||
|
||||
it "changes @product's attributes" do
|
||||
attributes = attributes_for(:product)
|
||||
attribute_to_change = attributes.keys.find{|k| k !~ /_id$/}
|
||||
attributes[attribute_to_change] = "ChangedByTest"
|
||||
put :update, id: @product, product: attributes
|
||||
@product.reload
|
||||
@product.send(attribute_to_change).should eq("ChangedByTest")
|
||||
end
|
||||
|
||||
it "redirects to the updated product" do
|
||||
put :update, id: @product, product: attributes_for(:product)
|
||||
response.should redirect_to [:admin, @product]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,164 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
describe UsersController do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# User. As you add validations to User, be sure to
|
||||
# update the return value of this method accordingly.
|
||||
def valid_attributes
|
||||
{}
|
||||
end
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# UsersController. Be sure to keep this updated too.
|
||||
def valid_session
|
||||
{}
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
it "assigns all users as @users" do
|
||||
user = User.create! valid_attributes
|
||||
get :index, {}, valid_session
|
||||
assigns(:users).should eq([user])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
it "assigns the requested user as @user" do
|
||||
user = User.create! valid_attributes
|
||||
get :show, {:id => user.to_param}, valid_session
|
||||
assigns(:user).should eq(user)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
it "assigns a new user as @user" do
|
||||
get :new, {}, valid_session
|
||||
assigns(:user).should be_a_new(User)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET edit" do
|
||||
it "assigns the requested user as @user" do
|
||||
user = User.create! valid_attributes
|
||||
get :edit, {:id => user.to_param}, valid_session
|
||||
assigns(:user).should eq(user)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST create" do
|
||||
describe "with valid params" do
|
||||
it "creates a new User" do
|
||||
expect {
|
||||
post :create, {:user => valid_attributes}, valid_session
|
||||
}.to change(User, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created user as @user" do
|
||||
post :create, {:user => valid_attributes}, valid_session
|
||||
assigns(:user).should be_a(User)
|
||||
assigns(:user).should be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created user" do
|
||||
post :create, {:user => valid_attributes}, valid_session
|
||||
response.should redirect_to(User.last)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns a newly created but unsaved user as @user" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
User.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:user => {}}, valid_session
|
||||
assigns(:user).should be_a_new(User)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
User.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:user => {}}, valid_session
|
||||
response.should render_template("new")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT update" do
|
||||
describe "with valid params" do
|
||||
it "updates the requested user" do
|
||||
user = User.create! valid_attributes
|
||||
# Assuming there are no other users in the database, this
|
||||
# specifies that the User created on the previous line
|
||||
# receives the :update_attributes message with whatever params are
|
||||
# submitted in the request.
|
||||
User.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
|
||||
put :update, {:id => user.to_param, :user => {'these' => 'params'}}, valid_session
|
||||
end
|
||||
|
||||
it "assigns the requested user as @user" do
|
||||
user = User.create! valid_attributes
|
||||
put :update, {:id => user.to_param, :user => valid_attributes}, valid_session
|
||||
assigns(:user).should eq(user)
|
||||
end
|
||||
|
||||
it "redirects to the user" do
|
||||
user = User.create! valid_attributes
|
||||
put :update, {:id => user.to_param, :user => valid_attributes}, valid_session
|
||||
response.should redirect_to(user)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns the user as @user" do
|
||||
user = User.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
User.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => user.to_param, :user => {}}, valid_session
|
||||
assigns(:user).should eq(user)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
user = User.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
User.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => user.to_param, :user => {}}, valid_session
|
||||
response.should render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE destroy" do
|
||||
it "destroys the requested user" do
|
||||
user = User.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, {:id => user.to_param}, valid_session
|
||||
}.to change(User, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the users list" do
|
||||
user = User.create! valid_attributes
|
||||
delete :destroy, {:id => user.to_param}, valid_session
|
||||
response.should redirect_to(users_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
FactoryGirl.define do
|
||||
factory :product do
|
||||
price 34.95
|
||||
association :supplier
|
||||
end
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Users" do
|
||||
describe "GET /users" do
|
||||
it "works! (now write some real specs)" do
|
||||
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
|
||||
get users_path
|
||||
response.status.should be(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,43 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe SupplierController do
|
||||
describe "routing" do
|
||||
|
||||
it "routes root to #home" do
|
||||
get("/supplier").should route_to("supplier#home")
|
||||
end
|
||||
it "routes to #active_orders" do
|
||||
get("/supplier/active_orders").should route_to("supplier#active_orders")
|
||||
end
|
||||
it "routes to #active_lists" do
|
||||
get("/supplier/active_lists").should route_to("supplier#active_lists")
|
||||
end
|
||||
it "routes to #close_list" do
|
||||
post("/supplier/close_list").should route_to("supplier#close_list")
|
||||
end
|
||||
it "routes to #mark_list_as_helped" do
|
||||
post("/supplier/mark_list_as_helped").should route_to("supplier#mark_list_as_helped")
|
||||
end
|
||||
it "routes to #mark_order_in_process" do
|
||||
post("/supplier/mark_order_in_process").should route_to("supplier#mark_order_in_process")
|
||||
end
|
||||
it "routes to #order_is_delivered" do
|
||||
post("/supplier/order_is_delivered").should route_to("supplier#order_is_delivered")
|
||||
end
|
||||
it "routes to #mark_as_open" do
|
||||
post("/supplier/mark_as_open").should route_to("supplier#mark_as_open")
|
||||
end
|
||||
it "routes to #mark_as_closed" do
|
||||
post("/supplier/mark_as_closed").should route_to("supplier#mark_as_closed")
|
||||
end
|
||||
it "routes to #settings" do
|
||||
get("/supplier/settings").should route_to("supplier#edit")
|
||||
end
|
||||
it "routes to #update via put" do
|
||||
put("/supplier/settings").should route_to("supplier#update")
|
||||
end
|
||||
it "routes to #update via post" do
|
||||
post("/supplier/settings").should route_to("supplier#update")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,72 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe UserController do
|
||||
describe "routing" do
|
||||
|
||||
it "routes root to #home" do
|
||||
get("/user").should route_to("user#home")
|
||||
end
|
||||
it "routes to #home" do
|
||||
get("/user/home").should route_to("user#home")
|
||||
end
|
||||
it "routes to #active_list" do
|
||||
get("/user/active_list").should route_to("user#active_list")
|
||||
end
|
||||
it "routes to #list_info" do
|
||||
get("/user/list_info").should route_to("user#list_info")
|
||||
end
|
||||
it "routes to #needs_help" do
|
||||
post("/user/needs_help").should route_to("user#needs_help")
|
||||
end
|
||||
|
||||
it "routes to #list_needs_payment" do
|
||||
post("/user/list_needs_payment").should route_to("user#list_needs_payment")
|
||||
end
|
||||
|
||||
it "routes to #create_list" do
|
||||
post("/user/create_list").should route_to("user#create_list")
|
||||
end
|
||||
it "routes to #list_products" do
|
||||
get("/user/list_products").should route_to("user#list_products")
|
||||
end
|
||||
it "routes to #list_products_for_table" do
|
||||
get("/user/list_products_for_table").should route_to("user#list_products_for_table")
|
||||
end
|
||||
it "routes to #list_history" do
|
||||
get("/user/list_history").should route_to("user#list_history")
|
||||
end
|
||||
it "routes to #history_list" do
|
||||
get("/user/history_list").should route_to("user#history_list")
|
||||
end
|
||||
it "routes to #home" do
|
||||
get("/user/home").should route_to("user#home")
|
||||
end
|
||||
it "routes to #order_selected_products" do
|
||||
post("/user/order_selected_products").should route_to("user#order_selected_products")
|
||||
end
|
||||
it "routes to #move_table" do
|
||||
post("/user/move_table").should route_to("user#move_table")
|
||||
end
|
||||
it "routes to #table_info" do
|
||||
get("/user/table_info").should route_to("user#table_info")
|
||||
end
|
||||
it "routes to #join_occupied_table" do
|
||||
get("/user/join_occupied_table").should route_to("user#join_occupied_table")
|
||||
end
|
||||
it "routes to #join_occupied_table" do
|
||||
post("/user/join_occupied_table").should route_to("user#request_to_join_occupied_table")
|
||||
end
|
||||
it "routes to #reject_join_request" do
|
||||
post("/user/reject_join_request").should route_to("user#reject_join_request")
|
||||
end
|
||||
it "routes to #approve_join_request" do
|
||||
post("/user/approve_join_request").should route_to("user#approve_join_request")
|
||||
end
|
||||
it "routes to #check_table_join_status" do
|
||||
post("/user/check_table_join_status").should route_to("user#check_table_join_status")
|
||||
end
|
||||
it "routes to #obtain_token" do
|
||||
get("/user/obtain_token").should route_to("user#obtain_token")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,35 +0,0 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe UsersController do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
get("/users").should route_to("users#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
get("/users/new").should route_to("users#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
get("/users/1").should route_to("users#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
get("/users/1/edit").should route_to("users#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
post("/users").should route_to("users#create")
|
||||
end
|
||||
|
||||
it "routes to #update" do
|
||||
put("/users/1").should route_to("users#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
delete("/users/1").should route_to("users#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
+10
-1
@@ -11,7 +11,14 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
|
||||
I18n.locale = :en
|
||||
Devise.stretches = 1
|
||||
Capybara.default_driver = :selenium
|
||||
Capybara.javascript_driver = :selenium
|
||||
#Capybara.default_driver = :selenium
|
||||
|
||||
module FactoryAttributesFor
|
||||
def attributes_for(obj, options={})
|
||||
super(obj, options).merge(build(obj).attributes.select{|k,v| k =~ /_id$/}).symbolize_keys
|
||||
end
|
||||
end
|
||||
RSpec.configure do |config|
|
||||
# == Mock Framework
|
||||
#
|
||||
@@ -22,6 +29,7 @@ RSpec.configure do |config|
|
||||
# config.mock_with :rr
|
||||
config.mock_with :rspec
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
config.include FactoryAttributesFor
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.include EndWithMatcher
|
||||
#config.use_transactional_fixtures = true
|
||||
@@ -30,6 +38,7 @@ RSpec.configure do |config|
|
||||
|
||||
# Use color in STDOUT
|
||||
config.color_enabled = true
|
||||
config.fail_fast = true
|
||||
|
||||
# Use color not only in STDOUT but also in pagers and files
|
||||
config.tty = true
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "users/edit" do
|
||||
before(:each) do
|
||||
@user = assign(:user, stub_model(User))
|
||||
end
|
||||
|
||||
it "renders the edit user form" do
|
||||
render
|
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => users_path(@user), :method => "post" do
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "users/index" do
|
||||
before(:each) do
|
||||
assign(:users, [
|
||||
stub_model(User),
|
||||
stub_model(User)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of users" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
end
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "users/new" do
|
||||
before(:each) do
|
||||
assign(:user, stub_model(User).as_new_record)
|
||||
end
|
||||
|
||||
it "renders new user form" do
|
||||
render
|
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => users_path, :method => "post" do
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,12 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "users/show" do
|
||||
before(:each) do
|
||||
@user = assign(:user, stub_model(User))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user