Add models

This commit is contained in:
Gabriel Augendre 2018-03-02 12:01:51 +01:00
parent a3d3280330
commit 753b5641c8
No known key found for this signature in database
GPG key ID: F360212F958357D4
10 changed files with 216 additions and 0 deletions

1
.gitignore vendored
View file

@ -177,3 +177,4 @@ venv.bak/
# End of https://www.gitignore.io/api/python,pycharm,osx # End of https://www.gitignore.io/api/python,pycharm,osx
db.sqlite3

0
gym/__init__.py Normal file
View file

3
gym/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
gym/apps.py Normal file
View file

@ -0,0 +1,5 @@
from django.apps import AppConfig
class GymConfig(AppConfig):
name = 'gym'

View file

@ -0,0 +1,104 @@
# Generated by Django 2.0.2 on 2018-03-02 11:00
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Equipment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=300, verbose_name='nom')),
],
options={
'verbose_name': 'machine',
'verbose_name_plural': 'machines',
},
),
migrations.CreateModel(
name='Room',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=300, verbose_name='nom')),
('latitude', models.DecimalField(decimal_places=8, max_digits=11, verbose_name='latitude')),
('longitude', models.DecimalField(decimal_places=8, max_digits=11, verbose_name='longitude')),
('notes', models.TextField(verbose_name='notes')),
],
options={
'verbose_name': 'salle',
'verbose_name_plural': 'salles',
},
),
migrations.CreateModel(
name='Round',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('repetition_number', models.PositiveIntegerField(verbose_name='nombre de répétitions')),
('theoretical_max_percentage', models.PositiveIntegerField(verbose_name='pourcentage')),
('chosen_weight', models.FloatField(verbose_name='charge choisie')),
('notes', models.TextField(verbose_name='notes')),
('equipment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rounds', to='gym.Equipment', verbose_name='machine')),
],
options={
'verbose_name': 'série',
'verbose_name_plural': 'séries',
},
),
migrations.CreateModel(
name='Session',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateField(verbose_name='date')),
('notes', models.TextField(verbose_name='notes')),
('room', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sessions', to='gym.Room', verbose_name='salle')),
],
options={
'verbose_name': 'séance',
'verbose_name_plural': 'séances',
},
),
migrations.CreateModel(
name='Setting',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, verbose_name='nom')),
('value', models.CharField(max_length=200, verbose_name='valeur')),
('equipment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='settings', to='gym.Equipment', verbose_name='machine')),
],
options={
'verbose_name': 'réglage',
'verbose_name_plural': 'réglages',
},
),
migrations.CreateModel(
name='TheoreticalMax',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateField(verbose_name='date')),
('value', models.FloatField(verbose_name='valeur')),
('equipment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='theoretical_maxs', to='gym.Equipment', verbose_name='machine')),
],
options={
'verbose_name': 'maximum théorique',
'verbose_name_plural': 'maximums théoriques',
},
),
migrations.AddField(
model_name='round',
name='session',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rounds', to='gym.Session', verbose_name='séance'),
),
migrations.AddField(
model_name='equipment',
name='room',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='equipments', to='gym.Room', verbose_name='salle'),
),
]

View file

96
gym/models.py Normal file
View file

@ -0,0 +1,96 @@
from django.db import models
class Room(models.Model):
class Meta:
verbose_name = 'salle'
verbose_name_plural = 'salles'
name = models.CharField('nom', max_length=300)
latitude = models.DecimalField('latitude', max_digits=11, decimal_places=8)
longitude = models.DecimalField('longitude', max_digits=11, decimal_places=8)
notes = models.TextField('notes')
class Equipment(models.Model):
class Meta:
verbose_name = 'machine'
verbose_name_plural = 'machines'
name = models.CharField('nom', max_length=300)
room = models.ForeignKey(
verbose_name='salle',
to=Room,
on_delete=models.SET_NULL,
related_name='equipments',
null=True
)
class Setting(models.Model):
class Meta:
verbose_name = 'réglage'
verbose_name_plural = 'réglages'
equipment = models.ForeignKey(
verbose_name='machine',
to=Equipment,
on_delete=models.CASCADE,
related_name='settings'
)
name = models.CharField('nom', max_length=200)
value = models.CharField('valeur', max_length=200)
class TheoreticalMax(models.Model):
class Meta:
verbose_name = 'maximum théorique'
verbose_name_plural = 'maximums théoriques'
equipment = models.ForeignKey(
verbose_name='machine',
to=Equipment,
on_delete=models.CASCADE,
related_name='theoretical_maxs'
)
date = models.DateField('date')
value = models.FloatField('valeur')
class Session(models.Model):
class Meta:
verbose_name = 'séance'
verbose_name_plural = 'séances'
date = models.DateField('date')
room = models.ForeignKey(
verbose_name='salle',
to=Room,
on_delete=models.SET_NULL,
related_name='sessions',
null=True
)
notes = models.TextField('notes')
class Round(models.Model):
class Meta:
verbose_name = 'série'
verbose_name_plural = 'séries'
repetition_number = models.PositiveIntegerField('nombre de répétitions')
equipment = models.ForeignKey(
verbose_name='machine',
to=Equipment,
on_delete=models.CASCADE,
related_name='rounds'
)
theoretical_max_percentage = models.PositiveIntegerField('pourcentage')
chosen_weight = models.FloatField('charge choisie')
session = models.ForeignKey(
verbose_name='séance',
to=Session,
on_delete=models.CASCADE,
related_name='rounds'
)
notes = models.TextField('notes')

3
gym/tests.py Normal file
View file

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

3
gym/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View file

@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'gym',
] ]
MIDDLEWARE = [ MIDDLEWARE = [