Use ISIN numbers instead of share symbols and add comment field to database.
Fixes #65
This commit is contained in:
@@ -2,13 +2,12 @@ __author__ = "Florian Kaiser"
|
||||
__copyright__ = "Copyright 2022, Project Aktienbot"
|
||||
__credits__ = ["Florian Kaiser", "Florian Kellermann", "Linus Eickhof", "Kevin Pauer"]
|
||||
__license__ = "GPL 3.0"
|
||||
__version__ = "1.0.0"
|
||||
__version__ = "1.0.1"
|
||||
|
||||
import datetime
|
||||
import os
|
||||
|
||||
from apiflask import abort, APIBlueprint
|
||||
|
||||
from app.auth import auth
|
||||
from app.db import database as db
|
||||
from app.helper_functions import make_response, get_email_or_abort_401
|
||||
@@ -28,12 +27,15 @@ def add_transaction(data):
|
||||
email = get_email_or_abort_401()
|
||||
|
||||
# Check if required data is available
|
||||
if not check_if_symbol_data_exists(data):
|
||||
abort(400, "Symbol missing")
|
||||
if not check_if_isin_data_exists(data):
|
||||
abort(400, "ISIN missing")
|
||||
|
||||
if not check_if_time_data_exists(data):
|
||||
abort(400, "Time missing")
|
||||
|
||||
if not check_if_comment_data_exists(data):
|
||||
abort(400, "Comment missing")
|
||||
|
||||
if not check_if_count_data_exists(data):
|
||||
abort(400, "Count missing")
|
||||
|
||||
@@ -43,7 +45,8 @@ def add_transaction(data):
|
||||
# Add transaction
|
||||
new_transaction = Transaction(
|
||||
email=email,
|
||||
symbol=data['symbol'],
|
||||
isin=data['isin'],
|
||||
comment=data['comment'],
|
||||
time=datetime.datetime.strptime(data['time'], '%Y-%m-%dT%H:%M:%S.%fZ'),
|
||||
count=data['count'],
|
||||
price=data['price']
|
||||
@@ -74,11 +77,11 @@ def get_transaction():
|
||||
return make_response(return_transactions, 200, "Successfully loaded transactions")
|
||||
|
||||
|
||||
def check_if_symbol_data_exists(data):
|
||||
if "symbol" not in data:
|
||||
def check_if_isin_data_exists(data):
|
||||
if "isin" not in data:
|
||||
return False
|
||||
|
||||
if data['symbol'] == "" or data['symbol'] is None:
|
||||
if data['isin'] == "" or data['isin'] is None:
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -94,6 +97,16 @@ def check_if_time_data_exists(data):
|
||||
return True
|
||||
|
||||
|
||||
def check_if_comment_data_exists(data):
|
||||
if "comment" not in data:
|
||||
return False
|
||||
|
||||
if data['comment'] == "" or data['comment'] is None:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def check_if_count_data_exists(data):
|
||||
if "count" not in data:
|
||||
return False
|
||||
|
Reference in New Issue
Block a user