]>
git.frykholm.com Git - tranquillity.git/blob - customerportal/views.py
182086e08fc0b52a9491edd0153876a8ab84d1a2
1 from django
.shortcuts
import render
2 from django
.http
import HttpResponse
3 from django
.contrib
.auth
.decorators
import login_required
4 from django
.conf
import settings
7 except ModuleNotFoundError
as e
:
13 headers
= {"Access-Token":settings
.FORTNOX_ACCESS_TOKEN
,
14 "Client-Secret":settings
.FORTNOX_CLIENT_SECRET
,
15 "Content-Type":"application/json",
16 "Accept":"application/json" }
17 res
= requests
.get("https://api.fortnox.se/3/contracts/", headers
=headers
)
19 contracts
= [contract
for contract
in contracts
['Contracts'] if int(contract
['CustomerNumber']) == request
.user
.fortnox_external_id
]
20 res
= requests
.get("https://api.fortnox.se/3/invoices/", headers
=headers
)
22 invoices
= [invoice
for invoice
in invoices
['Invoices'] if int(invoice
['CustomerNumber']) == request
.user
.fortnox_external_id
]
23 return render(request
, 'customerportal/landing.html',context
={'contracts':contracts
, 'invoices':invoices
})