Skip to content

Commit

Permalink
changed getting training data
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipSnell committed Feb 14, 2022
1 parent 2fcc1d2 commit 3206cc9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,16 @@ class TrainingData(APIView):
def post(self, request):
# print(request.data["username"]+ "- blah blah")
email_lookup = request.data["username"]
user = User.objects.filter(email=email_lookup)
phases = Phase.objects.filter(user=user[0].id)
user = User.objects.get(email=email_lookup)
phases = Phase.objects.filter(user=user)
for phase in phases:
try:
activeWeek = phase.weeks.get(isActive=True)
trainingData = TrainingEntry.objects.filter(
user=user, phase=activeWeek.phase, week=activeWeek.week)
except:
trainingData = None
print('active week not found')
trainingData = TrainingEntry.objects.filter(
user=user[0].id, phase=activeWeek.phase, week=activeWeek.week)

serializer = TrainingSerializer(trainingData, many=True)

Expand Down

0 comments on commit 3206cc9

Please sign in to comment.