cleanup switch_to supplier and make facebook image https
This commit is contained in:
@@ -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
|
||||
-----------------------------------------------
|
||||
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user