WIP
This commit is contained in:
@@ -5,4 +5,8 @@ from .models import *
|
||||
# Register your models here.
|
||||
@admin.register(Equipment)
|
||||
class EquipmentAdmin(ImportExportModelAdmin):
|
||||
list_display = ("name", "is_weight", "category",)
|
||||
list_display = ("name", "is_weight", "category",)
|
||||
|
||||
@admin.register(WorkoutEquipment)
|
||||
class WorkoutEquipmentAdmin(ImportExportModelAdmin):
|
||||
list_display = ("equipment", "exercise",)
|
||||
25
equipment/migrations/0002_workoutequipment.py
Normal file
25
equipment/migrations/0002_workoutequipment.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# Generated by Django 4.2.2 on 2023-06-13 02:07
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('exercise', '0002_alter_exercise_options'),
|
||||
('equipment', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='WorkoutEquipment',
|
||||
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)),
|
||||
('equipment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workout_exercise_workout', to='equipment.equipment')),
|
||||
('exercise', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workout_exercise_workout', to='exercise.exercise')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
from django.db import models
|
||||
from exercise.models import Exercise
|
||||
|
||||
# Create your models here.
|
||||
class Equipment(models.Model):
|
||||
@@ -9,4 +10,21 @@ class Equipment(models.Model):
|
||||
name = models.CharField(null=True, blank=True, max_length=64)
|
||||
|
||||
def __str__(self):
|
||||
return self.category + " : " + self.name
|
||||
return self.category + " : " + self.name
|
||||
|
||||
class WorkoutEquipment(models.Model):
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
exercise = models.ForeignKey(
|
||||
Exercise,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='workout_exercise_workout'
|
||||
)
|
||||
equipment = models.ForeignKey(
|
||||
Equipment,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='workout_exercise_workout'
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.exercise.name + " : " + self.equipment.name
|
||||
Reference in New Issue
Block a user