Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
OGKevin committed May 29, 2017
2 parents 3887da5 + 2953281 commit 9fa2528
Show file tree
Hide file tree
Showing 30 changed files with 167 additions and 66 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python
dist: trusty
python:
- 3.5.1
- 3.6.1
addons:
postgresql: '9.6'
Expand Down
93 changes: 72 additions & 21 deletions BunqAPI/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.sessions.models import Session
from django.core.exceptions import ObjectDoesNotExist
# from apiwrapper.endpoints.controller import Controller as Endpoints # noqa
from apiwrapper.clients.api_client import ApiClient as API2 # noqa
import requests
import json
import base64
import tempfile
import time
# from pprint import pprint


class callback(AESCipher):
Expand Down Expand Up @@ -68,6 +69,39 @@ def register(self):
r = self.init_api.endpoints.device_server.create_new_device_server('ComBunqWebApp') # noqa
return r

def load_file(self):
start_session = self.start_session()

try:
start_session['Response']
except KeyError:
return start_session
else:
try:
userID = start_session['Response'][2]['UserCompany']['id']
except KeyError:
userID = start_session['Response'][2]['UserPerson']['id']

self.userID = userID

time.sleep(1.5)

accounts = self.accounts()

self.accountID = accounts['Response'][0]['MonetaryAccountBank']['id'] # noqa

time.sleep(1.5)

payments = self.payment()

response = {
'start_session': start_session['Response'],
'accounts': accounts['Response'],
'payments': payments['Response']
}

return response

def start_session(self):
'''
Starts a server-session according to
Expand All @@ -85,28 +119,36 @@ def start_session(self):
'''
r = self.init_api.endpoints.session_server.create_new_session_server()

try:
session_token = r.json()['Response'][1]['Token']['token']
except KeyError: # pragma: no cover
return r.json()
else:
s = SessionStore()
s['session_token'] = session_token
s.create()
self.user.profile.session_token = s.session_key
self.user.save()

if r.status_code == 200:
try:
avatar_id = r.json()[
'Response'][2]['UserCompany']['avatar']['image'][0]['attachment_public_uuid'] # noqa
except KeyError:
avatar_id = r.json()[
'Response'][2]['UserPerson']['avatar']['image'][0]['attachment_public_uuid'] # noqa
self.get_avatar(avatar_id)
session_token = r.json()['Response'][1]['Token']['token']
except KeyError: # pragma: no cover
return r.json()
else:
self.get_avatar(avatar_id)
s = SessionStore()
s['session_token'] = session_token
s.create()
self.user.profile.session_token = s.session_key
self.user.save()

return r.json()
try:
avatar_id = r.json()[
'Response'][2]['UserCompany']['avatar']['image'][0]['attachment_public_uuid'] # noqa
except KeyError:
avatar_id = r.json()[
'Response'][2]['UserPerson']['avatar']['image'][0]['attachment_public_uuid'] # noqa
self.get_avatar(avatar_id)
else:
self.get_avatar(avatar_id)

return r.json()
else:
error = {
'Error': [{
'error_description_translated': 'Something went wrong starting the session' # noqa
}]
}
return error

def users(self):
'''
Expand Down Expand Up @@ -252,7 +294,16 @@ def get_pdf(invoice):
}
return r
else:
return get_pdf(json.dumps(r['Response'][0]['Invoice']))
try:
invoice = r['Response'][0]['Invoice']
except IndexError:
error = {
'Error': [{
'error_description_translated': 'the response seems to have no invoice in it.'}] # noqa
}
return error
else:
return get_pdf(json.dumps(invoice))

def get_avatar(self, avatar_id):
r = self.init_api.endpoints.attachment_public.get_content_of_public_attachment(avatar_id) # noqa
Expand Down
11 changes: 3 additions & 8 deletions BunqAPI/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from cryptography.hazmat.primitives.asymmetric import rsa
from apiwrapper.clients.api_client import ApiClient as API # noqa
from BunqAPI.encryption import AESCipher
import requests
# from django.contrib.auth.models import User
import json
import uuid
# from pprint import pprint


Expand Down Expand Up @@ -35,10 +34,8 @@ def __init__(self, user, password, API_KEY):
self.r = self.get_token()

def get_GUID(self):
url = 'https://www.uuidgenerator.net/api/guid'
GUID = requests.get(url).content.decode()
return GUID
# using UUIDGenerator.net for GUID
GUID = uuid.uuid4()
return str(GUID)

def get_token(self):
rsa_key = self.RSA_key
Expand All @@ -62,13 +59,11 @@ def encrypt(self):
'privateKey': self.RSA_key,
'API': self.API_KEY,
'ServerPublicKey': self.r['ServerPublicKey']
# NOTE: need to add this
}
if len(self.user_guid) > 1:
del self.user_guid[0]

self.user_guid.append(self.GUID)
# self.user.save()
k = AESCipher(self.password)
secret = AESCipher.encrypt(k, json.dumps(d))
d2 = {
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ Community BunqWeb is going to be a web interface for bunqers using the [Bunq API



***Disclaimer: Bunq itself has nothing to do with this project.
This app is still in development and is not ready to be used with real world API keys.***
***Disclaimer: Bunq itself has nothing to do with this project.***



Expand Down Expand Up @@ -48,6 +47,9 @@ View the [wiki] for more information.


- Use Bunq CSV file and see a Pie Charts of Income, Expanses, Transcation Names and Percentages
- User the bunq API to view your transactions
- Export your latest invoice
- Export the shown transactions in CSV format


# Why Community ?
Expand Down
2 changes: 1 addition & 1 deletion Wiki
Submodule Wiki updated from bc99a9 to 4b5720
2 changes: 1 addition & 1 deletion apiwrapper/clients/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ApiClient:
__variables = ['installation_id', 'installation_token', 'api_key',
'server_token', 'server_pubkey', 'session_token']

def __init__(self, privkey, use_sandbox=False, **kwargs):
def __init__(self, privkey, use_sandbox=True, **kwargs):
self.privkey = privkey
self._uri = self._uri_sandbox if use_sandbox else self._uri_production
self._handle_kwargs(kwargs)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "communitybunqweb",
"version": "0.5.2",
"version": "0.5.3",
"description": "Bunq web interface made by bunqers",
"main": "./manage.py",
"scripts": {
Expand Down
55 changes: 24 additions & 31 deletions static/BunqAPI/JS/decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,30 @@ $(function() {
$("#encryption_form").submit(function(event) {
/* Act on the event */
event.preventDefault()
firstCall()
});
$("#load_file").click(function(event) {
firstCall()
get_file()
deactivateItems()
$(this).addClass('active')

});

function firstCall() {
$("#user_accounts").css('visibility', 'hidden');
setTimeout(function () {
sendPost(jsonObj, "load_file", false)

}, 500)
});

$("#load_file").click(function(event) {
// firstCall()
get_file()
setTimeout(function() {

if (jsonObj) {

$("#loading").html('File is loaded... Starting session')

sendPost(jsonObj, "start_session", start_session_template)

setTimeout(function() {
sendPost(jsonObj, "accounts" + '/' + get_user_id(), accounts_template)

}, 3000)

setTimeout(function() {
sendPost(jsonObj, "payment" + '/' + get_user_id() + '/' + get_account_id(), payments_template)

}, 5000)
} else {
alert('You must load a file fist')
}
deactivateItems()
$(this).addClass('active')


setTimeout(function () {
sendPost(jsonObj, "load_file", false)

}, 500)

}


});

$('#register').click(function(event) {
deactivateItems()
Expand Down Expand Up @@ -149,7 +136,13 @@ function sendPost(json, action, template) {

if (action.match(/start_session/)) {
show(r.Response, false, template, "start_session")


} else if (action.match(/load_file/)) {
show(r.start_session, false, start_session_template, 'start_session')
show(r.accounts, false, accounts_template, 'accounts')
createTable(r.payments)


} else if (action.match(/accounts/)) {
show(r.Response, false, template, "accounts")
} else if (action.match(/payment/)) {
Expand Down
11 changes: 11 additions & 0 deletions static/faviconit/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="./favicon-70.png"/>
<square150x150logo src="./favicon-150.png"/>
<square310x310logo src="./favicon-310.png"/>
<TileColor>#FFFFFF</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added static/faviconit/favicon-114.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-160.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-310.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon-96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/faviconit/favicon.ico
Binary file not shown.
25 changes: 25 additions & 0 deletions static/faviconit/faviconit-instructies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
bedankt voor het gebruiken van faviconit!
kopieër de bestanden naar je site en voeg deze code toe aan de <HEAD> tag in je HTML:

<!-- ****** faviconit.com favicons ****** -->
<link rel="shortcut icon" href="/favicon.ico">
<link rel="icon" sizes="16x16 32x32 64x64" href="/favicon.ico">
<link rel="icon" type="image/png" sizes="196x196" href="/favicon-192.png">
<link rel="icon" type="image/png" sizes="160x160" href="/favicon-160.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96.png">
<link rel="icon" type="image/png" sizes="64x64" href="/favicon-64.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16.png">
<link rel="apple-touch-icon" href="/favicon-57.png">
<link rel="apple-touch-icon" sizes="114x114" href="/favicon-114.png">
<link rel="apple-touch-icon" sizes="72x72" href="/favicon-72.png">
<link rel="apple-touch-icon" sizes="144x144" href="/favicon-144.png">
<link rel="apple-touch-icon" sizes="60x60" href="/favicon-60.png">
<link rel="apple-touch-icon" sizes="120x120" href="/favicon-120.png">
<link rel="apple-touch-icon" sizes="76x76" href="/favicon-76.png">
<link rel="apple-touch-icon" sizes="152x152" href="/favicon-152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/favicon-180.png">
<meta name="msapplication-TileColor" content="#FFFFFF">
<meta name="msapplication-TileImage" content="/favicon-144.png">
<meta name="msapplication-config" content="/browserconfig.xml">
<!-- ****** faviconit.com favicons ****** -->
25 changes: 25 additions & 0 deletions templates/Home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,31 @@
<link rel="stylesheet" href="{%static "font-awesome/css/font-awesome.min.css"%}"/>
<link rel="stylesheet" href="{%static "assets/css/main.css"%}" />
<!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><![endif]-->

<!-- ****** faviconit.com favicons ****** -->
<link rel="shortcut icon" href="{%static "faviconit/favicon.ico"%}">
<link rel="icon" sizes="16x16 32x32 64x64" href="{%static "faviconit/favicon.ico"%}">
<link rel="icon" type="image/png" sizes="196x196" href="{%static "faviconit/favicon-192.png"%}">
<link rel="icon" type="image/png" sizes="160x160" href="{%static "faviconit/favicon-160.png"%}">
<link rel="icon" type="image/png" sizes="96x96" href="{%static "faviconit/favicon-96.png"%}">
<link rel="icon" type="image/png" sizes="64x64" href="{%static "faviconit/favicon-64.png"%}">
<link rel="icon" type="image/png" sizes="32x32" href="{%static "faviconit/favicon-32.png"%}">
<link rel="icon" type="image/png" sizes="16x16" href="{%static "faviconit/favicon-16.png"%}">
<link rel="apple-touch-icon" href="{%static "faviconit/favicon-57.png"%}">
<link rel="apple-touch-icon" sizes="114x114" href="{%static "faviconit/favicon-114.png"%}">
<link rel="apple-touch-icon" sizes="72x72" href="{%static "faviconit/favicon-72.png"%}">
<link rel="apple-touch-icon" sizes="144x144" href="{%static "faviconit/favicon-144.png"%}">
<link rel="apple-touch-icon" sizes="60x60" href="{%static "faviconit/favicon-60.png"%}">
<link rel="apple-touch-icon" sizes="120x120" href="{%static "faviconit/favicon-120.png"%}">
<link rel="apple-touch-icon" sizes="76x76" href="{%static "faviconit/favicon-76.png"%}">
<link rel="apple-touch-icon" sizes="152x152" href="{%static "faviconit/favicon-152.png"%}">
<link rel="apple-touch-icon" sizes="180x180" href="{%static "faviconit/favicon-180.png"%}">
<meta name="msapplication-TileColor" content="#FFFFFF">
<meta name="msapplication-TileImage" content="{%static "faviconit/favicon-144.png"%}">
<meta name="msapplication-config" content="{%static "faviconit/browserconfig.xml"%}">
<!-- ****** faviconit.com favicons ****** -->


</head>
<body class="homepage">
<div id="page-wrapper">
Expand Down

0 comments on commit 9fa2528

Please sign in to comment.