Skip to content

Commit

Permalink
added link to that links fields and values
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipSnell committed Feb 20, 2022
1 parent a7a6bf4 commit 12ad761
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ def post(self, request):
serializer = TrackTextValueSerializer(data=item,)
if serializer.is_valid():
serializer.save()
field = TrackingTextField.objects.get(
id == item.get("field_id"))
field.values.add(serializer)
field.save()
data['response'] = data['response'] + \
"entry "+str(index) + " entered, "
else:
Expand Down
9 changes: 9 additions & 0 deletions trainerInterface/splitViews/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,12 @@ def getGraphData(request):
# 'error': 'Could not load data'
# }
return JsonResponse(response)


def linkValues(request):
values = TrackingTextValue.objects.all()
for value in values:
field = TrackingTextField.objects.get(id=value.field_id)
field.values.add(value)
field.save()
return redirect('home')
1 change: 1 addition & 0 deletions trainerInterface/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
path('dashboard/graph/', graphTracking, name='graph'),
path('dashboard/getGraphData/', getGraphData, name='graph_data'),
path('dashboard/editexercise/', editExercise, name='edit_exercise'),
path('dashboard/linkvalues/', linkValues, name='link'),
]

0 comments on commit 12ad761

Please sign in to comment.