Skip to content

Commit

Permalink
wip of fixing upload and download
Browse files Browse the repository at this point in the history
  • Loading branch information
XaelShan committed Jun 30, 2023
1 parent 3865aef commit ae917e9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions webfit/data/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from rest_framework import status

from serializers import DataSerializers
from user_authentication.models import User
from .models import Data


Expand All @@ -23,7 +22,11 @@ def get_data(request, version):


@api_view(['POST', 'PUT'])
def upload(request, version):
def upload(request, version):
if request.user.is_authenticated:
#checks to see if there is an existing file to update
file = get_object_or_404(Data, username = request.username)

#saves file_string
if request.method == 'POST':
serializer = DataSerializers(file_string = request.file_string)
Expand All @@ -35,10 +38,7 @@ def upload(request, version):

#saves or updates file_string
if request.method == 'PUT':
if User.anonymous == False:
#checks to see if there is an existing file to update
file = get_object_or_404(Data, file_string=request.file_string)

if request.user.is_authenticated:
serializer = DataSerializers(file, file_string=request.file_string)
if serializer.is_valid():
serializer.save()
Expand Down

0 comments on commit ae917e9

Please sign in to comment.