init commit

init commit
This commit is contained in:
Trey t
2023-06-11 20:09:22 -05:00
commit a2fd663255
946 changed files with 38811 additions and 0 deletions

0
exercise/__init__.py Normal file
View File

10
exercise/admin.py Normal file
View File

@@ -0,0 +1,10 @@
from django.contrib import admin
from import_export.admin import ImportExportModelAdmin
from .models import *
# Register your models here.
@admin.register(Exercise)
class ExerciseAdmin(ImportExportModelAdmin):
search_fields = ['name', 'description', 'movement_patterns']
list_display = ("name", "description", "synonyms",)
readonly_fields = ('return_video_url',)

6
exercise/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class ExerciseConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'exercise'

View File

@@ -0,0 +1,37 @@
# Generated by Django 4.2.2 on 2023-06-11 22:00
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Exercise',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('name', models.CharField(blank=True, max_length=64, null=True)),
('description', models.CharField(blank=True, max_length=255, null=True)),
('side', models.CharField(blank=True, max_length=64, null=True)),
('is_two_dumbbells', models.BooleanField(default=False)),
('is_trackable_distance', models.BooleanField(default=False)),
('is_alternating', models.BooleanField(default=False)),
('is_weight', models.BooleanField(default=False)),
('is_distance', models.BooleanField(default=False)),
('is_duration', models.BooleanField(default=False)),
('is_reps', models.BooleanField(default=False)),
('joints_used', models.CharField(blank=True, max_length=255, null=True)),
('movement_patterns', models.CharField(blank=True, max_length=255, null=True)),
('equipment_required', models.CharField(blank=True, max_length=255, null=True)),
('muscle_groups', models.CharField(blank=True, max_length=255, null=True)),
('synonyms', models.CharField(blank=True, max_length=255, null=True)),
],
),
]

View File

31
exercise/models.py Normal file
View File

@@ -0,0 +1,31 @@
from django.db import models
from django.conf import settings
# Create your models here.
class Exercise(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
name = models.CharField(null=True, blank=True, max_length=64)
description = models.CharField(null=True, blank=True, max_length=255)
side = models.CharField(null=True, blank=True, max_length=64)
is_two_dumbbells = models.BooleanField(default=False)
is_trackable_distance = models.BooleanField(default=False)
is_alternating = models.BooleanField(default=False)
is_weight = models.BooleanField(default=False)
is_distance = models.BooleanField(default=False)
is_duration = models.BooleanField(default=False)
is_reps = models.BooleanField(default=False)
joints_used = models.CharField(null=True, blank=True, max_length=255)
movement_patterns = 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)
synonyms = models.CharField(null=True, blank=True, max_length=255)
class Meta:
ordering = ('name',)
def __str__(self):
return self.name + ":" + self.description
def return_video_url(self):
return str(settings.STATIC_ROOT) + "/" + self.name.replace(" ", "%20") + ".mp4"

9
exercise/serializers.py Normal file
View File

@@ -0,0 +1,9 @@
from rest_framework import serializers
from .models import *
class ExerciseSerializer(serializers.ModelSerializer):
return_video_url = serializers.ReadOnlyField()
class Meta:
model = Exercise
fields = '__all__'

3
exercise/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
exercise/urls.py Normal file
View File

@@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('all/', views.all_exercises, name='all exercises'),
]

22
exercise/views.py Normal file
View File

@@ -0,0 +1,22 @@
from django.shortcuts import render
from .models import *
from .serializers import *
from django.shortcuts import render
from rest_framework.decorators import api_view
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
from django.contrib.auth.models import User
from django.contrib.auth import authenticate
from rest_framework.authentication import TokenAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework.decorators import authentication_classes
from rest_framework.decorators import permission_classes
# Create your views here.
@api_view(['GET'])
def all_exercises(request):
users = Exercise.objects.all()
serializer = ExerciseSerializer(users, many=True)
return Response(data=serializer.data, status=status.HTTP_200_OK)