Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Remove unused views and templates

Roland Geiderfab220b5225e
diff --git a/wger/core/templates/tags/render_day.html b/wger/core/templates/tags/render_day.html
index 5b18c0961..df12490b6 100644
--- a/wger/core/templates/tags/render_day.html
+++ b/wger/core/templates/tags/render_day.html
@@ -2,14 +2,8 @@
<script>
$(document).ready(function () {
-
- // Call the setup function to allow the sets to be sortable again after loading this
- // view via AJAX
- wgerSetupSortable();
-
// Init the modal dialog to edit the exercise
wgerFormModalDialog();
-
})
</script>
@@ -19,36 +13,6 @@
<thead class="thead-light">
<tr id="day-{{ day.id }}">
<th colspan="2">
- {% if editable %}
- <div class="float-end">
- <div class="dropdown">
- <button class="btn btn-sm dropdown-toggle " type="button"
- id="dropdownMenuDay{{ day.id }}" data-bs-toggle="dropdown"
- aria-haspopup="true" aria-expanded="false">
- <span class="{% fa_class 'cog' %}"></span>
- </button>
- <div class="dropdown-menu dropdown-menu-right"
- aria-labelledby="dropdownMenuDay{{ day.id }}">
- <a href="{% url 'manager:day:log' day.id %}" class="dropdown-item">
- <span class="{% fa_class 'chart-line' %}"></span>
- {% translate 'Add weight log' %}
- </a>
- <a href="{% url 'manager:day:edit' day.id %}"
- class="wger-modal-dialog dropdown-item">
- <span class="{% fa_class 'edit' %}"></span>
- {% translate 'Edit' %}
- </a>
- <div class="dropdown-divider"></div>
- <a href="{% url 'manager:day:delete' day.id %}"
- class="dropdown-item">
- <span class="{% fa_class 'trash' %}"></span>
- {% translate 'Delete' %}
- </a>
-
- </div>
- </div>
- </div>
- {% endif %}
<h4>{{ day.description }}</h4>
{{ day.days_txt }}
@@ -60,36 +24,6 @@
<tr data-id="{{ set.id }}" id="set-{{ set.id }}">
<td style="width: 15%;border-right-width: 0;">
<span>#{{ forloop.counter }}</span>
-
- {% if editable %}
- <div class="dropdown float-end">
- <button class="btn btn-link btn-sm btn-block dropdown-toggle " type="button"
- id="dropdownMenuSet{{ set.id }}" data-bs-toggle="dropdown"
- aria-haspopup="true" aria-expanded="false">
- </button>
- <div class="dropdown-menu dropdown-menu-right"
- aria-labelledby="dropdownMenuSet{{ set.id }}">
- <a href="{% url 'manager:set:edit' set.id %}"
- class="wger-modal-dialog dropdown-item">
- <span class="{% fa_class 'edit' %}"></span>
- {% translate 'Edit' %}
- </a>
- <div class="dropdown-divider"></div>
- <a href="{% url 'manager:set:delete' set.id %}"
- class="dropdown-item">
- <span class="{% fa_class 'trash' %}"></span>
- {% translate 'Delete' %}
- </a>
- </div>
- </div>
-
- {% if false and day.set_list|length > 1 %}
- <span class="editoptions">
- <span class="{% fa_class 'bars' %} dragndrop-handle"></span>
- <br>
- </span>
- {% endif %}
- {% endif %}
</td>
<td style="border-left-width: 0px;">
{% if set.comment %}
@@ -97,23 +31,23 @@
{% endif %}
<div class="exercise-list">
- {% for base in set.exercise_bases %}
- {% with base.get_exercise as exercise %}
+ {% for exercise in set.exercise_bases %}
+ {% with exercise.get_translation as translation %}
- <div id="exercise-{{ base.id }}" class="ajax-set-edit-target">
+ <div id="translation-{{ translation.id }}" class="ajax-set-edit-target">
<div class="media">
<div style="width: 64px; height: 64px;">
- <a href="{{ exercise.get_absolute_url }}">
+ <a href="{{ translation.get_absolute_url }}">
{% if base.main_image %}
<img class="img-fluid"
src="{{ base.main_image.image|thumbnail_url:'small' }}"
- alt="{{ exercise }}"
+ alt="{{ translation }}"
style="max-width: 100%; max-height: 100%;">
{% else %}
<img class="img-fluid"
src="{% static 'images/icons/image-placeholder.svg' %}"
- alt="{% translate 'Placeholder image for exercise' %}"
+ alt="{% translate 'Placeholder image for translation' %}"
style="opacity: 0.4;">
{% endif %}
</a>
@@ -121,31 +55,11 @@
<div class="media-body ml-2">
<p class="media-heading h5">
- {{ exercise.name }}
+ {{ translation.name }}
</p>
<p>
- {{ base.settings }}
+ {{ exercise.settings }}
</p>
-
- {% if editable %}
- {% if not base.settings %}
- <p>
- {% translate "This exercise has no repetitions." %}<br>
- <a href="{% url 'manager:set:edit' set.id %}"
- class="wger-modal-dialog">
- {% translate "Edit them now." %}
- </a>
- </p>
- {% endif %}
-
- {% if base.exercisecomment_set.all %}
- <p class="text-muted exercise-comments">
- {% for comment in base.exercisecomment_set.all %}
- {{ comment }}<br>
- {% endfor %}
- </p>
- {% endif %}
- {% endif %}
</div>
</div>
</div>
@@ -155,14 +69,7 @@
</td>
</tr>
{% endfor %} <!--for set in day-->
- {% if editable %}
- <tr>
- <td colspan="2" class="py-0">
- <a href="{% url 'manager:set:add' day.id %}"
- class="wger-modal-dialog btn btn-link btn-block">{% translate "Add exercises to this workout day" %}</a>
- </td>
- </tr>
- {% endif %}
+
</tbody>
diff --git a/wger/core/templates/tags/render_weight_log.html b/wger/core/templates/tags/render_weight_log.html
deleted file mode 100644
index 19595651e..000000000
--- a/wger/core/templates/tags/render_weight_log.html
+++ /dev/null
@@ -1,41 +0,0 @@
-{% load i18n static wger_extras %}
-<div id="svg-{{div_uuid}}"></div>
-
-<div class="table-responsive weight-chart-table">
-<table class="noborder">
- <tr>
- {% for date, entry_list in log.items %}
- <td style="padding: 0em; border-top-width: 0px; vertical-align: top;">
- <table class="table-sm">
- <thead>
- <tr>
- <th colspan="3">{{date|date:"d.m.Y"}}</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="text-right">{% translate "Reps" %}</td>
- <td></td>
- <td style="padding:0px;">
- {% trans_weight_unit 'kg' user %}
- </td>
- </tr>
- {% for entry in entry_list %}
- <tr>
- <td class="text-right">{{entry.reps}}</td>
- <td class="text-center" style="padding:0px;">×</td>
- <td style="padding:0px;">
- {{entry.weight}}
- {% if entry.rir %}
- {{ entry.rir }} {% translate "RiR" %}
- {% endif %}
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </td>
- {% endfor %}
- </tr>
-</table>
-</div>
diff --git a/wger/core/templatetags/wger_extras.py b/wger/core/templatetags/wger_extras.py
index bc61124c3..1711294c9 100644
--- a/wger/core/templatetags/wger_extras.py
+++ b/wger/core/templatetags/wger_extras.py
@@ -92,19 +92,6 @@ def pagination(paginator, page):
return {'page': page, 'page_range': page_range}
[email protected]_tag('tags/render_weight_log.html')
-def render_weight_log(log, div_uuid, user=None):
- """
- Renders a weight log series
- """
-
- return {
- 'log': log,
- 'div_uuid': div_uuid,
- 'user': user,
- }
-
-
@register.inclusion_tag('tags/muscles.html')
def render_muscles(muscles=None, muscles_sec=None):
"""
diff --git a/wger/manager/templates/day/view.html b/wger/manager/templates/day/view.html
deleted file mode 100644
index 52a50036e..000000000
--- a/wger/manager/templates/day/view.html
+++ /dev/null
@@ -1,4 +0,0 @@
-{% load i18n %}
-{% load wger_extras %}
-
-{% render_day day %}
\ No newline at end of file
diff --git a/wger/manager/templates/workout/log.html b/wger/manager/templates/workout/log.html
deleted file mode 100644
index 7ad23d788..000000000
--- a/wger/manager/templates/workout/log.html
+++ /dev/null
@@ -1,101 +0,0 @@
-{% extends "base.html" %}
-{% load i18n static wger_extras django_bootstrap_breadcrumbs %}
-
-
-{# #}
-{# Opengraph #}
-{# #}
-{% block opengraph %}
- {{ block.super }}
- <meta property="og:title" content="{% translate 'Weight log' %}">
- <meta property="og:description" content="{% translate 'Weight log' %} / {{ workout }} / {{ owner_user.username }}">
-{% endblock %}
-
-
-{# #}
-{# Breadcrumbs #}
-{# #}
-{% block breadcrumbs %}
- {{ block.super }}
-
- {% breadcrumb workout workout %}
- {% breadcrumb "Weight log" "manager:log:log" workout.pk %}
-{% endblock %}
-
-
-{# #}
-{# Title #}
-{# #}
-{% block title %}{% translate "Weight log for workout" %}{% endblock %}
-
-
-{# #}
-{# Header #}
-{# #}
-{% block header %}
-{% endblock %}
-
-
-{# #}
-{# Content #}
-{# #}
-{% block content %}
-{% for day in workout.canonical_representation.day_list %}
- <h4>{{ day.obj.description }}</h4>
-
- {% if is_owner %}
- <p>
- <a href="{% url 'manager:day:log' day.obj.id %}" class="btn btn-success btn-sm">
- {% translate 'Add weight log to this day' %}
- </a>
- </p>
- {% endif %}
-
- {% for set in day.set_list %}
- {% for base in set.exercise_list %}
-
- {% with day_list=workout_log|get_item:day.obj.id %}
- {% with exercise_list=day_list|get_item:base.obj.id %}
-
- <h5 class="mt-4">{{ base.obj.get_translation.name }}</h5>
- {% if exercise_list.log_by_date %}
- {# TODO: perhaps move the draw_weight_chart function to render_weight_log #}
- {% with list=exercise_list.log_by_date %}
- {% render_weight_log list exercise_list.div_uuid owner_user %}
- {% endwith %}
-
-
- {% else %}
- <p><em>{% translate "No weight entries here." %}</em></p>
- {% endif %}
-
- {% endwith %}
- {% endwith %}
-
- {% empty%}
- <p>
- <em>{% translate "No exercises for this day." %}</em>
- </p>
- {% endfor %}
- {% endfor %}
-{% endfor %}
-{% endblock %}
-
-
-{# #}
-{# Side bar #}
-{# #}
-{% block sidebar %}
-<h4>{% translate "Notes" %}</h4>
-<p>{% blocktranslate %}This page shows the weight logs belonging to this workout
-only. Click on an exercise to see all the historical data for
-it.{% endblocktranslate %}</p>
-
-<p>{% blocktranslate %}If on a single day there is more than one entry with the
-same number of repetitions, but different weights, only the entry with the
-higher weight is shown in the diagram.{% endblocktranslate %}</p>
-
-<p>{% blocktranslate %}Note that only entries with a weight unit (kg or lb) and
-repetitions are charted, other combinations such as time or until failure
-are ignored here.{% endblocktranslate %}</p>
-{% endblock %}
diff --git a/wger/manager/urls.py b/wger/manager/urls.py
index bba566601..a546f7e3c 100644
--- a/wger/manager/urls.py
+++ b/wger/manager/urls.py
@@ -232,11 +232,6 @@ patterns_day = [
day.delete,
name='delete',
),
- path(
- '<int:id>/view',
- day.view,
- name='view',
- ),
path(
'<int:pk>/log/add',
log.add,
diff --git a/wger/manager/views/day.py b/wger/manager/views/day.py
index 1ae28d45a..56d8cd71a 100644
--- a/wger/manager/views/day.py
+++ b/wger/manager/views/day.py
@@ -21,10 +21,7 @@ import logging
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponseRedirect
-from django.shortcuts import (
- get_object_or_404,
- render,
-)
+from django.shortcuts import get_object_or_404
from django.urls import reverse
from django.utils.translation import (
gettext as _,
@@ -125,20 +122,3 @@ def delete(request, pk):
day = get_object_or_404(Day, training__user=request.user, pk=pk)
day.delete()
return HttpResponseRedirect(reverse('manager:workout:view', kwargs={'pk': day.training_id}))
-
-
-@login_required
-def view(request, id):
- """
- Renders a day as shown in the workout overview.
-
- This function is to be used with AJAX calls.
- """
- template_data = {}
-
- # Load day and check if its workout belongs to the user
- day = get_object_or_404(Day, pk=id, training__user=request.user)
-
- template_data['day'] = day
-
- return render(request, 'day/view.html', template_data)
diff --git a/wger/manager/views/log.py b/wger/manager/views/log.py
index 7a6649cc6..ba15750af 100644
--- a/wger/manager/views/log.py
+++ b/wger/manager/views/log.py
@@ -245,74 +245,6 @@ def add(request, pk):
return render(request, 'log/add.html', context)
-class WorkoutLogDetailView(DetailView, LoginRequiredMixin):
- """
- An overview of the workout's log
- """
-
- model = Workout
- template_name = 'workout/log.html'
- context_object_name = 'workout'
- owner_user = None
-
- def get_context_data(self, **kwargs):
- # Call the base implementation first to get a context
- context = super(WorkoutLogDetailView, self).get_context_data(**kwargs)
- is_owner = self.owner_user == self.request.user
-
- # Prepare the entries for rendering and the D3 chart
- workout_log = {}
-
- for day_obj in self.object.day_set.all():
- day_id = day_obj.id
- workout_log[day_id] = {}
- for set_obj in day_obj.set_set.all():
- exercise_log = {}
- for base_obj in set_obj.exercise_bases:
- exercise_base_id = base_obj.id
- exercise_log[exercise_base_id] = []
-
- # Filter the logs for user and exclude all units that are not weight
- logs = base_obj.workoutlog_set.filter(
- user=self.owner_user,
- weight_unit__in=(1, 2),
- repetition_unit=1,
- workout=self.object,
- )
- entry_log, chart_data = process_log_entries(logs)
- if entry_log:
- exercise_log[base_obj.id].append(entry_log)
-
- if exercise_log:
- workout_log[day_id][exercise_base_id] = {}
- workout_log[day_id][exercise_base_id]['log_by_date'] = entry_log
- workout_log[day_id][exercise_base_id]['div_uuid'] = 'div-' + str(
- uuid.uuid4()
- )
- workout_log[day_id][exercise_base_id]['chart_data'] = chart_data
-
- context['workout_log'] = workout_log
- context['owner_user'] = self.owner_user
- context['is_owner'] = is_owner
-
- return context
-
- def dispatch(self, request, *args, **kwargs):
- """
- Check for ownership
- """
-
- workout = get_object_or_404(Workout, pk=kwargs['pk'])
- self.owner_user = workout.user
- is_owner = request.user == self.owner_user
-
- if not is_owner and not self.owner_user.userprofile.ro_access:
- return HttpResponseForbidden()
-
- # Dispatch normally
- return super(WorkoutLogDetailView, self).dispatch(request, *args, **kwargs)
-
-
def calendar(request, username=None, year=None, month=None):
"""
Show a calendar with all the workout logs
diff --git a/yarn.lock b/yarn.lock
index 98280a106..1e6b1b95b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2,6 +2,11 @@
# yarn lockfile v1
+"@popperjs/core@^2.11.8":
+ version "2.11.8"
+ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f"
+ integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==
+
"@types/jquery@^2.0.32":
version "2.0.54"
resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-2.0.54.tgz#d7999245f77c3fab5d84e7d32b8a6c20bfd1f072"
@@ -9,7 +14,6 @@
Sortable@RubaXa/Sortable#1.15.3:
version "1.15.3"
- uid dcb8f9e85b972292db1e0cab2ff9d7cd359ff352
resolved "https://codeload.github.com/RubaXa/Sortable/tar.gz/dcb8f9e85b972292db1e0cab2ff9d7cd359ff352"
@@ -349,11 +353,6 @@ outlayer@^2.1.0:
fizzy-ui-utils "^2.0.0"
get-size "^2.0.2"
-popper.js@^1.16.1:
- version "1.16.1"
- resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
- integrity sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==
-
robust-predicates@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-3.0.1.tgz#ecde075044f7f30118682bd9fb3f123109577f9a"