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

18
music/decorators.py Normal file
View File

@@ -0,0 +1,18 @@
from rest_framework.response import Response
from rest_framework.views import status
def validate_request_data(fn):
def decorated(*args, **kwargs):
# args[0] == GenericView Object
title = args[0].request.data.get("title", "")
artist = args[0].request.data.get("artist", "")
if not title and not artist:
return Response(
data={
"message": "Both title and artist are required to add a song"
},
status=status.HTTP_400_BAD_REQUEST
)
return fn(*args, **kwargs)
return decorated