work off today

This commit is contained in:
2020-02-25 11:09:27 -05:00
parent da2ba6230d
commit 8740300b9a
34 changed files with 657 additions and 662 deletions
@@ -1,8 +1,9 @@
module Admin
class ApplicationController < ::ApplicationController
before_action :setup_administrator!
load_and_authorize_resource
#load_and_authorize_resource
layout 'cmtool/application'
private
def setup_administrator!
@@ -1,9 +1,8 @@
module Admin
class EmployeesController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
skip_before_filter :setup_administrator!, only: :test_login
skip_authorize_resource only: :test_login
skip_before_filter :set_locale, only: :test_login
before_action :set_relation_options, only: [:new, :edit, :create, :update]
skip_before_action :setup_administrator!, only: :test_login
skip_before_action :set_locale, only: :test_login
# GET /employees
# GET /employees.json
def index
+2 -2
View File
@@ -1,7 +1,7 @@
# encoding: UTF-8
module Admin
module Admin
class ListsController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
before_action :set_relation_options, only: [:new, :edit, :create, :update]
# GET /lists
# GET /lists.json
def index
+2 -2
View File
@@ -1,7 +1,7 @@
# encoding: UTF-8
module Admin
module Admin
class OrdersController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
before_action :set_relation_options, only: [:new, :edit, :create, :update]
# GET /orders
# GET /orders.json
def index
@@ -1,7 +1,7 @@
# encoding: UTF-8
module Admin
class ProductCategoriesController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
before_action :set_relation_options, only: [:new, :edit, :create, :update]
# GET /product_categories
# GET /product_categories.json
def index
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: UTF-8
module Admin
class ProductsController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
before_action :set_relation_options, only: [:new, :edit, :create, :update]
# GET /products
# GET /products.json
def index
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: UTF-8
module Admin
class SectionsController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
before_action :set_relation_options, only: [:new, :edit, :create, :update]
# GET /sections
# GET /sections.json
def index
@@ -1,7 +1,7 @@
module Admin
class SuppliersController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
skip_before_filter :authenticate_administrator!, only: :test_login
before_action :set_relation_options, only: [:new, :edit, :create, :update]
skip_before_action :setup_administrator!, only: :test_login
# GET /suppliers
# GET /suppliers.json
def index
+2 -2
View File
@@ -1,7 +1,7 @@
# encoding: UTF-8
module Admin
module Admin
class TablesController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
before_action :set_relation_options, only: [:new, :edit, :create, :update]
# GET /tables
# GET /tables.json
def index
+2 -3
View File
@@ -1,8 +1,7 @@
module Admin
class UsersController < Admin::ApplicationController
skip_before_filter :setup_administrator!, only: :test_login
skip_authorize_resource only: :test_login
skip_before_filter :set_locale, only: :test_login
skip_before_action :setup_administrator!, only: :test_login
skip_before_action :set_locale, only: :test_login
# GET /users
# GET /users.json
def index
+6 -6
View File
@@ -16,10 +16,10 @@ class ApplicationController < ActionController::Base
private
def allow_all_origins
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = '*'
headers['Access-Control-Allow-Methods'] = '*'
headers['Access-Control-Allow-Headers'] = '*'
headers['Access-Control-Allow-Methods'] = '*'
end
#START CMTOOL
@@ -89,9 +89,9 @@ private
def after_sign_in_path_for(resource)
case resource
when Employee then supplier_root_path
when Administrator then cmtool.root_path
else root_path
when Employee then supplier_root_path
when Administrator then cmtool.root_path
else root_path
end
end
@@ -1,7 +1,10 @@
module Suppliers
class ApplicationController < ::ApplicationController
before_action :setup_employee_and_supplier!
load_and_authorize_resource
#load_and_authorize_resource
if Rails.env.development?
skip_before_action :setup_employee_and_supplier!, only: :employee_and_supplier
end
attr_reader :current_supplier
helper_method :current_supplier
layout 'supplier/app'
@@ -16,6 +19,16 @@ module Suppliers
end
end
# GET
def employee_and_supplier
employee = current_employee || Employee.find_by_email('bterkuile@gmail.com')
supplier = current_supplier || employee.suppliers.first
render json: {
employee: JSONAPI::Serializer.serialize(employee, serializer: Suppliers::EmployeeSerializer),
supplier: JSONAPI::Serializer.serialize(supplier, serializer: Suppliers::SupplierSerializer)
}
end
def setup_employee_and_supplier!
authenticate_employee!
find_current_supplier!
@@ -1,4 +1,5 @@
class Suppliers::SessionsController < Devise::SessionsController
respond_to :json
def destroy
session[:supplier_id] = nil