Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Remove views for exercise video upload

Roland Geider00a3ad27152b
diff --git a/wger/exercises/templates/exercise/view.html b/wger/exercises/templates/exercise/view.html
index 696c196be..573918c76 100644
--- a/wger/exercises/templates/exercise/view.html
+++ b/wger/exercises/templates/exercise/view.html
@@ -125,20 +125,7 @@ $(document).ready(function() {
Your browser does not support the video tag.
</video>
<div class="card-body text-center">
- {% if perms.exercises.change_exercisevideo %}
- <a href="{% url 'exercise:video:delete' exercise.pk video.pk %}" class="wger-modal-dialog btn btn-link">
- <span class="{% fa_class 'trash' %}"></span>
- </a>
- <a href="{% url 'exercise:video:edit' exercise.pk video.pk %}" class="btn btn-link">
- <span class="{% fa_class 'edit' %}"></span>
- </a>
- {% endif %}
- {% if video.is_main %}
- <p class="card-text text-wger-green">
- <span class="{% fa_class 'medal' %}"></span>
- </p>
- {% endif %}
</div>
<div class="card-footer">
{{video.get_license_display}}
@@ -150,14 +137,6 @@ $(document).ready(function() {
</div>
{% endfor %}
</div>
-
- {% if allow_upload_videos and perms.exercises.change_exercisevideo %}
- <p>
- <a href="{% url 'exercise:video:add' exercise.id %}" >
- {% translate "Add new video" %}
- </a>
- </p>
- {% endif %}
{% endif %}
{% endwith %}
diff --git a/wger/exercises/urls.py b/wger/exercises/urls.py
index e2f13e69e..c33424c64 100644
--- a/wger/exercises/urls.py
+++ b/wger/exercises/urls.py
@@ -32,7 +32,6 @@ from wger.exercises.views import (
history,
images,
muscles,
- videos,
)
@@ -95,24 +94,6 @@ patterns_images = [
),
]
-# sub patterns for exercise videos
-patterns_videos = [
- path(
- '<int:exercise_pk>/video/add',
- videos.ExerciseVideoAddView.as_view(),
- name='add',
- ),
- path(
- '<int:exercise_pk>/<int:pk>/edit',
- videos.ExerciseVideoEditView.as_view(),
- name='edit',
- ),
- path(
- '<int:exercise_pk>/video/<int:pk>/delete',
- videos.ExerciseVideoDeleteView.as_view(),
- name='delete',
- ),
-]
# sub patterns for exercise comments
patterns_comment = [
@@ -208,7 +189,6 @@ patterns_exercise = [
urlpatterns = [
path('muscle/', include((patterns_muscle, 'muscle'), namespace="muscle")),
path('image/', include((patterns_images, 'image'), namespace="image")),
- path('video/', include((patterns_videos, 'image'), namespace="video")),
path('comment/', include((patterns_comment, 'comment'), namespace="comment")),
path('category/', include((patterns_category, 'category'), namespace="category")),
path('equipment/', include((patterns_equipment, 'equipment'), namespace="equipment")),
diff --git a/wger/exercises/views/videos.py b/wger/exercises/views/videos.py
deleted file mode 100644
index 664ea05f1..000000000
--- a/wger/exercises/views/videos.py
+++ /dev/null
@@ -1,145 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# This file is part of wger Workout Manager.
-#
-# wger Workout Manager is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# wger Workout Manager is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-
-# Standard Library
-import logging
-
-# Django
-from django.contrib.auth.decorators import permission_required
-from django.contrib.auth.mixins import (
- LoginRequiredMixin,
- PermissionRequiredMixin,
-)
-from django.http import HttpResponseRedirect
-from django.shortcuts import get_object_or_404
-from django.urls import reverse
-from django.utils.translation import (
- gettext as _,
- gettext_lazy,
-)
-from django.views.generic import (
- CreateView,
- DeleteView,
- UpdateView,
-)
-
-# wger
-from wger.exercises.forms import ExerciseVideoForm
-from wger.exercises.models import (
- Exercise,
- ExerciseVideo,
-)
-from wger.utils.constants import DEFAULT_LICENSE_ID
-from wger.utils.generic_views import (
- WgerDeleteMixin,
- WgerFormMixin,
-)
-
-
-logger = logging.getLogger(__name__)
-"""
-Exercise videos
-"""
-
-
-class ExerciseVideoEditView(
- WgerFormMixin,
- LoginRequiredMixin,
- PermissionRequiredMixin,
- UpdateView,
-):
- """
- Generic view to update an existing exercise video
- """
-
- model = ExerciseVideo
- title = gettext_lazy('Edit')
- permission_required = 'exercises.change_exercisevideo'
- form_class = ExerciseVideoForm
-
- def get_success_url(self):
- return reverse('exercise:exercise:view', kwargs={'id': self.kwargs['exercise_pk']})
-
- # Send some additional data to the template
- def get_context_data(self, **kwargs):
- context = super(ExerciseVideoEditView, self).get_context_data(**kwargs)
- context['enctype'] = 'multipart/form-data'
- return context
-
-
-class ExerciseVideoAddView(
- WgerFormMixin,
- LoginRequiredMixin,
- PermissionRequiredMixin,
- CreateView,
-):
- """
- Generic view to add a new exercise video
- """
-
- model = ExerciseVideo
- title = gettext_lazy('Add new video')
- permission_required = 'exercises.add_exercisevideo'
- form_class = ExerciseVideoForm
-
- def form_valid(self, form):
- """Set the exercise base and the author"""
- exercise = get_object_or_404(Exercise, pk=self.kwargs['exercise_pk'])
- form.instance.exercise_base = exercise.exercise_base
- form.instance.license_id = DEFAULT_LICENSE_ID
- return super(ExerciseVideoAddView, self).form_valid(form)
-
- def get_success_url(self):
- return reverse('exercise:exercise:view', kwargs={'id': self.kwargs['exercise_pk']})
-
- def get_context_data(self, **kwargs):
- """
- Send some additional data to the template
- """
- context = super(ExerciseVideoAddView, self).get_context_data(**kwargs)
- context['enctype'] = 'multipart/form-data'
- return context
-
-
-class ExerciseVideoDeleteView(
- WgerDeleteMixin,
- LoginRequiredMixin,
- PermissionRequiredMixin,
- DeleteView,
-):
- """
- Generic view to delete an existing exercise image
- """
-
- model = ExerciseVideo
- fields = ('video', 'is_main')
- messages = gettext_lazy('Successfully deleted')
- permission_required = 'exercises.delete_exercisevideo'
-
- def get_success_url(self):
- """
- Return to exercise image
- """
- return reverse('exercise:exercise:view', kwargs={'id': self.kwargs['exercise_pk']})
-
- def get_context_data(self, **kwargs):
- """
- Send some additional data to the template
- """
- context = super(ExerciseVideoDeleteView, self).get_context_data(**kwargs)
-
- context['title'] = _('Delete?')
- return context