Add unit field to theoretical max
This commit is contained in:
parent
45d5879596
commit
8edc9c03f4
3 changed files with 54 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from gym.models import Room, Equipment, Setting, TheoreticalMax, Session, Round
|
||||
from gym.models import Room, Equipment, TheoreticalMax, Session, Round, Unit
|
||||
|
||||
|
||||
@admin.register(Room)
|
||||
|
@ -26,3 +26,8 @@ class SessionAdmin(admin.ModelAdmin):
|
|||
@admin.register(Round)
|
||||
class RoundAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
@admin.register(Unit)
|
||||
class UnitAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
|
30
gym/migrations/0006_auto_20180304_2037.py
Normal file
30
gym/migrations/0006_auto_20180304_2037.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 2.0.2 on 2018-03-04 19:37
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gym', '0005_auto_20180304_1025'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Unit',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=50, verbose_name='nom')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'unité',
|
||||
'verbose_name_plural': 'unités',
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='theoreticalmax',
|
||||
name='unit',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='gym.Unit', verbose_name='unité'),
|
||||
),
|
||||
]
|
|
@ -55,6 +55,17 @@ class Setting(models.Model):
|
|||
return f'{self.name}={self.value}'
|
||||
|
||||
|
||||
class Unit(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'unité'
|
||||
verbose_name_plural = 'unités'
|
||||
|
||||
name = models.CharField('nom', max_length=50)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class TheoreticalMax(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'maximum théorique'
|
||||
|
@ -68,9 +79,15 @@ class TheoreticalMax(models.Model):
|
|||
)
|
||||
date = models.DateField('date')
|
||||
value = models.FloatField('valeur')
|
||||
unit = models.ForeignKey(
|
||||
verbose_name='unité',
|
||||
to=Unit,
|
||||
on_delete=models.PROTECT,
|
||||
null=True
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.value} le {self.date}'
|
||||
return f'{self.value} {self.unit.name} le {self.date}'
|
||||
|
||||
|
||||
class Session(models.Model):
|
||||
|
|
Loading…
Reference in a new issue