WIP, berths dont work yet

This commit is contained in:
Daniel Schick 2023-03-23 17:56:04 +01:00
parent d4cad33513
commit f64ea1b7cd
5 changed files with 34 additions and 15 deletions

View File

@ -69,9 +69,18 @@ CREATE TABLE `participant` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='An organization taking part';
CREATE TABLE `berth` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name1` varchar(128) DEFAULT NULL,
`name2` varchar(128) DEFAULT NULL,
PRIMARY KEY(`id`)
PRIMARY KEY(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Place of ship for a ship call';
CREATE TABLE `shipcall_participant_map` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shipcall_id` int(10) unsigned DEFAULT NULL,
`participant_id` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Associates a participant with a shipcall';

View File

@ -13,7 +13,6 @@ from .api import participant
from .api import times
from .api import notifications
from .api import berths
from .impl import util
def create_app(test_config=None):

View File

@ -9,5 +9,5 @@ bp = Blueprint('berths', __name__)
@bp.route('/berths', methods=['get'])
def GetBerths():
return impl.berths.GetBerths()
token = request.headers.get('Authentication')
return impl.berths.GetBerths(token)

View File

@ -1,19 +1,27 @@
import json
import logging
import pydapper
def GetBerths():
from ..schemas import model
from ..schemas import __init__
def GetBerths(token):
"""
No parameters, gets all entries
"""
"""
# TODO: validate token
# Implement your business logic here
# All the parameters are present in the options argument
try:
return json.dumps([{
"id": "<integer>",
"name1": "<string>",
"name2": "<string>",
}]), 200
commands = pydapper.using(__init__.connection_pool)
data = commands.query("SELECT id, name1, name2 FROM berth ORDER BY name1", model=model.BerthList)
except Exception as ex:
logging.error(ex)
return json.dumps("call failed"), 500
return json.dumps(data), 200

View File

@ -10,7 +10,7 @@ def GetVerify(apikey):
:param apikey: the api-key registered with the user
"""
if not apikey
if not apikey:
return json.dumps("missing api key"), 400
sentinel = object()
@ -21,8 +21,11 @@ def GetVerify(apikey):
return json.dumps("wrong api key", 403)
except Exception as ex:
logging.error(ex)
return json.dumps("logon failed"), 500
logging.error(e)
# TODO: user authenticated: Create,store and transmit JWT token
return json.dumps("<integer>"), 200