This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6 | |
Authorization:Bearer "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOjSIsImlhdCI6MTUwMDU1NzMxMiwicm9sZXMiOlsib3JkZXJfZW50cnkiLCJzdG9ja19lbnF1aXJ5IiwiYWNjb3VudF9lbnF1aXJ5Iiwic29sZW50X3N0YWZmIl19.e9Km5qfr4ieoYj4O82-qv3uRA5NyEiN1OHU0unLFOIs3XcYpbcmR7PyqPq_EnAoUuGJGwwhjl-KDjmQTt5qU3w" | |
Connection:keep-alive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "client.py", line 32, in <module> | |
'customerid': 1, | |
File "/home/luke/virts/ecomNew/lib/python3.5/site-packages/requests/api.py", line 112, in post | |
return request('post', url, data=data, json=json, **kwargs) | |
File "/home/luke/virts/ecomNew/lib/python3.5/site-packages/requests/api.py", line 58, in request | |
return session.request(method=method, url=url, **kwargs) | |
File "/home/luke/virts/ecomNew/lib/python3.5/site-packages/requests/sessions.py", line 488, in request | |
prep = self.prepare_request(req) | |
File "/home/luke/virts/ecomNew/lib/python3.5/site-packages/requests/sessions.py", line 431, in prepare_request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header_template = """ Authorization: Bearer "{myJWT}" """ | |
r = requests.post('http://localhost:6542/name.json', | |
headers={header_template.format(myJWT=token)}, | |
data=json.dumps({ | |
'customerid': 1, | |
})) | |
print(r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header_template = """ Authorization: Bearer "{myJWT}" """ | |
r = requests.post('http://localhost:6542/name.json', | |
headers={header_template.format(myJWT=token)}, | |
data=json.dumps({ | |
'customerid': 1, | |
})) | |
print(r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user_dict ={ | |
'userid': loginQuery['user'].id, | |
'user_name': loginQuery['user'].user_name, | |
'roles': ['order_entry', 'stock_enquiry', 'account_enquiry', 'solent_staff'], | |
} | |
return user_dict | |
return { | |
'result': 'ok', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_role_principals(userid, request): | |
return request.jwt_claims.get('roles', []) | |
def main(global_config, **settings): | |
""" This function returns a Pyramid WSGI application. | |
""" | |
config = Configurator(settings=settings) | |
config.include('.cors') | |
config.add_cors_preflight_handler() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyramid.config import Configurator | |
from pyramid.authorization import ACLAuthorizationPolicy | |
from pyramid.security import Allow | |
from pyramid.security import Deny | |
from pyramid.security import Everyone, ALL_PERMISSIONS | |
from pyramid.security import ( | |
Authenticated, | |
Everyone, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component, Input, ViewContainerRef, ViewChild, ReflectiveInjector, ComponentFactoryResolver} from '@angular/core'; | |
import { OrderLineComponent } from '../orderLine/orderline.component'; | |
import * as orderhead from '../_actions/orderhead'; | |
import * as fromRoot from '../_ngrx_reducers/index'; | |
import { Subscription } from 'rxjs/Subscription'; | |
import {Store, provideStore} from '@ngrx/store'; | |
import { OrderHead, StockRefResponse } from '../_models/index'; | |
import { Observable } from 'rxjs/Observable'; | |
import { OrderNumberStreamService } from '../_services/order-number.service'; | |
@Component({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find nearest value in array | |
def find_nearest(array, value): | |
n = [abs(i-value) for i in array] | |
idx = n.index(min(n)) | |
return array[idx] | |
# largestCut = Decimal(5.20) | |
# stockList = [Decimal(9.00), Decimal(3.00)] | |
largestCutAllocation = find_nearest(stockList, largestCut) | |
print (largestCutAllocation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Range(BasePY): | |
__tablename__ = 'ranges' | |
id = Column(Integer, primary_key=True, unique=True) | |
name = Column(String) | |
stock_type = Column(Integer) | |
range_backings = relationship('Backing', | |
secondary='backings_to_range', | |
backref='ranges') | |
def as_dict(self): |