Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add help texts

Roland Geideraa9802324bc8
diff --git a/wger/manager/models.py b/wger/manager/models.py
deleted file mode 100644
index 6cf6ddc87..000000000
--- a/wger/manager/models.py
+++ /dev/null
@@ -1,174 +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
-# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.
-
-# Standard Library
-import datetime
-import logging
-import typing
-
-# Django
-from django.contrib.auth.models import User
-from django.core.cache import cache
-from django.core.exceptions import (
- ObjectDoesNotExist,
- ValidationError,
-)
-from django.core.validators import (
- MaxValueValidator,
- MinValueValidator,
-)
-from django.db import models
-from django.urls import reverse
-from django.utils.translation import gettext_lazy as _
-
-# wger
-from wger.core.models import (
- DaysOfWeek,
- RepetitionUnit,
- WeightUnit,
-)
-from wger.exercises.models import Exercise
-from wger.utils.cache import (
- cache_mapper,
- reset_workout_canonical_form,
- reset_workout_log,
-)
-from wger.utils.fields import Html5DateField
-from wger.utils.helpers import normalize_decimal
-
-
-class WorkoutSession(models.Model):
- """
- Model for a workout session
- """
-
- # Note: values hardcoded in manager.helpers.WorkoutCalendar
- IMPRESSION_BAD = '1'
- IMPRESSION_NEUTRAL = '2'
- IMPRESSION_GOOD = '3'
-
- IMPRESSION = (
- (IMPRESSION_BAD, _("Bad")),
- (IMPRESSION_NEUTRAL, _('Neutral')),
- (IMPRESSION_GOOD, _('Good')),
- )
-
- user = models.ForeignKey(
- User,
- verbose_name=_('User'),
- on_delete=models.CASCADE,
- )
- """
- The user the workout session belongs to
-
- See note in weight.models.WeightEntry about why this is not editable=False
- """
-
- workout = models.ForeignKey(
- Workout,
- verbose_name=_('Workout'),
- on_delete=models.CASCADE,
- )
- """
- The workout the session belongs to
- """
-
- date = Html5DateField(verbose_name=_('Date'))
- """
- The date the workout session was performed
- """
-
- notes = models.TextField(
- verbose_name=_('Notes'),
- null=True,
- blank=True,
- help_text=_('Any notes you might want to save about this workout '
- 'session.')
- )
- """
- User notes about the workout
- """
-
- impression = models.CharField(
- verbose_name=_('General impression'),
- max_length=2,
- choices=IMPRESSION,
- default=IMPRESSION_NEUTRAL,
- help_text=_(
- 'Your impression about this workout session. '
- 'Did you exercise as well as you could?'
- )
- )
- """
- The user's general impression of workout
- """
-
- time_start = models.TimeField(verbose_name=_('Start time'), blank=True, null=True)
- """
- Time the workout session started
- """
-
- time_end = models.TimeField(verbose_name=_('Finish time'), blank=True, null=True)
- """
- Time the workout session ended
- """
-
- def __str__(self):
- """
- Return a more human-readable representation
- """
- return "{0} - {1}".format(self.workout, self.date)
-
- class Meta:
- """
- Set other properties
- """
- ordering = [
- "date",
- ]
- unique_together = ("date", "user")
-
- def clean(self):
- """
- Perform some additional validations
- """
-
- if (not self.time_end and self.time_start) or (self.time_end and not self.time_start):
- raise ValidationError(_("If you enter a time, you must enter both start and end time."))
-
- if self.time_end and self.time_start and self.time_start > self.time_end:
- raise ValidationError(_("The start time cannot be after the end time."))
-
- def get_owner_object(self):
- """
- Returns the object that has owner information
- """
- return self
-
- def save(self, *args, **kwargs):
- """
- Reset cache
- """
- reset_workout_log(self.user_id, self.date.year, self.date.month)
- super(WorkoutSession, self).save(*args, **kwargs)
-
- def delete(self, *args, **kwargs):
- """
- Reset cache
- """
- reset_workout_log(self.user_id, self.date.year, self.date.month)
- super(WorkoutSession, self).delete(*args, **kwargs)
diff --git a/wger/manager/models/workout.py b/wger/manager/models/workout.py
index c490e10e5..71f1dd25a 100644
--- a/wger/manager/models/workout.py
+++ b/wger/manager/models/workout.py
@@ -65,15 +65,16 @@ class Workout(models.Model):
)
is_template = models.BooleanField(
verbose_name=_('Workout template'),
+ help_text=_('Marking a workout as a template will freeze it and allow you to '
+ 'make copies of it'),
default=False,
null=False,
- help_text=_(""),
)
is_public = models.BooleanField(
verbose_name=_('Public template'),
+ help_text=_('A public template will be available to other users'),
default=False,
null=False,
- help_text=_(""),
)
user = models.ForeignKey(User, verbose_name=_('User'), on_delete=models.CASCADE)