First commit of the V2.

New base, new info.
This commit is contained in:
2019-04-18 00:58:59 +02:00
parent 698b6dd865
commit 31d5f7ade4
185 changed files with 32824 additions and 0 deletions

24
timelaps/decorators.py Normal file
View File

@@ -0,0 +1,24 @@
from rest_framework.response import Response
from rest_framework.views import status
import logging
logger = logging.getLogger(__name__)
def validate_request_driver_data(fn):
def decorated(*args, **kwargs):
# args[0] == GenericView Object
logger.error(args[0].request.data)
first_name = args[0].request.data.get("first_name", "")
kart_id = args[0].request.data.get("kart_id", "")
logger.error(first_name)
logger.error(kart_id)
if not first_name and not kart_id:
return Response(
data={
"message": "Both first_name and kart_id are required to add a driver"
},
status=status.HTTP_400_BAD_REQUEST
)
return fn(*args, **kwargs)
return decorated