Self hosted FLOSS fitness/workout, nutrition and weight tracker
Use the model's get_absolute_url
Roland Geider57a3152c5dbb
diff --git a/wger/core/templates/index.html b/wger/core/templates/index.htmlindex 6a9c96f90..1c9bbe453 100644--- a/wger/core/templates/index.html+++ b/wger/core/templates/index.html@@ -98,13 +98,7 @@ day in your current workout:{% endblocktrans %} <strong>{{current_workout}}</str{% if plan %}<p>- <a href="{% url 'nutrition:plan:view' plan.id %}">- {% if plan.description %}- {{ plan.description }}- {% else %}- {% trans "Nutrition plan" %}- {% endif %}- </a>+ <a href="{{ plan.get_absolute_url }}">{{ plan }}</a></p>– {{ plan.creation_date }}<ul>diff --git a/wger/core/templates/mobile/index.html b/wger/core/templates/mobile/index.htmlindex 864de4615..572aac750 100644--- a/wger/core/templates/mobile/index.html+++ b/wger/core/templates/mobile/index.html@@ -50,7 +50,7 @@<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h4 class="modal-title">{% trans "Current nutrition plan" %}</h4>{% if plan %}- <h5><a href="{% url 'nutrition:plan:view' plan.id %}">{{ plan }}</a></h5>+ <h5><a href="{{ plan.get_absolute_url }}>{{ plan }}</a></h5>{% endif %}</div><div class="modal-body">diff --git a/wger/core/templates/user/overview.html b/wger/core/templates/user/overview.htmlindex b787de7a5..ac4785fdf 100644--- a/wger/core/templates/user/overview.html+++ b/wger/core/templates/user/overview.html@@ -149,7 +149,7 @@{{nutrition_plan.creation_date}}</td><td>- <a href="{{trainer_login}}?next={% url 'nutrition:plan:view' nutrition_plan.id %}">{{nutrition_plan}}</a>+ <a href="{{trainer_login}}?next={{ nutrition_plan.get_absolute_url }}">{{nutrition_plan}}</a></td><td>{{nutrition_plan.get_nutritional_values.total.energy|floatformat}} {% trans "kcal" %}diff --git a/wger/nutrition/templates/mobile/plan/overview.html b/wger/nutrition/templates/mobile/plan/overview.htmlindex 634617a6f..81ebb1875 100644--- a/wger/nutrition/templates/mobile/plan/overview.html+++ b/wger/nutrition/templates/mobile/plan/overview.html@@ -7,7 +7,7 @@{% block content %}<div class="list-group">{% for plan in plans %}- <a href="{% url 'nutrition:plan:view' plan.id %}" class="list-group-item wger-list-group-item">+ <a href="{{ plan.get_absolute_url }}" class="list-group-item wger-list-group-item"><span class="glyphicon glyphicon-chevron-right pull-right"></span><h3 class="list-group-item-heading">{{plan}}</h4>diff --git a/wger/nutrition/templates/plan/overview.html b/wger/nutrition/templates/plan/overview.htmlindex 9b35a861a..1a80f7176 100644--- a/wger/nutrition/templates/plan/overview.html+++ b/wger/nutrition/templates/plan/overview.html@@ -19,7 +19,7 @@{% for plan in plans %}<tr><td>- <a href="{% url 'nutrition:plan:view' plan.id %}">{{ plan }}</a>+ <a href="{{ plan.get_absolute_url }}">{{ plan }}</a></td><td>{{ plan.creation_date }}diff --git a/wger/nutrition/views/meal.py b/wger/nutrition/views/meal.pyindex d9ce35b61..199c4cbe4 100644--- a/wger/nutrition/views/meal.py+++ b/wger/nutrition/views/meal.py@@ -54,7 +54,7 @@ class MealCreateView(WgerFormMixin, CreateView):return super(MealCreateView, self).form_valid(form)def get_success_url(self):- return reverse('nutrition:plan:view', kwargs={'id': self.object.plan.id})+ return self.object.plan.get_absolute_url()# Send some additional data to the templatedef get_context_data(self, **kwargs):@@ -76,7 +76,7 @@ class MealEditView(WgerFormMixin, UpdateView):form_action_urlname = 'nutrition:meal:edit'def get_success_url(self):- return reverse('nutrition:plan:view', kwargs={'id': self.object.plan.id})+ return self.object.plan.get_absolute_url()@login_required@@ -92,6 +92,6 @@ def delete_meal(request, id):# Only delete if the user is the ownerif plan.user == request.user:meal.delete()- return HttpResponseRedirect(reverse('nutrition:plan:view', kwargs={'id': plan.id}))+ return HttpResponseRedirect(plan.get_absolute_url())else:return HttpResponseForbidden()