Self hosted FLOSS fitness/workout, nutrition and weight tracker
Rename enum option
Roland Geiderb484025298a3
diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.pyindex 2264f108e..921e2be83 100644--- a/wger/exercises/api/views.py+++ b/wger/exercises/api/views.py@@ -31,11 +31,10 @@ from rest_framework.decorators import (action,api_view,)-from rest_framework.permissions import IsAuthenticatedOrReadOnlyfrom rest_framework.response import Response# wger-from exercises.views.helper import HistoryModes+from wger.exercises.views.helper import HistoryModesfrom wger.config.models import LanguageConfigfrom wger.core.api.viewsets import CreateUpdateModelViewSetfrom wger.exercises.api.permissions import CanEditExercises@@ -126,7 +125,7 @@ class ExerciseTranslationViewSet(CreateUpdateModelViewSet):super().perform_create(serializer)actstream_action.send(self.request.user,- verb=HistoryModes.ADDED.value,+ verb=HistoryModes.CREATED.value,action_object=serializer.instance,)@@ -142,7 +141,7 @@ class ExerciseTranslationViewSet(CreateUpdateModelViewSet):)-class ExerciseViewSet(CreateUpdateModelViewSet):+class ExerciseViewSet(viewsets.ReadOnlyModelViewSet):"""API endpoint for exercise objects. For a single read-only endpoint with allthe information of an exercise, see /api/v2/exerciseinfo/@@ -352,12 +351,25 @@ class ExerciseImageViewSet(CreateUpdateModelViewSet):def perform_create(self, serializer):"""- Set the license data+ Save entry to activity stream+ """+ super().perform_create(serializer)+ actstream_action.send(+ self.request.user,+ verb=HistoryModes.CREATED.value,+ action_object=serializer.instance,+ )++ def perform_update(self, serializer):"""- obj = serializer.save()- # Todo is it right to call set author after save?- obj.set_author(self.request)- obj.save()+ Save entry to activity stream+ """+ super().perform_create(serializer)+ actstream_action.send(+ self.request.user,+ verb=HistoryModes.UPDATED.value,+ action_object=serializer.instance,+ )class ExerciseVideoViewSet(viewsets.ReadOnlyModelViewSet):@@ -400,7 +412,7 @@ class ExerciseCommentViewSet(CreateUpdateModelViewSet):super().perform_create(serializer)actstream_action.send(self.request.user,- verb=HistoryModes.ADDED.value,+ verb=HistoryModes.CREATED.value,action_object=serializer.instance,)diff --git a/wger/exercises/templates/history/list.html b/wger/exercises/templates/history/list.htmlindex e47ff97f3..2ae76f5a4 100644--- a/wger/exercises/templates/history/list.html+++ b/wger/exercises/templates/history/list.html@@ -34,7 +34,7 @@{% if event.verb == modes.ADDED.value %}<span class="{% fa_class 'plus' %}"></span>{% elif event.verb == modes.UPDATED.value %}- <span class="{% fa_class 'asterisk' %}"></span>+ <span class="{% fa_class 'pen' %}"></span>{% endif %}</td><td>diff --git a/wger/exercises/views/helper.py b/wger/exercises/views/helper.pyindex 6687d8169..72d65d249 100644--- a/wger/exercises/views/helper.py+++ b/wger/exercises/views/helper.py@@ -15,5 +15,5 @@ import enumclass HistoryModes(enum.Enum):- ADDED = 'created'+ CREATED = 'created'UPDATED = 'updated'diff --git a/wger/exercises/views/history.py b/wger/exercises/views/history.pyindex e70ac6b0f..ac3127791 100644--- a/wger/exercises/views/history.py+++ b/wger/exercises/views/history.py@@ -21,7 +21,7 @@ from django.contrib.auth.decorators import permission_requiredfrom django.shortcuts import render# wger-from exercises.views.helper import HistoryModes+from wger.exercises.views.helper import HistoryModesfrom wger.exercises.models import Exercisefrom actstream.models import Action@@ -35,11 +35,10 @@ def overview(request):Generic view to list the history of the exercises"""- print(HistoryModes.ADDED.value)context = {'stream': Action.objects.all(),- # We can't pass the enmu to the template, so we have to do this+ # We can't pass the enum to the template, so we have to do this# https://stackoverflow.com/questions/35953132/'modes': HistoryModes.__members__}