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

Commit

Permalink
Release v0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
OGKevin committed Jul 2, 2017
1 parent 17dd482 commit 4c0eaf3
Show file tree
Hide file tree
Showing 30 changed files with 352 additions and 240 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,11 @@ tmp/
static/semantic/tasks
static/semantic/src
static/semantic/dist/components
/keyrings/live/pubring.gpg~
/keyrings/live/pubring.kbx~
/keyrings/live/secring.gpg
/Caddyfile
/uwsgi.ini
/BunqWebApp/config.yaml
/uwsgi-develop.ini
Android Emulator
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
- sudo /etc/init.d/postgresql stop
- wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key
add -
- sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
9.5" >> /etc/apt/sources.list.d/postgresql.list'
- sudo apt-get update
- sudo apt-get install postgresql-9.5
- npm install -g bower
- bower install
# - sudo /etc/init.d/postgresql stop
# - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key
# add -
# - sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
# 9.5" >> /etc/apt/sources.list.d/postgresql.list'
# - sudo apt-get update
# - sudo apt-get install postgresql-9.5
- psql -c "CREATE DATABASE travisci;" -U postgres
- ./manage.py migrate
- ./manage.py collectstatic --noinput -v 0
Expand Down
3 changes: 2 additions & 1 deletion BunqAPI/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ def get_payment_pdf(self):

try:
pdf = Creator(self._user,
'pdf').payment(payment['Response'][0])
'pdf').payment(payment['Response'][0],
transaction_id=self.payment_id)
except KeyError: # pragma: no cover
error_msg = payment['Error'][0]['error_description_translated']
error = {
Expand Down
Binary file added BunqWebApp/config.yaml.gpg
Binary file not shown.
50 changes: 36 additions & 14 deletions BunqWebApp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@

import os
import dj_database_url
from ruamel.yaml import YAML
from box import Box
import pathlib
# import raven
# from django.core.urlresolvers import reverse_lazy

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

config_file = pathlib.Path(os.path.join(BASE_DIR, 'BunqWebApp/config.yaml'))
if config_file.is_file():
config = Box(YAML(typ='safe').load(pathlib.Path(
os.path.join(BASE_DIR,
'BunqWebApp/config.yaml')))) # noqa
else:
config = None

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
Expand All @@ -44,21 +53,33 @@
Exception('Please create a %s file with random characters \
to generate your secret key!' % SECRET_FILE)

DEBUG = True
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False
DESABLE_LOGGERS = False
SANDBOX = True
ALLOWED_HOSTS = ['*']
USE_PROXY = False
PROXY_URI = 'url'
TELEGRAM_TOKEN = None
if config is not None:
DEBUG = True if str(config.DEBUG) == 'True' else False
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False
DESABLE_LOGGERS = False
SANDBOX = True if str(config.SANDBOX) == 'True' else False
ALLOWED_HOSTS = ['*']
USE_PROXY = True if str(config.USE_PROXY) == 'True' else False
PROXY_URI = config.PROXY_URI
TELEGRAM_TOKEN = None if str(config.TELEGRAM_TOKEN) == "None" else config\
.TELEGRAM_TOKEN # noqa

else:
DEBUG = True
SANDBOX = True
DESABLE_LOGGERS = False
ALLOWED_HOSTS = ['*']
USE_PROXY = False
TELEGRAM_TOKEN = None

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

RAVEN_CONFIG = {
'dsn': None,

if config is not None and config.DSN is not 'None':
RAVEN_CONFIG = {
'dsn': config.DSN if str(config.DSN) != "None" else None,
}

# Application definition
Expand Down Expand Up @@ -180,7 +201,8 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'KevinH',
'NAME': 'khellemun' if config is None else config.DATABASE.NAME,
'USER': None if config is None else config.DATABASE.USER
}
}
db_from_env = dj_database_url.config()
Expand Down Expand Up @@ -230,7 +252,7 @@
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static-files')
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), os.path.join(
BASE_DIR, 'node_modules')]
BASE_DIR, 'node_modules'), os.path.join(BASE_DIR, 'bower_components')]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
Expand Down
26 changes: 15 additions & 11 deletions BunqWebApp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ def post(self, request):
password = form.cleaned_data['password']
file_contents = request.FILES['user_file'].read().decode()

self.authenticate_user(username, password, request)
user = self.authenticate_user(username, password, request)
session = self.store_in_session(file_contents, password, username)
if session is not False:
if session:
self.check_bunq_session(username)
login(request, user)
return redirect('my_bunq')
else:
messages.error(request=request,
Expand All @@ -133,7 +134,12 @@ def post(self, request):
def authenticate_user(username, password, request):
user = authenticate(username=username, password=password)
if user is not None:
login(request, user)
# login(request, user)
'''
This will always be called because users is being authenticated
in the form.
'''
return user

@staticmethod
def store_in_session(data, password, username):
Expand All @@ -143,7 +149,7 @@ def store_in_session(data, password, username):
try:
dec_data = signing.loads(data['secret'], key=password)
except signing.BadSignature:
return False
return None

enc_data = signing.dumps(dec_data)

Expand All @@ -152,6 +158,7 @@ def store_in_session(data, password, username):
s.create()
user.session.session_token = s.session_key
user.save()
return True

@staticmethod
def check_bunq_session(username):
Expand Down Expand Up @@ -203,13 +210,13 @@ def post(self, request):
password = form.cleaned_data['password']
encryption_password = form.cleaned_data['encryption_password']
user_file = request.FILES['user_file']
self.authenticate_user(username=username, password=password,
request=request)
user = self.authenticate_user(username=username, password=password,
request=request)
api_key = self.decrypt_file(user_file=user_file,
encryption_password=encryption_password) # noqa
if api_key is not False:
print(api_key)
form = self.generate_form(initial={'API': api_key})
login(request, user)
return render(request, 'BunqAPI/index.html',
{'form': form})
else:
Expand All @@ -224,10 +231,7 @@ def post(self, request):
def authenticate_user(username, password, request):
user = authenticate(username=username, password=password)
if user is not None:
login(request, user)
return True
else:
return False
return user

@staticmethod
def decrypt_file(user_file, encryption_password):
Expand Down
Binary file added Caddyfile.gpg
Binary file not shown.
14 changes: 14 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

0.7.1 / 2017-07-02
==================

* View transactions easier
* Scheduled daily dependency update on sunday (#107)
* Scheduled daily dependency update on tuesday (#104)
* Using blackbox to encrypt/decrypt config files
* Transaction id is now in file name(#100)
* User gets logged in after successful decryption(#102)
* Cleaned JS after #88
* Easier to export a transaction and view transaction details(#100)
* Scheduled daily dependency update on friday (#98)
* Update links to https://bunqweb.com
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Community BunqWeb is going to be a web interface for bunqers using the [Bunq API



View the app live based on the latest [release]: <https://combunqweb.herokuapp.com/>
View the app live based on the latest [release]: <https://bunqweb.com/>

View the [wiki] for more information.

Expand All @@ -47,10 +47,10 @@ 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
- Use the bunq API to view your transactions
- Export your latest invoice
- Export the shown transactions in CSV format

- Export a bunq official transactions overview

# Why Community ?

Expand Down Expand Up @@ -96,8 +96,6 @@ MIT

[django]:<https://www.djangoproject.com/>

[heroku]:<https://www.heroku.com/>

[npm]:<https://www.npmjs.com/>

[virtualenv]:<https://virtualenv.pypa.io/en/stable/>
Expand Down
2 changes: 1 addition & 1 deletion Wiki
Submodule Wiki updated from eaaf1b to 8a7798
25 changes: 25 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "communitybunqweb",
"description": "Bunq web interface made by bunqers",
"main": "./manage.py",
"authors": [
"OGKevin <Kevinhellemun@icloud.com>"
],
"license": "MIT",
"keywords": [
"bunq",
"pyhton",
"django"
],
"homepage": "https://github.com/OGKevin/ComBunqWebApp",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"bPopup": "bpopup#^0.11.0"
}
}
11 changes: 6 additions & 5 deletions bunq_bot/responses/commands/start.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Hi I'm a bot, the bunq-bot here to help you the best way I can.

I can help you with:
Nothing at the moment :(
My commands are:
/start `To start receiving automatic messages.`
/stop `To stop receiving automatic messages. This command should also be used before you want to remove me.`
/news `Shows the recent 5 blog posts from bunq.`
/help `Displays a help message.`

If you need help you can use the /help command.

My source code can be found [here](https://github.com/OGKevin/bunq-bot).
My source code can be found [here](https://github.com/OGKevin/ComBunqWebApp/tree/master/bunq_bot).
18 changes: 12 additions & 6 deletions filecreator/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, user, extension=None):
self.user = user
self.extension = extension

def payment(self, data):
def payment(self, data, transaction_id=None):
data['Payment']['amount']['value'] = float(
data['Payment']['amount']['value'])

Expand All @@ -38,7 +38,8 @@ def payment(self, data):
)).replace('.', ',')

if self.extension == 'pdf':
file_path = self.pdf(data['Payment'], 'payment.html')
file_path = self.pdf(data['Payment'], 'payment.html',
prefix=transaction_id)

self.store_in_session(file_path)

Expand Down Expand Up @@ -158,7 +159,7 @@ def csv(headers, rows):
return temp_file.name

@staticmethod
def pdf(data, template):
def pdf(data, template, prefix=None):
html_string = render_to_string(
'filecreator/pdf/%s' % template, {'data': data}
)
Expand All @@ -177,24 +178,29 @@ def pdf(data, template):

pdf = pdfkit.from_string(html_string, False, options=options)

temp_file = Creator.temp_file('.pdf')
temp_file = Creator.temp_file('.pdf', append_prefix=prefix)
temp_file.write(pdf)
temp_file.close()

return temp_file.name

@staticmethod
def temp_file(extension, bytes_=True):
def temp_file(extension, bytes_=True, append_prefix=None):
if bytes_ is True:
mode = 'wb'
else:
mode = 'w'

if append_prefix is not None:
prefix = "ComBunqWebApp-pr-%s-pr-" % append_prefix
else:
prefix = "ComBunqWebApp"

temp_file = tempfile.NamedTemporaryFile(
mode=mode,
dir=None,
suffix='%s' % extension,
prefix='ComBunqWebApp',
prefix=prefix,
delete=False
)
return temp_file
12 changes: 10 additions & 2 deletions filecreator/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ def get(self, request):
session_key=user.tokens.file_token
).get_decoded()["file_path"]

file_name = os.path.basename(file_path).split('-pr-')
if len(file_name) >= 3:
transaction_id = "_%s" % file_name[1]
else:
transaction_id = ''

file_extension = os.path.splitext(file_path)[1]

with open(file_path, 'rb') as f:
response = HttpResponse(f.read(), content_type="application/force-download") # noqa
response = HttpResponse(f.read(),
content_type="application/force-download")
response['Content-Disposition'] = 'attachment; filename=%s' % smart_str( # noqa
'ComBunqWebApp_%s%s' % (user, file_extension))
'ComBunqWebApp_%s%s%s' % (user, transaction_id,
file_extension))
try:
return response
# except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions keyrings/live/blackbox-admins.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OGKevin
4 changes: 4 additions & 0 deletions keyrings/live/blackbox-files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BunqWebApp/config.yaml
Caddyfile
uwsgi-develop.ini
uwsgi.ini
Binary file added keyrings/live/pubring.kbx
Binary file not shown.
Binary file added keyrings/live/trustdb.gpg
Binary file not shown.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"keywords": [
"bunq",
"pyhton",
"django",
"heroku"
"django"
],
"author": "OGKevin <Kevinhellemun@icloud.com>",
"license": "MIT",
Expand Down
Loading

0 comments on commit 4c0eaf3

Please sign in to comment.