Skip to content

Commit

Permalink
Merge pull request #1398 from wger-project/feature/1387-add-last-modi…
Browse files Browse the repository at this point in the history
…fied-date-for-exercises

add last modified date for exercises
  • Loading branch information
rolandgeider authored Aug 6, 2023
2 parents 3203abe + 471e1d5 commit b829e84
Show file tree
Hide file tree
Showing 34 changed files with 17,327 additions and 7,065 deletions.
7 changes: 3 additions & 4 deletions extras/docker/development/settings.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# wger
from wger.settings_global import *

# Third Party
import environ

# wger
from wger.settings_global import *

env = environ.Env(
# set casting, default value
DJANGO_DEBUG=(bool, False)
Expand Down
7 changes: 3 additions & 4 deletions wger/core/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
AbstractWeight,
)
from wger.weight.models import WeightEntry

# Local
from .language import Language

Expand Down Expand Up @@ -523,9 +522,9 @@ def user_bodyweight(self, weight):
"""
if (
not WeightEntry.objects.filter(user=self.user).exists() or (
datetime.date.today() - WeightEntry.objects.filter(user=self.user).latest().date
> datetime.timedelta(days=3)
)
datetime.date.today() - WeightEntry.objects.filter(user=self.user).latest().date >
datetime.timedelta(days=3)
)
):
entry = WeightEntry()
entry.weight = weight
Expand Down
2 changes: 1 addition & 1 deletion wger/core/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h5 class="card-title">{% translate "Workout" %}</h5>
</a>
</p>
<p>
– {{ current_workout.creation_date }}
– {{ current_workout.created }}
<p>
{% endif %}

Expand Down
18 changes: 10 additions & 8 deletions wger/exercises/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from django.conf import settings
from django.core.cache import cache
from django.db.models import Q

# Third Party
from rest_framework import serializers

Expand Down Expand Up @@ -47,8 +46,8 @@ class Meta:
fields = [
'id',
'uuid',
'creation_date',
'update_date',
'created',
'last_update',
'category',
'muscles',
'muscles_secondary',
Expand Down Expand Up @@ -241,7 +240,7 @@ class Meta:
"name",
"exercise_base",
"description",
"creation_date",
"created",
"category",
"muscles",
"muscles_secondary",
Expand Down Expand Up @@ -276,7 +275,7 @@ class Meta:
"name",
"exercise_base",
"description",
"creation_date",
"created",
"language",
"aliases",
"notes",
Expand Down Expand Up @@ -309,7 +308,7 @@ class Meta:
"name",
"exercise_base",
"description",
"creation_date",
"created",
"language",
'license_author',
)
Expand Down Expand Up @@ -367,7 +366,7 @@ class Meta:
"uuid",
"exercise_base_id",
"description",
"creation_date",
"created",
"category",
"muscles",
"muscles_secondary",
Expand Down Expand Up @@ -398,14 +397,17 @@ class ExerciseBaseInfoSerializer(serializers.ModelSerializer):
variations = serializers.PrimaryKeyRelatedField(read_only=True)
author_history = serializers.ListSerializer(child=serializers.CharField())
total_authors_history = serializers.ListSerializer(child=serializers.CharField())
last_update_global = serializers.DateTimeField(read_only=True)

class Meta:
model = ExerciseBase
depth = 1
fields = [
"id",
"uuid",
"creation_date",
"created",
"last_update",
"last_update_global",
"category",
"muscles",
"muscles_secondary",
Expand Down
17 changes: 7 additions & 10 deletions wger/exercises/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@
# Standard Library
import logging

# Third Party
import bleach
from actstream import action as actstream_action
from bleach.css_sanitizer import CSSSanitizer
# Django
from django.conf import settings
from django.db.models import Q
from django.http import HttpRequest
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from django.views.decorators.cache import cache_page

# Third Party
import bleach
from actstream import action as actstream_action
from bleach.css_sanitizer import CSSSanitizer
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import (
OpenApiParameter,
Expand Down Expand Up @@ -91,7 +89,6 @@
)
from wger.utils.language import load_language


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -145,7 +142,7 @@ class ExerciseTranslationViewSet(ModelViewSet):
ordering_fields = '__all__'
filterset_fields = (
'uuid',
'creation_date',
'created',
'exercise_base',
'description',
'name',
Expand Down Expand Up @@ -214,7 +211,7 @@ class ExerciseViewSet(viewsets.ReadOnlyModelViewSet):
ordering_fields = '__all__'
filterset_fields = (
'uuid',
'creation_date',
'created',
'exercise_base',
'description',
'language',
Expand Down Expand Up @@ -380,7 +377,7 @@ class ExerciseInfoViewset(viewsets.ReadOnlyModelViewSet):
serializer_class = ExerciseInfoSerializer
ordering_fields = '__all__'
filterset_fields = (
'creation_date',
'created',
'description',
'name',
'exercise_base',
Expand Down
106 changes: 53 additions & 53 deletions wger/exercises/fixtures/categories.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
[
{
"pk": 8,
"fields": {
"name": "Arms"
},
"model": "exercises.exercisecategory"
"model": "exercises.exercisecategory",
"pk": 8,
"fields": {
"name": "Arms"
}
},
{
"pk": 9,
"fields": {
"name": "Legs"
},
"model": "exercises.exercisecategory"
},
{
"pk": 10,
"fields": {
"name": "Abs"
},
"model": "exercises.exercisecategory"
},
{
"pk": 11,
"fields": {
"name": "Chest"
},
"model": "exercises.exercisecategory"
},
{
"pk": 12,
"fields": {
"name": "Back"
},
"model": "exercises.exercisecategory"
},
{
"pk": 13,
"fields": {
"name": "Shoulders"
},
"model": "exercises.exercisecategory"
},
{
"pk": 14,
"fields": {
"name": "Calves"
},
"model": "exercises.exercisecategory"
},
{
"pk": 15,
"fields": {
"name": "Cardio"
},
"model": "exercises.exercisecategory"
{
"model": "exercises.exercisecategory",
"pk": 9,
"fields": {
"name": "Legs"
}
},
{
"model": "exercises.exercisecategory",
"pk": 10,
"fields": {
"name": "Abs"
}
},
{
"model": "exercises.exercisecategory",
"pk": 11,
"fields": {
"name": "Chest"
}
},
{
"model": "exercises.exercisecategory",
"pk": 12,
"fields": {
"name": "Back"
}
},
{
"model": "exercises.exercisecategory",
"pk": 13,
"fields": {
"name": "Shoulders"
}
},
{
"model": "exercises.exercisecategory",
"pk": 14,
"fields": {
"name": "Calves"
}
},
{
"model": "exercises.exercisecategory",
"pk": 15,
"fields": {
"name": "Cardio"
}
}
]
Loading

0 comments on commit b829e84

Please sign in to comment.