cleanup switch_to supplier and make facebook image https
This commit is contained in:
@@ -1,6 +1,17 @@
|
|||||||
Mozo server backend README
|
Mozo server backend README
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
------------------
|
||||||
|
### Supplier app
|
||||||
|
* model validations
|
||||||
|
* ~foundation css~
|
||||||
|
* entry funnel handling
|
||||||
|
|
||||||
|
### User app
|
||||||
|
* Supplier close as event that can be handled by users
|
||||||
|
|
||||||
|
|
||||||
Application architecture
|
Application architecture
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class Suppliers::Ability
|
|||||||
can :mark_in_process, Order
|
can :mark_in_process, Order
|
||||||
can :mark_delivered, Order
|
can :mark_delivered, Order
|
||||||
can :cancel, Order
|
can :cancel, Order
|
||||||
can :switch_to, Supplier
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ module Suppliers
|
|||||||
end
|
end
|
||||||
|
|
||||||
# GET
|
# GET
|
||||||
#NOTE: temporary solution for development, if I am in production something is wrong
|
|
||||||
def employee_and_supplier
|
def employee_and_supplier
|
||||||
# database optimization, preloading
|
# database optimization, preloading
|
||||||
FlatKeys.as_nested_structure(Supplier::PRELOAD_INCLUDES).last.each do |relation_name, includes|
|
FlatKeys.as_nested_structure(Supplier::PRELOAD_INCLUDES).last.each do |relation_name, includes|
|
||||||
@@ -43,12 +42,14 @@ module Suppliers
|
|||||||
|
|
||||||
def find_current_supplier!
|
def find_current_supplier!
|
||||||
return current_supplier if current_supplier.present?
|
return current_supplier if current_supplier.present?
|
||||||
if session[:supplier_id]
|
supplier_id = request.headers['HTTP_SUPPLIER_ID'].presence || session[:supplier_id].presence
|
||||||
supplier = Supplier.find(session[:supplier_id])
|
if supplier_id and supplier_id != 'null' and supplier_id != 'undefined' # crying face icon! but javascript nulls and ruby presence are not brothers
|
||||||
|
supplier = Supplier.find(supplier_id)
|
||||||
if supplier.employee_ids.include?(current_employee.id)
|
if supplier.employee_ids.include?(current_employee.id)
|
||||||
@current_supplier = supplier
|
@current_supplier = supplier
|
||||||
else
|
else
|
||||||
session[:supplier_id] = nil
|
session[:supplier_id] = nil
|
||||||
|
raise CanCan::AccessDenied unless current_employee.active?
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@current_supplier = current_employee.suppliers.first
|
@current_supplier = current_employee.suppliers.first
|
||||||
|
|||||||
@@ -29,14 +29,6 @@ module Suppliers
|
|||||||
render json: current_supplier
|
render json: current_supplier
|
||||||
end
|
end
|
||||||
|
|
||||||
def switch_to
|
|
||||||
@switch_supplier = Supplier.find(params[:id])
|
|
||||||
#TODO sessions currently not working, just tokens
|
|
||||||
session[:supplier_id] = @switch_supplier.id if @switch_supplier.employee_ids.include? current_employee.id
|
|
||||||
render json: {ok: true}
|
|
||||||
#redirect_to supplier_root_path(other: '/my-account')
|
|
||||||
end
|
|
||||||
|
|
||||||
def mark_as_open
|
def mark_as_open
|
||||||
current_supplier.mark_as_open!
|
current_supplier.mark_as_open!
|
||||||
head :ok
|
head :ok
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ class User
|
|||||||
def avatar
|
def avatar
|
||||||
return '' unless provider.present?
|
return '' unless provider.present?
|
||||||
case provider.to_sym
|
case provider.to_sym
|
||||||
when :facebook then "http://graph.facebook.com/#{uid}/picture?type=square"
|
when :facebook then "https://graph.facebook.com/#{uid}/picture?type=square"
|
||||||
when :instagram then auth_data['info'].try(:[], 'image')
|
when :instagram then auth_data['info'].try(:[], 'image')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -130,7 +130,6 @@ Qwaiter::Application.routes.draw do
|
|||||||
get 'employee_and_supplier', controller: 'application'
|
get 'employee_and_supplier', controller: 'application'
|
||||||
resources :suppliers do
|
resources :suppliers do
|
||||||
member do
|
member do
|
||||||
post :switch_to
|
|
||||||
post :mark_as_open
|
post :mark_as_open
|
||||||
post :mark_as_closed
|
post :mark_as_closed
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user