wip
BIN
db.sqlite3
@@ -7,4 +7,4 @@ from .models import *
|
|||||||
class ExerciseAdmin(ImportExportModelAdmin):
|
class ExerciseAdmin(ImportExportModelAdmin):
|
||||||
search_fields = ['name', 'description', 'movement_patterns']
|
search_fields = ['name', 'description', 'movement_patterns']
|
||||||
list_display = ("name", "description", "synonyms",)
|
list_display = ("name", "description", "synonyms",)
|
||||||
readonly_fields = ('return_video_url',)
|
readonly_fields = ('video_url', 'audio_url',)
|
||||||
|
|||||||
18
exercise/migrations/0003_exercise_duration.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.2 on 2023-06-14 13:23
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('exercise', '0002_alter_exercise_options'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='exercise',
|
||||||
|
name='duration',
|
||||||
|
field=models.IntegerField(blank=True, max_length=4, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
17
exercise/migrations/0004_remove_exercise_duration.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 4.2.2 on 2023-06-14 13:24
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('exercise', '0003_exercise_duration'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='exercise',
|
||||||
|
name='duration',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -20,12 +20,15 @@ class Exercise(models.Model):
|
|||||||
equipment_required = models.CharField(null=True, blank=True, max_length=255)
|
equipment_required = models.CharField(null=True, blank=True, max_length=255)
|
||||||
muscle_groups = models.CharField(null=True, blank=True, max_length=255)
|
muscle_groups = models.CharField(null=True, blank=True, max_length=255)
|
||||||
synonyms = models.CharField(null=True, blank=True, max_length=255)
|
synonyms = models.CharField(null=True, blank=True, max_length=255)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('name',)
|
ordering = ('name',)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name + ":" + self.description
|
return self.name + ":" + self.description
|
||||||
|
|
||||||
def return_video_url(self):
|
def video_url(self):
|
||||||
return str(settings.STATIC_ROOT) + "/" + self.name.replace(" ", "%20") + ".mp4"
|
return str(settings.MEDIA_URL) + "exercise_videos/" + self.name.replace(" ", "_") + ".mp4"
|
||||||
|
|
||||||
|
def audio_url(self):
|
||||||
|
return str(settings.MEDIA_URL) + "exercise_audio/" + self.name.replace(" ", "_") + ".m4a"
|
||||||
@@ -7,7 +7,8 @@ from muscle.serializers import ExerciseMuscleSerializer
|
|||||||
class ExerciseSerializer(serializers.ModelSerializer):
|
class ExerciseSerializer(serializers.ModelSerializer):
|
||||||
muscles = serializers.SerializerMethodField()
|
muscles = serializers.SerializerMethodField()
|
||||||
equipment = serializers.SerializerMethodField()
|
equipment = serializers.SerializerMethodField()
|
||||||
return_video_url = serializers.ReadOnlyField()
|
audio_url = serializers.ReadOnlyField()
|
||||||
|
video_url = serializers.ReadOnlyField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Exercise
|
model = Exercise
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# path('sync_equipment/', views.sync_equipment, name='sync_equipment'),
|
# path('sync_equipment/', views.sync_equipment, name='sync_equipment'),
|
||||||
path('sync_muscle_groups/', views.sync_equipment, name='sync_equipment'),
|
# path('sync_muscle_groups/', views.sync_muscle_groups, name='sync_equipment'),
|
||||||
]
|
]
|
||||||
@@ -24,7 +24,7 @@ def sync_equipment(request):
|
|||||||
return Response(status=status.HTTP_200_OK)
|
return Response(status=status.HTTP_200_OK)
|
||||||
|
|
||||||
@api_view(['GET'])
|
@api_view(['GET'])
|
||||||
def sync_equipment(request):
|
def sync_muscle_groups(request):
|
||||||
all_exercise = Exercise.objects.all()
|
all_exercise = Exercise.objects.all()
|
||||||
for exercise in all_exercise:
|
for exercise in all_exercise:
|
||||||
all_muscle_groups = exercise.muscle_groups.split(',')
|
all_muscle_groups = exercise.muscle_groups.split(',')
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 331 B |
|
Before Width: | Height: | Size: 504 B After Width: | Height: | Size: 504 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 380 B After Width: | Height: | Size: 380 B |
|
Before Width: | Height: | Size: 677 B After Width: | Height: | Size: 677 B |
|
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 392 B |
|
Before Width: | Height: | Size: 560 B After Width: | Height: | Size: 560 B |
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 581 B After Width: | Height: | Size: 581 B |
|
Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 436 B |
|
Before Width: | Height: | Size: 560 B After Width: | Height: | Size: 560 B |
|
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 331 B |
|
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 280 B |