cleanup switch_to supplier and make facebook image https

This commit is contained in:
2020-03-07 11:11:06 -05:00
parent eda3fc280b
commit 68f7d4dd54
6 changed files with 16 additions and 14 deletions
+11
View File
@@ -1,6 +1,17 @@
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
-----------------------------------------------
-1
View File
@@ -14,7 +14,6 @@ class Suppliers::Ability
can :mark_in_process, Order
can :mark_delivered, Order
can :cancel, Order
can :switch_to, Supplier
end
end
end
@@ -17,7 +17,6 @@ module Suppliers
end
# GET
#NOTE: temporary solution for development, if I am in production something is wrong
def employee_and_supplier
# database optimization, preloading
FlatKeys.as_nested_structure(Supplier::PRELOAD_INCLUDES).last.each do |relation_name, includes|
@@ -43,12 +42,14 @@ module Suppliers
def find_current_supplier!
return current_supplier if current_supplier.present?
if session[:supplier_id]
supplier = Supplier.find(session[:supplier_id])
supplier_id = request.headers['HTTP_SUPPLIER_ID'].presence || session[:supplier_id].presence
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)
@current_supplier = supplier
else
session[:supplier_id] = nil
raise CanCan::AccessDenied unless current_employee.active?
end
else
@current_supplier = current_employee.suppliers.first
@@ -29,14 +29,6 @@ module Suppliers
render json: current_supplier
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
current_supplier.mark_as_open!
head :ok
+1 -1
View File
@@ -78,7 +78,7 @@ class User
def avatar
return '' unless provider.present?
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')
end
end
-1
View File
@@ -130,7 +130,6 @@ Qwaiter::Application.routes.draw do
get 'employee_and_supplier', controller: 'application'
resources :suppliers do
member do
post :switch_to
post :mark_as_open
post :mark_as_closed
end