Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add original to diff against

Tom Bowyere813c283a34d
diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.py
index 293d090bf..4a0fa7d82 100644
--- a/wger/exercises/api/views.py
+++ b/wger/exercises/api/views.py
@@ -144,10 +144,16 @@ class ExerciseTranslationViewSet(CreateUpdateModelViewSet):
"""
Save entry to activity stream
"""
- super().perform_create(serializer)
-
obj_id = self.kwargs['pk']
updated_object = Exercise.objects.get(id=obj_id)
+
+ # Create a default history to diff against if there is none
+ most_recent_history = updated_object.history.order_by('history_date').last()
+ if most_recent_history is None:
+ updated_object.save()
+
+ super().perform_create(serializer)
+
most_recent_history = updated_object.history.order_by('history_date').last()
actstream_action.send(
diff --git a/wger/exercises/templates/history/list3.html b/wger/exercises/templates/history/list3.html
index a4b69e931..dbd541f89 100644
--- a/wger/exercises/templates/history/list3.html
+++ b/wger/exercises/templates/history/list3.html
@@ -44,11 +44,11 @@
</td>
<td>{{ event.stream.timesince }}</td>
<td>
- <a href="#" id="view-changes" data-toggle="modal" data-target="#changes-modal"
+ <a href="#" id="view-changes" data-toggle="modal" data-target="#changes-modal-{{ event.stream.id }}"
class="btn btn-success btn-sm btn-block">
{% translate "View changes" %}
</a>
- <div class="modal fade" id="changes-modal">
+ <div class="modal fade" id="changes-modal-{{ event.stream.id }}">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">