Black everything
This commit is contained in:
parent
f0c18dbe74
commit
5fc79b9486
18 changed files with 737 additions and 524 deletions
44
gym/admin.py
44
gym/admin.py
|
@ -5,37 +5,51 @@ from gym.models import Room, Equipment, TheoreticalMax, Session, Round, Unit, Wo
|
|||
|
||||
@admin.register(Room)
|
||||
class RoomAdmin(admin.ModelAdmin):
|
||||
list_display = ['name', 'latitude', 'longitude']
|
||||
list_display = ["name", "latitude", "longitude"]
|
||||
|
||||
|
||||
@admin.register(Equipment)
|
||||
class EquipmentAdmin(admin.ModelAdmin):
|
||||
list_display = ['name', 'room', 'unit', 'last_theoretical_max', 'default_work_form', 'default_repetition_number']
|
||||
list_editable = ['default_work_form', 'default_repetition_number']
|
||||
list_filter = ['room', 'unit', 'default_work_form']
|
||||
list_display = [
|
||||
"name",
|
||||
"room",
|
||||
"unit",
|
||||
"last_theoretical_max",
|
||||
"default_work_form",
|
||||
"default_repetition_number",
|
||||
]
|
||||
list_editable = ["default_work_form", "default_repetition_number"]
|
||||
list_filter = ["room", "unit", "default_work_form"]
|
||||
|
||||
|
||||
@admin.register(TheoreticalMax)
|
||||
class TheoreticalMaxAdmin(admin.ModelAdmin):
|
||||
list_display = ['equipment', 'date', 'value']
|
||||
list_display_links = ['equipment', 'date']
|
||||
list_filter = ['equipment']
|
||||
date_hierarchy = 'date'
|
||||
list_display = ["equipment", "date", "value"]
|
||||
list_display_links = ["equipment", "date"]
|
||||
list_filter = ["equipment"]
|
||||
date_hierarchy = "date"
|
||||
|
||||
|
||||
@admin.register(Session)
|
||||
class SessionAdmin(admin.ModelAdmin):
|
||||
list_display = ['start', 'room', 'default_theoretical_max_percentage']
|
||||
list_filter = ['room']
|
||||
date_hierarchy = 'start'
|
||||
list_display = ["start", "room", "default_theoretical_max_percentage"]
|
||||
list_filter = ["room"]
|
||||
date_hierarchy = "start"
|
||||
|
||||
|
||||
@admin.register(Round)
|
||||
class RoundAdmin(admin.ModelAdmin):
|
||||
list_display = ['equipment', 'session', 'repetition_number', 'theoretical_max_percentage', 'chosen_weight', 'work_form']
|
||||
list_display_links = ['equipment', 'session']
|
||||
list_filter = ['equipment', 'work_form']
|
||||
date_hierarchy = 'session__start'
|
||||
list_display = [
|
||||
"equipment",
|
||||
"session",
|
||||
"repetition_number",
|
||||
"theoretical_max_percentage",
|
||||
"chosen_weight",
|
||||
"work_form",
|
||||
]
|
||||
list_display_links = ["equipment", "session"]
|
||||
list_filter = ["equipment", "work_form"]
|
||||
date_hierarchy = "session__start"
|
||||
|
||||
|
||||
@admin.register(Unit)
|
||||
|
|
|
@ -2,4 +2,4 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class GymConfig(AppConfig):
|
||||
name = 'gym'
|
||||
name = "gym"
|
||||
|
|
|
@ -8,97 +8,189 @@ class Migration(migrations.Migration):
|
|||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
dependencies = []
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Equipment',
|
||||
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')),
|
||||
(
|
||||
"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',
|
||||
},
|
||||
options={"verbose_name": "machine", "verbose_name_plural": "machines"},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Room',
|
||||
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')),
|
||||
(
|
||||
"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',
|
||||
},
|
||||
options={"verbose_name": "salle", "verbose_name_plural": "salles"},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Round',
|
||||
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')),
|
||||
(
|
||||
"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',
|
||||
},
|
||||
options={"verbose_name": "série", "verbose_name_plural": "séries"},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Session',
|
||||
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')),
|
||||
(
|
||||
"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',
|
||||
},
|
||||
options={"verbose_name": "séance", "verbose_name_plural": "séances"},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Setting',
|
||||
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')),
|
||||
(
|
||||
"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',
|
||||
},
|
||||
options={"verbose_name": "réglage", "verbose_name_plural": "réglages"},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='TheoreticalMax',
|
||||
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')),
|
||||
(
|
||||
"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',
|
||||
"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'),
|
||||
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'),
|
||||
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",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -5,34 +5,36 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gym', '0001_initial'),
|
||||
]
|
||||
dependencies = [("gym", "0001_initial")]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='room',
|
||||
name='latitude',
|
||||
field=models.DecimalField(blank=True, decimal_places=8, max_digits=11, verbose_name='latitude'),
|
||||
model_name="room",
|
||||
name="latitude",
|
||||
field=models.DecimalField(
|
||||
blank=True, decimal_places=8, max_digits=11, verbose_name="latitude"
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='room',
|
||||
name='longitude',
|
||||
field=models.DecimalField(blank=True, decimal_places=8, max_digits=11, verbose_name='longitude'),
|
||||
model_name="room",
|
||||
name="longitude",
|
||||
field=models.DecimalField(
|
||||
blank=True, decimal_places=8, max_digits=11, verbose_name="longitude"
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='room',
|
||||
name='notes',
|
||||
field=models.TextField(blank=True, verbose_name='notes'),
|
||||
model_name="room",
|
||||
name="notes",
|
||||
field=models.TextField(blank=True, verbose_name="notes"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='round',
|
||||
name='notes',
|
||||
field=models.TextField(blank=True, verbose_name='notes'),
|
||||
model_name="round",
|
||||
name="notes",
|
||||
field=models.TextField(blank=True, verbose_name="notes"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='session',
|
||||
name='notes',
|
||||
field=models.TextField(blank=True, verbose_name='notes'),
|
||||
model_name="session",
|
||||
name="notes",
|
||||
field=models.TextField(blank=True, verbose_name="notes"),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -5,14 +5,12 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gym', '0002_auto_20180303_1201'),
|
||||
]
|
||||
dependencies = [("gym", "0002_auto_20180303_1201")]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='session',
|
||||
name='date',
|
||||
field=models.DateTimeField(verbose_name='date et heure de début'),
|
||||
),
|
||||
model_name="session",
|
||||
name="date",
|
||||
field=models.DateTimeField(verbose_name="date et heure de début"),
|
||||
)
|
||||
]
|
||||
|
|
|
@ -5,14 +5,8 @@ from django.db import migrations
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gym', '0003_auto_20180303_1801'),
|
||||
]
|
||||
dependencies = [("gym", "0003_auto_20180303_1801")]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='session',
|
||||
old_name='date',
|
||||
new_name='start',
|
||||
),
|
||||
migrations.RenameField(model_name="session", old_name="date", new_name="start")
|
||||
]
|
||||
|
|
|
@ -5,19 +5,29 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gym', '0004_auto_20180303_1801'),
|
||||
]
|
||||
dependencies = [("gym", "0004_auto_20180303_1801")]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='room',
|
||||
name='latitude',
|
||||
field=models.DecimalField(blank=True, decimal_places=8, max_digits=11, null=True, verbose_name='latitude'),
|
||||
model_name="room",
|
||||
name="latitude",
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=8,
|
||||
max_digits=11,
|
||||
null=True,
|
||||
verbose_name="latitude",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='room',
|
||||
name='longitude',
|
||||
field=models.DecimalField(blank=True, decimal_places=8, max_digits=11, null=True, verbose_name='longitude'),
|
||||
model_name="room",
|
||||
name="longitude",
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=8,
|
||||
max_digits=11,
|
||||
null=True,
|
||||
verbose_name="longitude",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,25 +6,33 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gym', '0005_auto_20180304_1025'),
|
||||
]
|
||||
dependencies = [("gym", "0005_auto_20180304_1025")]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Unit',
|
||||
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')),
|
||||
(
|
||||
"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',
|
||||
},
|
||||
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é'),
|
||||
model_name="theoreticalmax",
|
||||
name="unit",
|
||||
field=models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to="gym.Unit",
|
||||
verbose_name="unité",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,18 +6,18 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gym', '0006_auto_20180304_2037'),
|
||||
]
|
||||
dependencies = [("gym", "0006_auto_20180304_2037")]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='theoreticalmax',
|
||||
name='unit',
|
||||
),
|
||||
migrations.RemoveField(model_name="theoreticalmax", name="unit"),
|
||||
migrations.AddField(
|
||||
model_name='equipment',
|
||||
name='unit',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='gym.Unit', verbose_name='unité'),
|
||||
model_name="equipment",
|
||||
name="unit",
|
||||
field=models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to="gym.Unit",
|
||||
verbose_name="unité",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,35 +6,53 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gym', '0007_auto_20180313_0857'),
|
||||
]
|
||||
dependencies = [("gym", "0007_auto_20180313_0857")]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='WorkForm',
|
||||
name="WorkForm",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=300, verbose_name='nom')),
|
||||
(
|
||||
"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': 'forme de travail',
|
||||
'verbose_name_plural': 'formes de travail',
|
||||
"verbose_name": "forme de travail",
|
||||
"verbose_name_plural": "formes de travail",
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='equipment',
|
||||
name='default_repetition_number',
|
||||
field=models.PositiveIntegerField(default=12, verbose_name='nombre de répétitions par défaut'),
|
||||
model_name="equipment",
|
||||
name="default_repetition_number",
|
||||
field=models.PositiveIntegerField(
|
||||
default=12, verbose_name="nombre de répétitions par défaut"
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='equipment',
|
||||
name='default_work_form',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='gym.WorkForm', verbose_name='forme de travail par défaut'),
|
||||
model_name="equipment",
|
||||
name="default_work_form",
|
||||
field=models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
to="gym.WorkForm",
|
||||
verbose_name="forme de travail par défaut",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='round',
|
||||
name='work_form',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='gym.WorkForm', verbose_name='forme de travail'),
|
||||
model_name="round",
|
||||
name="work_form",
|
||||
field=models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to="gym.WorkForm",
|
||||
verbose_name="forme de travail",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -5,14 +5,14 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gym', '0008_auto_20180313_0913'),
|
||||
]
|
||||
dependencies = [("gym", "0008_auto_20180313_0913")]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='session',
|
||||
name='default_theoretical_max_percentage',
|
||||
field=models.PositiveIntegerField(default=65, verbose_name='pourcentage par défaut'),
|
||||
),
|
||||
model_name="session",
|
||||
name="default_theoretical_max_percentage",
|
||||
field=models.PositiveIntegerField(
|
||||
default=65, verbose_name="pourcentage par défaut"
|
||||
),
|
||||
)
|
||||
]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class SessionResetMixin:
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if 'session_pk' in request.session:
|
||||
del request.session['session_pk']
|
||||
if "session_pk" in request.session:
|
||||
del request.session["session_pk"]
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
@ -12,5 +12,5 @@ class QuickActionsMixin:
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['quick_actions'] = self.get_quick_actions()
|
||||
context["quick_actions"] = self.get_quick_actions()
|
||||
return context
|
||||
|
|
132
gym/models.py
132
gym/models.py
|
@ -4,13 +4,17 @@ from django.db import models
|
|||
|
||||
class Room(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'salle'
|
||||
verbose_name_plural = 'salles'
|
||||
verbose_name = "salle"
|
||||
verbose_name_plural = "salles"
|
||||
|
||||
name = models.CharField('nom', max_length=300)
|
||||
latitude = models.DecimalField('latitude', max_digits=11, decimal_places=8, blank=True, null=True)
|
||||
longitude = models.DecimalField('longitude', max_digits=11, decimal_places=8, blank=True, null=True)
|
||||
notes = models.TextField('notes', blank=True)
|
||||
name = models.CharField("nom", max_length=300)
|
||||
latitude = models.DecimalField(
|
||||
"latitude", max_digits=11, decimal_places=8, blank=True, null=True
|
||||
)
|
||||
longitude = models.DecimalField(
|
||||
"longitude", max_digits=11, decimal_places=8, blank=True, null=True
|
||||
)
|
||||
notes = models.TextField("notes", blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -18,10 +22,10 @@ class Room(models.Model):
|
|||
|
||||
class Unit(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'unité'
|
||||
verbose_name_plural = 'unités'
|
||||
verbose_name = "unité"
|
||||
verbose_name_plural = "unités"
|
||||
|
||||
name = models.CharField('nom', max_length=50)
|
||||
name = models.CharField("nom", max_length=50)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -29,10 +33,10 @@ class Unit(models.Model):
|
|||
|
||||
class WorkForm(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'forme de travail'
|
||||
verbose_name_plural = 'formes de travail'
|
||||
verbose_name = "forme de travail"
|
||||
verbose_name_plural = "formes de travail"
|
||||
|
||||
name = models.CharField('nom', max_length=300)
|
||||
name = models.CharField("nom", max_length=300)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -40,122 +44,124 @@ class WorkForm(models.Model):
|
|||
|
||||
class Equipment(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'machine'
|
||||
verbose_name_plural = 'machines'
|
||||
verbose_name = "machine"
|
||||
verbose_name_plural = "machines"
|
||||
|
||||
name = models.CharField('nom', max_length=300)
|
||||
name = models.CharField("nom", max_length=300)
|
||||
room = models.ForeignKey(
|
||||
verbose_name='salle',
|
||||
verbose_name="salle",
|
||||
to=Room,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name='equipments',
|
||||
null=True
|
||||
related_name="equipments",
|
||||
null=True,
|
||||
)
|
||||
unit = models.ForeignKey(
|
||||
verbose_name='unité',
|
||||
to=Unit,
|
||||
on_delete=models.PROTECT,
|
||||
null=True
|
||||
verbose_name="unité", to=Unit, on_delete=models.PROTECT, null=True
|
||||
)
|
||||
default_work_form = models.ForeignKey(
|
||||
verbose_name='forme de travail par défaut',
|
||||
default_work_form = models.ForeignKey(
|
||||
verbose_name="forme de travail par défaut",
|
||||
to=WorkForm,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True
|
||||
null=True,
|
||||
)
|
||||
default_repetition_number = models.PositiveIntegerField(
|
||||
"nombre de répétitions par défaut", default=12
|
||||
)
|
||||
default_repetition_number = models.PositiveIntegerField('nombre de répétitions par défaut', default=12)
|
||||
|
||||
@property
|
||||
def last_theoretical_max(self):
|
||||
return self.theoretical_maxs.order_by('-date', '-pk').first()
|
||||
return self.theoretical_maxs.order_by("-date", "-pk").first()
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.name} ({self.room.name})'
|
||||
return f"{self.name} ({self.room.name})"
|
||||
|
||||
|
||||
class Setting(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'réglage'
|
||||
verbose_name_plural = 'réglages'
|
||||
verbose_name = "réglage"
|
||||
verbose_name_plural = "réglages"
|
||||
|
||||
equipment = models.ForeignKey(
|
||||
verbose_name='machine',
|
||||
verbose_name="machine",
|
||||
to=Equipment,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='settings'
|
||||
related_name="settings",
|
||||
)
|
||||
name = models.CharField('nom', max_length=200)
|
||||
value = models.CharField('valeur', max_length=200)
|
||||
name = models.CharField("nom", max_length=200)
|
||||
value = models.CharField("valeur", max_length=200)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.name}={self.value}'
|
||||
return f"{self.name}={self.value}"
|
||||
|
||||
|
||||
class TheoreticalMax(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'maximum théorique'
|
||||
verbose_name_plural = 'maximums théoriques'
|
||||
verbose_name = "maximum théorique"
|
||||
verbose_name_plural = "maximums théoriques"
|
||||
|
||||
equipment = models.ForeignKey(
|
||||
verbose_name='machine',
|
||||
verbose_name="machine",
|
||||
to=Equipment,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='theoretical_maxs'
|
||||
related_name="theoretical_maxs",
|
||||
)
|
||||
date = models.DateField('date')
|
||||
value = models.FloatField('valeur')
|
||||
date = models.DateField("date")
|
||||
value = models.FloatField("valeur")
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.value} {self.equipment.unit.name} le {self.date:%d/%m/%Y}'
|
||||
return f"{self.value} {self.equipment.unit.name} le {self.date:%d/%m/%Y}"
|
||||
|
||||
|
||||
class Session(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'séance'
|
||||
verbose_name_plural = 'séances'
|
||||
verbose_name = "séance"
|
||||
verbose_name_plural = "séances"
|
||||
|
||||
start = models.DateTimeField('date et heure de début')
|
||||
start = models.DateTimeField("date et heure de début")
|
||||
room = models.ForeignKey(
|
||||
verbose_name='salle',
|
||||
verbose_name="salle",
|
||||
to=Room,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name='sessions',
|
||||
null=True
|
||||
related_name="sessions",
|
||||
null=True,
|
||||
)
|
||||
default_theoretical_max_percentage = models.PositiveIntegerField('pourcentage par défaut', default=65)
|
||||
notes = models.TextField('notes', blank=True)
|
||||
default_theoretical_max_percentage = models.PositiveIntegerField(
|
||||
"pourcentage par défaut", default=65
|
||||
)
|
||||
notes = models.TextField("notes", blank=True)
|
||||
|
||||
def __str__(self):
|
||||
import pytz
|
||||
|
||||
server_timezone = pytz.timezone(settings.TIME_ZONE)
|
||||
server = server_timezone.normalize(self.start.astimezone(server_timezone))
|
||||
return f'{self.room} {server:%d/%m/%Y %H:%M} ({settings.TIME_ZONE})'
|
||||
return f"{self.room} {server:%d/%m/%Y %H:%M} ({settings.TIME_ZONE})"
|
||||
|
||||
|
||||
class Round(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'série'
|
||||
verbose_name_plural = 'séries'
|
||||
verbose_name = "série"
|
||||
verbose_name_plural = "séries"
|
||||
|
||||
repetition_number = models.PositiveIntegerField('nombre de répétitions')
|
||||
repetition_number = models.PositiveIntegerField("nombre de répétitions")
|
||||
equipment = models.ForeignKey(
|
||||
verbose_name='machine',
|
||||
verbose_name="machine",
|
||||
to=Equipment,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='rounds'
|
||||
related_name="rounds",
|
||||
)
|
||||
theoretical_max_percentage = models.PositiveIntegerField('pourcentage')
|
||||
chosen_weight = models.FloatField('charge choisie')
|
||||
theoretical_max_percentage = models.PositiveIntegerField("pourcentage")
|
||||
chosen_weight = models.FloatField("charge choisie")
|
||||
session = models.ForeignKey(
|
||||
verbose_name='séance',
|
||||
verbose_name="séance",
|
||||
to=Session,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='rounds'
|
||||
related_name="rounds",
|
||||
)
|
||||
work_form = models.ForeignKey(
|
||||
verbose_name='forme de travail',
|
||||
verbose_name="forme de travail",
|
||||
to=WorkForm,
|
||||
on_delete=models.PROTECT,
|
||||
null=True
|
||||
null=True,
|
||||
)
|
||||
notes = models.TextField('notes', blank=True)
|
||||
notes = models.TextField("notes", blank=True)
|
||||
|
|
49
gym/urls.py
49
gym/urls.py
|
@ -5,20 +5,39 @@ from . import views
|
|||
# Wire up our API using automatic URL routing.
|
||||
# Additionally, we include login URLs for the browsable API.
|
||||
urlpatterns = [
|
||||
path('', views.RoomListView.as_view(), name='rooms-list'),
|
||||
path('rooms/<int:pk>/', views.RoomDetailView.as_view(), name='room-detail'),
|
||||
path('equipment/add/', views.EquipmentCreateView.as_view(), name='equipment-create'),
|
||||
path('equipment/<int:pk>/', views.EquipmentDetailView.as_view(), name='equipment-detail'),
|
||||
path('equipment/<int:pk>/maxs', views.TheoreticalMaxListView.as_view(), name='theoretical-max-list'),
|
||||
path('setting/add/', views.SettingCreateView.as_view(), name='setting-create'),
|
||||
path('setting/<int:pk>/', views.SettingUpdateView.as_view(), name='setting-edit'),
|
||||
path('setting/<int:pk>/delete/', views.SettingDeleteView.as_view(), name='setting-delete'),
|
||||
path('session/start/', views.SessionCreateView.as_view(), name='session-start'),
|
||||
path('session/<int:pk>/', views.SessionDetailView.as_view(), name='session-detail'),
|
||||
path('round/add/', views.RoundCreateView.as_view(), name='round-create'),
|
||||
path('round/<int:pk>/', views.RoundUpdateView.as_view(), name='round-edit'),
|
||||
path('round/<int:pk>/delete/', views.RoundDeleteView.as_view(), name='round-delete'),
|
||||
path('theoretical-max/add/', views.TheoreticalMaxCreateView.as_view(), name='theoretical-max-create'),
|
||||
path("", views.RoomListView.as_view(), name="rooms-list"),
|
||||
path("rooms/<int:pk>/", views.RoomDetailView.as_view(), name="room-detail"),
|
||||
path(
|
||||
"equipment/add/", views.EquipmentCreateView.as_view(), name="equipment-create"
|
||||
),
|
||||
path(
|
||||
"equipment/<int:pk>/",
|
||||
views.EquipmentDetailView.as_view(),
|
||||
name="equipment-detail",
|
||||
),
|
||||
path(
|
||||
"equipment/<int:pk>/maxs",
|
||||
views.TheoreticalMaxListView.as_view(),
|
||||
name="theoretical-max-list",
|
||||
),
|
||||
path("setting/add/", views.SettingCreateView.as_view(), name="setting-create"),
|
||||
path("setting/<int:pk>/", views.SettingUpdateView.as_view(), name="setting-edit"),
|
||||
path(
|
||||
"setting/<int:pk>/delete/",
|
||||
views.SettingDeleteView.as_view(),
|
||||
name="setting-delete",
|
||||
),
|
||||
path("session/start/", views.SessionCreateView.as_view(), name="session-start"),
|
||||
path("session/<int:pk>/", views.SessionDetailView.as_view(), name="session-detail"),
|
||||
path("round/add/", views.RoundCreateView.as_view(), name="round-create"),
|
||||
path("round/<int:pk>/", views.RoundUpdateView.as_view(), name="round-edit"),
|
||||
path(
|
||||
"round/<int:pk>/delete/", views.RoundDeleteView.as_view(), name="round-delete"
|
||||
),
|
||||
path(
|
||||
"theoretical-max/add/",
|
||||
views.TheoreticalMaxCreateView.as_view(),
|
||||
name="theoretical-max-create",
|
||||
),
|
||||
# path('session/<int:pk>/delete/', views.SessionDeleteView.as_view(), name='session-delete'),
|
||||
]
|
||||
|
||||
|
|
472
gym/views.py
472
gym/views.py
|
@ -12,120 +12,145 @@ from gym.models import Room, Equipment, Setting, Session, Round, TheoreticalMax
|
|||
|
||||
|
||||
class RoomListView(LoginRequiredMixin, SessionResetMixin, generic.ListView):
|
||||
queryset = Room.objects.all().order_by('name')
|
||||
context_object_name = 'rooms'
|
||||
template_name = 'gym/rooms.html'
|
||||
queryset = Room.objects.all().order_by("name")
|
||||
context_object_name = "rooms"
|
||||
template_name = "gym/rooms.html"
|
||||
|
||||
|
||||
class RoomDetailView(LoginRequiredMixin, QuickActionsMixin, SessionResetMixin, generic.DetailView):
|
||||
class RoomDetailView(
|
||||
LoginRequiredMixin, QuickActionsMixin, SessionResetMixin, generic.DetailView
|
||||
):
|
||||
model = Room
|
||||
context_object_name = 'room'
|
||||
template_name = 'gym/room.html'
|
||||
context_object_name = "room"
|
||||
template_name = "gym/room.html"
|
||||
|
||||
def get_quick_actions(self):
|
||||
quick_actions = [
|
||||
{
|
||||
'url': reverse('rooms-list'),
|
||||
'category': 'secondary',
|
||||
'display': 'Liste des salles'
|
||||
"url": reverse("rooms-list"),
|
||||
"category": "secondary",
|
||||
"display": "Liste des salles",
|
||||
},
|
||||
{
|
||||
'url': "{}?room={}".format(reverse('session-start'), self.object.pk),
|
||||
'category': 'primary',
|
||||
'display': 'Commencer une séance'
|
||||
"url": "{}?room={}".format(reverse("session-start"), self.object.pk),
|
||||
"category": "primary",
|
||||
"display": "Commencer une séance",
|
||||
},
|
||||
{
|
||||
'url': "{}?room={}".format(reverse('equipment-create'), self.object.pk),
|
||||
'category': 'success',
|
||||
'display': 'Ajouter une machine'
|
||||
"url": "{}?room={}".format(reverse("equipment-create"), self.object.pk),
|
||||
"category": "success",
|
||||
"display": "Ajouter une machine",
|
||||
},
|
||||
]
|
||||
|
||||
if self.object.latitude and self.object.longitude:
|
||||
from user_agents import parse
|
||||
user_agent = parse(self.request.META.get('HTTP_USER_AGENT'))
|
||||
|
||||
user_agent = parse(self.request.META.get("HTTP_USER_AGENT"))
|
||||
|
||||
if user_agent.is_mobile:
|
||||
url = f"waze://?ll={self.object.latitude},{self.object.longitude}&navigate=yes"
|
||||
name = 'Waze'
|
||||
name = "Waze"
|
||||
|
||||
quick_actions.append({
|
||||
'url': f"here-location://{self.object.latitude},{self.object.longitude}",
|
||||
'category': 'info',
|
||||
'display': 'Here WeGo',
|
||||
'icon': 'fas fa-location-arrow',
|
||||
})
|
||||
quick_actions.append(
|
||||
{
|
||||
"url": f"here-location://{self.object.latitude},{self.object.longitude}",
|
||||
"category": "info",
|
||||
"display": "Here WeGo",
|
||||
"icon": "fas fa-location-arrow",
|
||||
}
|
||||
)
|
||||
else:
|
||||
url = (f"https://www.google.com/maps/place/{self.object.latitude},{self.object.longitude}"
|
||||
f"/@{self.object.latitude},{self.object.longitude},18z")
|
||||
name = 'Google Maps'
|
||||
url = (
|
||||
f"https://www.google.com/maps/place/{self.object.latitude},{self.object.longitude}"
|
||||
f"/@{self.object.latitude},{self.object.longitude},18z"
|
||||
)
|
||||
name = "Google Maps"
|
||||
|
||||
quick_actions.append({
|
||||
'url': url,
|
||||
'category': 'info',
|
||||
'display': name,
|
||||
'icon': 'fas fa-location-arrow',
|
||||
})
|
||||
quick_actions.append(
|
||||
{
|
||||
"url": url,
|
||||
"category": "info",
|
||||
"display": name,
|
||||
"icon": "fas fa-location-arrow",
|
||||
}
|
||||
)
|
||||
return quick_actions
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['sessions'] = self.object.sessions.all().order_by('-start')
|
||||
context["sessions"] = self.object.sessions.all().order_by("-start")
|
||||
return context
|
||||
|
||||
|
||||
class EquipmentDetailView(LoginRequiredMixin, QuickActionsMixin, generic.DetailView):
|
||||
model = Equipment
|
||||
context_object_name = 'equipment'
|
||||
template_name = 'gym/equipment.html'
|
||||
context_object_name = "equipment"
|
||||
template_name = "gym/equipment.html"
|
||||
session = None
|
||||
|
||||
def get_quick_actions(self):
|
||||
lst = []
|
||||
|
||||
if self.session:
|
||||
lst.extend([
|
||||
lst.extend(
|
||||
[
|
||||
{
|
||||
"url": reverse("session-detail", args=(self.session.pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la séance",
|
||||
},
|
||||
{
|
||||
"url": "{}?equipment={}".format(
|
||||
reverse("round-create"), self.object.pk
|
||||
),
|
||||
"category": "primary",
|
||||
"display": "Commencer une série",
|
||||
},
|
||||
]
|
||||
)
|
||||
else:
|
||||
lst.append(
|
||||
{
|
||||
'url': reverse('session-detail', args=(self.session.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la séance'
|
||||
"url": reverse("room-detail", args=(self.object.room.pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la salle",
|
||||
}
|
||||
)
|
||||
lst.extend(
|
||||
[
|
||||
{
|
||||
"url": "{}?equipment={}".format(
|
||||
reverse("setting-create"), self.object.pk
|
||||
),
|
||||
"category": "success",
|
||||
"display": "Ajouter un réglage",
|
||||
},
|
||||
{
|
||||
'url': '{}?equipment={}'.format(reverse('round-create'), self.object.pk),
|
||||
'category': 'primary',
|
||||
'display': 'Commencer une série'
|
||||
}
|
||||
])
|
||||
else:
|
||||
lst.append({
|
||||
'url': reverse('room-detail', args=(self.object.room.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la salle'
|
||||
})
|
||||
lst.extend([
|
||||
{
|
||||
'url': '{}?equipment={}'.format(reverse('setting-create'), self.object.pk),
|
||||
'category': 'success',
|
||||
'display': 'Ajouter un réglage'
|
||||
},
|
||||
{
|
||||
'url': '{}?equipment={}'.format(reverse('theoretical-max-create'), self.object.pk),
|
||||
'category': 'success',
|
||||
'display': 'Ajouter un max théorique'
|
||||
}
|
||||
])
|
||||
"url": "{}?equipment={}".format(
|
||||
reverse("theoretical-max-create"), self.object.pk
|
||||
),
|
||||
"category": "success",
|
||||
"display": "Ajouter un max théorique",
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
if self.request.user.is_staff:
|
||||
lst.append({
|
||||
'url': reverse('admin:gym_equipment_change', args=(self.object.pk,)),
|
||||
'category': 'warning',
|
||||
'display': 'Éditer la machine'
|
||||
})
|
||||
lst.append(
|
||||
{
|
||||
"url": reverse(
|
||||
"admin:gym_equipment_change", args=(self.object.pk,)
|
||||
),
|
||||
"category": "warning",
|
||||
"display": "Éditer la machine",
|
||||
}
|
||||
)
|
||||
|
||||
return lst
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
session_pk = self.request.session.get('session_pk')
|
||||
session_pk = self.request.session.get("session_pk")
|
||||
if session_pk:
|
||||
self.session = Session.objects.get(pk=session_pk)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
@ -133,36 +158,38 @@ class EquipmentDetailView(LoginRequiredMixin, QuickActionsMixin, generic.DetailV
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
if self.session:
|
||||
context['session'] = self.session.pk
|
||||
context['rounds'] = Round.objects.filter(session=self.session, equipment=self.get_object())
|
||||
context["session"] = self.session.pk
|
||||
context["rounds"] = Round.objects.filter(
|
||||
session=self.session, equipment=self.get_object()
|
||||
)
|
||||
return context
|
||||
|
||||
|
||||
class EquipmentCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||
model = Equipment
|
||||
fields = ['room', 'name', 'default_work_form', 'unit', 'default_repetition_number']
|
||||
template_name = 'gym/equipment_edit.html'
|
||||
fields = ["room", "name", "default_work_form", "unit", "default_repetition_number"]
|
||||
template_name = "gym/equipment_edit.html"
|
||||
room = None
|
||||
|
||||
def get_quick_actions(self):
|
||||
return [
|
||||
{
|
||||
'url': reverse('room-detail', args=(self.room.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la salle'
|
||||
},
|
||||
"url": reverse("room-detail", args=(self.room.pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la salle",
|
||||
}
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['room'] = self.room
|
||||
context["room"] = self.room
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('equipment-detail', kwargs={'pk': self.object.pk})
|
||||
return reverse("equipment-detail", kwargs={"pk": self.object.pk})
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
default_room_id = self.request.GET.get('room')
|
||||
default_room_id = self.request.GET.get("room")
|
||||
if default_room_id:
|
||||
self.room = get_object_or_404(Room, pk=default_room_id)
|
||||
|
||||
|
@ -170,34 +197,34 @@ class EquipmentCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateV
|
|||
|
||||
def get_initial(self):
|
||||
initial = super().get_initial()
|
||||
initial['room'] = self.room
|
||||
initial["room"] = self.room
|
||||
|
||||
return initial
|
||||
|
||||
|
||||
class SettingCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||
model = Setting
|
||||
fields = ['equipment', 'name', 'value']
|
||||
template_name = 'gym/setting_edit.html'
|
||||
fields = ["equipment", "name", "value"]
|
||||
template_name = "gym/setting_edit.html"
|
||||
equipment = None
|
||||
|
||||
def get_quick_actions(self):
|
||||
return [
|
||||
{
|
||||
'url': reverse('equipment-detail', args=(self.equipment.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la machine'
|
||||
},
|
||||
"url": reverse("equipment-detail", args=(self.equipment.pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la machine",
|
||||
}
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['title'] = 'Ajouter'
|
||||
context['equipment'] = self.equipment
|
||||
context["title"] = "Ajouter"
|
||||
context["equipment"] = self.equipment
|
||||
return context
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
default_equipment_id = self.request.GET.get('equipment')
|
||||
default_equipment_id = self.request.GET.get("equipment")
|
||||
if default_equipment_id:
|
||||
self.equipment = get_object_or_404(Equipment, pk=default_equipment_id)
|
||||
|
||||
|
@ -205,81 +232,84 @@ class SettingCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateVie
|
|||
|
||||
def get_initial(self):
|
||||
initial = super().get_initial()
|
||||
initial['equipment'] = self.equipment
|
||||
initial["equipment"] = self.equipment
|
||||
|
||||
return initial
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||
return reverse("equipment-detail", kwargs={"pk": self.object.equipment.pk})
|
||||
|
||||
|
||||
class SettingUpdateView(LoginRequiredMixin, QuickActionsMixin, generic.UpdateView):
|
||||
model = Setting
|
||||
fields = ['equipment', 'name', 'value']
|
||||
template_name = 'gym/setting_edit.html'
|
||||
fields = ["equipment", "name", "value"]
|
||||
template_name = "gym/setting_edit.html"
|
||||
|
||||
def get_quick_actions(self):
|
||||
return [
|
||||
{
|
||||
'url': reverse('equipment-detail', args=(self.object.equipment.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la machine'
|
||||
},
|
||||
"url": reverse("equipment-detail", args=(self.object.equipment.pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la machine",
|
||||
}
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['edit'] = True
|
||||
context['title'] = 'Modifier'
|
||||
context['equipment'] = self.object.equipment
|
||||
context["edit"] = True
|
||||
context["title"] = "Modifier"
|
||||
context["equipment"] = self.object.equipment
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||
return reverse("equipment-detail", kwargs={"pk": self.object.equipment.pk})
|
||||
|
||||
|
||||
class SettingDeleteView(LoginRequiredMixin, generic.DeleteView):
|
||||
model = Setting
|
||||
template_name = 'gym/confirm_delete.html'
|
||||
template_name = "gym/confirm_delete.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['article'] = 'une'
|
||||
context['name'] = 'série'
|
||||
context['message'] = ('Êtes-vous sûr de vouloir supprimer le réglage '
|
||||
'<code>{}</code> pour la machine "{}" ?'.format(
|
||||
self.object,
|
||||
self.object.equipment,
|
||||
))
|
||||
context["article"] = "une"
|
||||
context["name"] = "série"
|
||||
context["message"] = (
|
||||
"Êtes-vous sûr de vouloir supprimer le réglage "
|
||||
'<code>{}</code> pour la machine "{}" ?'.format(
|
||||
self.object, self.object.equipment
|
||||
)
|
||||
)
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||
return reverse("equipment-detail", kwargs={"pk": self.object.equipment.pk})
|
||||
|
||||
|
||||
class TheoreticalMaxCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||
class TheoreticalMaxCreateView(
|
||||
LoginRequiredMixin, QuickActionsMixin, generic.CreateView
|
||||
):
|
||||
model = TheoreticalMax
|
||||
fields = ['equipment', 'date', 'value']
|
||||
template_name = 'gym/theoretical_max_edit.html'
|
||||
fields = ["equipment", "date", "value"]
|
||||
template_name = "gym/theoretical_max_edit.html"
|
||||
equipment = None
|
||||
|
||||
def get_quick_actions(self):
|
||||
return [
|
||||
{
|
||||
'url': reverse('equipment-detail', args=(self.equipment.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la machine'
|
||||
},
|
||||
"url": reverse("equipment-detail", args=(self.equipment.pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la machine",
|
||||
}
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['title'] = 'Ajouter'
|
||||
context['equipment'] = self.equipment
|
||||
context["title"] = "Ajouter"
|
||||
context["equipment"] = self.equipment
|
||||
return context
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
default_equipment_id = self.request.GET.get('equipment')
|
||||
default_equipment_id = self.request.GET.get("equipment")
|
||||
if default_equipment_id:
|
||||
self.equipment = get_object_or_404(Equipment, pk=default_equipment_id)
|
||||
|
||||
|
@ -287,41 +317,43 @@ class TheoreticalMaxCreateView(LoginRequiredMixin, QuickActionsMixin, generic.Cr
|
|||
|
||||
def get_initial(self):
|
||||
initial = super().get_initial()
|
||||
initial['equipment'] = self.equipment
|
||||
initial['date'] = datetime.date.today()
|
||||
initial["equipment"] = self.equipment
|
||||
initial["date"] = datetime.date.today()
|
||||
|
||||
return initial
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('theoretical-max-list', kwargs={'pk': self.object.equipment.pk})
|
||||
return reverse("theoretical-max-list", kwargs={"pk": self.object.equipment.pk})
|
||||
|
||||
|
||||
class TheoreticalMaxListView(LoginRequiredMixin, QuickActionsMixin, generic.ListView):
|
||||
model = TheoreticalMax
|
||||
template_name = 'gym/theoretical_max_list.html'
|
||||
context_object_name = 'maxs'
|
||||
template_name = "gym/theoretical_max_list.html"
|
||||
context_object_name = "maxs"
|
||||
equipment = None
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
pk = self.kwargs.pop('pk')
|
||||
pk = self.kwargs.pop("pk")
|
||||
self.equipment = get_object_or_404(Equipment, pk=pk)
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return TheoreticalMax.objects.filter(equipment=self.equipment).order_by('date')
|
||||
return TheoreticalMax.objects.filter(equipment=self.equipment).order_by("date")
|
||||
|
||||
def get_quick_actions(self):
|
||||
return [
|
||||
{
|
||||
'url': reverse('equipment-detail', args=(self.equipment.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la machine'
|
||||
"url": reverse("equipment-detail", args=(self.equipment.pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la machine",
|
||||
},
|
||||
{
|
||||
'url': '{}?equipment={}'.format(reverse('theoretical-max-create'), self.equipment.pk),
|
||||
'category': 'success',
|
||||
'display': 'Ajouter un max théorique'
|
||||
"url": "{}?equipment={}".format(
|
||||
reverse("theoretical-max-create"), self.equipment.pk
|
||||
),
|
||||
"category": "success",
|
||||
"display": "Ajouter un max théorique",
|
||||
},
|
||||
]
|
||||
|
||||
|
@ -332,69 +364,71 @@ class TheoreticalMaxListView(LoginRequiredMixin, QuickActionsMixin, generic.List
|
|||
go.Scatter(
|
||||
x=[max.date for max in self.get_queryset()],
|
||||
y=[max.value for max in self.get_queryset()],
|
||||
),
|
||||
)
|
||||
]
|
||||
layout = go.Layout(
|
||||
title="Évolution du max théorique",
|
||||
yaxis={"title": "Charge ({})".format(self.equipment.unit.name)},
|
||||
xaxis={"title": "Date"},
|
||||
)
|
||||
figure = {"data": data, "layout": layout, }
|
||||
graph = plotly.offline.plot(figure, auto_open=False, output_type='div')
|
||||
figure = {"data": data, "layout": layout}
|
||||
graph = plotly.offline.plot(figure, auto_open=False, output_type="div")
|
||||
|
||||
context['graph'] = graph
|
||||
context['equipment'] = self.equipment
|
||||
context["graph"] = graph
|
||||
context["equipment"] = self.equipment
|
||||
return context
|
||||
|
||||
|
||||
class SessionCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||
model = Session
|
||||
fields = ['room', 'start', 'default_theoretical_max_percentage']
|
||||
template_name = 'gym/session_edit.html'
|
||||
fields = ["room", "start", "default_theoretical_max_percentage"]
|
||||
template_name = "gym/session_edit.html"
|
||||
room = None
|
||||
|
||||
def get_quick_actions(self):
|
||||
room_pk = self.room.pk
|
||||
return [
|
||||
{
|
||||
'url': reverse('room-detail', args=(room_pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la salle'
|
||||
},
|
||||
"url": reverse("room-detail", args=(room_pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la salle",
|
||||
}
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['title'] = 'Démarrer'
|
||||
context['room'] = self.room
|
||||
context["title"] = "Démarrer"
|
||||
context["room"] = self.room
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('session-detail', kwargs={'pk': self.object.pk})
|
||||
return reverse("session-detail", kwargs={"pk": self.object.pk})
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.room = get_object_or_404(Room, pk=self.request.GET.get('room'))
|
||||
self.room = get_object_or_404(Room, pk=self.request.GET.get("room"))
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_initial(self):
|
||||
initial = super().get_initial()
|
||||
initial['room'] = self.room
|
||||
initial['start'] = datetime.datetime.now()
|
||||
initial["room"] = self.room
|
||||
initial["start"] = datetime.datetime.now()
|
||||
|
||||
return initial
|
||||
|
||||
|
||||
class SessionDetailView(LoginRequiredMixin, QuickActionsMixin, generic.DetailView):
|
||||
model = Session
|
||||
context_object_name = 'session'
|
||||
template_name = 'gym/session_detail.html'
|
||||
context_object_name = "session"
|
||||
template_name = "gym/session_detail.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
session = self.get_object()
|
||||
|
||||
context['used_equipments'] = {k: Round.objects.filter(equipment=k, session=session).count()
|
||||
for k in Equipment.objects.filter(rounds__session=self.get_object())}
|
||||
context["used_equipments"] = {
|
||||
k: Round.objects.filter(equipment=k, session=session).count()
|
||||
for k in Equipment.objects.filter(rounds__session=self.get_object())
|
||||
}
|
||||
|
||||
return context
|
||||
|
||||
|
@ -402,48 +436,57 @@ class SessionDetailView(LoginRequiredMixin, QuickActionsMixin, generic.DetailVie
|
|||
room_pk = self.get_object().room.pk
|
||||
return [
|
||||
{
|
||||
'url': reverse('room-detail', args=(room_pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la salle'
|
||||
"url": reverse("room-detail", args=(room_pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la salle",
|
||||
},
|
||||
{
|
||||
'url': "{}?room={}".format(reverse('equipment-create'), room_pk),
|
||||
'category': 'success',
|
||||
'display': 'Ajouter une machine'
|
||||
"url": "{}?room={}".format(reverse("equipment-create"), room_pk),
|
||||
"category": "success",
|
||||
"display": "Ajouter une machine",
|
||||
},
|
||||
]
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
request.session['session_pk'] = self.get_object().pk
|
||||
request.session["session_pk"] = self.get_object().pk
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class RoundCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||
model = Round
|
||||
fields = ['equipment', 'session', 'theoretical_max_percentage', 'chosen_weight',
|
||||
'repetition_number', 'work_form', 'notes']
|
||||
template_name = 'gym/round_edit.html'
|
||||
fields = [
|
||||
"equipment",
|
||||
"session",
|
||||
"theoretical_max_percentage",
|
||||
"chosen_weight",
|
||||
"repetition_number",
|
||||
"work_form",
|
||||
"notes",
|
||||
]
|
||||
template_name = "gym/round_edit.html"
|
||||
equipment = None
|
||||
session = None
|
||||
|
||||
def get_quick_actions(self):
|
||||
return [
|
||||
{
|
||||
'url': reverse('equipment-detail', args=(self.equipment.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la machine'
|
||||
},
|
||||
"url": reverse("equipment-detail", args=(self.equipment.pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la machine",
|
||||
}
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['title'] = 'Commencer'
|
||||
context['equipment'] = self.equipment
|
||||
context["title"] = "Commencer"
|
||||
context["equipment"] = self.equipment
|
||||
return context
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.equipment = get_object_or_404(Equipment, pk=self.request.GET.get('equipment'))
|
||||
session_pk = self.request.session.get('session_pk')
|
||||
self.equipment = get_object_or_404(
|
||||
Equipment, pk=self.request.GET.get("equipment")
|
||||
)
|
||||
session_pk = self.request.session.get("session_pk")
|
||||
if session_pk:
|
||||
self.session = Session.objects.get(pk=session_pk)
|
||||
|
||||
|
@ -452,73 +495,88 @@ class RoundCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView)
|
|||
def get_initial(self):
|
||||
theoretical_max_percentage = self.session.default_theoretical_max_percentage
|
||||
initial = super().get_initial()
|
||||
initial['equipment'] = self.equipment
|
||||
initial['session'] = self.session
|
||||
last_round = self.equipment.rounds.filter(session=self.session).last() # type: Round
|
||||
initial['theoretical_max_percentage'] = theoretical_max_percentage
|
||||
initial["equipment"] = self.equipment
|
||||
initial["session"] = self.session
|
||||
last_round = self.equipment.rounds.filter(
|
||||
session=self.session
|
||||
).last() # type: Round
|
||||
initial["theoretical_max_percentage"] = theoretical_max_percentage
|
||||
|
||||
if last_round:
|
||||
initial['repetition_number'] = last_round.repetition_number
|
||||
initial['work_form'] = last_round.work_form
|
||||
initial['chosen_weight'] = last_round.chosen_weight
|
||||
initial["repetition_number"] = last_round.repetition_number
|
||||
initial["work_form"] = last_round.work_form
|
||||
initial["chosen_weight"] = last_round.chosen_weight
|
||||
else:
|
||||
initial['repetition_number'] = self.equipment.default_repetition_number or 12
|
||||
initial['work_form'] = self.equipment.default_work_form
|
||||
initial["repetition_number"] = (
|
||||
self.equipment.default_repetition_number or 12
|
||||
)
|
||||
initial["work_form"] = self.equipment.default_work_form
|
||||
proposed_weight = 0
|
||||
theoretical_max = self.equipment.last_theoretical_max
|
||||
if theoretical_max:
|
||||
proposed_weight = theoretical_max.value * theoretical_max_percentage / 100
|
||||
initial['chosen_weight'] = proposed_weight
|
||||
proposed_weight = (
|
||||
theoretical_max.value * theoretical_max_percentage / 100
|
||||
)
|
||||
initial["chosen_weight"] = proposed_weight
|
||||
|
||||
return initial
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||
return reverse("equipment-detail", kwargs={"pk": self.object.equipment.pk})
|
||||
|
||||
|
||||
class RoundUpdateView(LoginRequiredMixin, QuickActionsMixin, generic.UpdateView):
|
||||
model = Round
|
||||
fields = ['equipment', 'session', 'theoretical_max_percentage', 'chosen_weight',
|
||||
'repetition_number', 'work_form', 'notes']
|
||||
template_name = 'gym/round_edit.html'
|
||||
fields = [
|
||||
"equipment",
|
||||
"session",
|
||||
"theoretical_max_percentage",
|
||||
"chosen_weight",
|
||||
"repetition_number",
|
||||
"work_form",
|
||||
"notes",
|
||||
]
|
||||
template_name = "gym/round_edit.html"
|
||||
|
||||
def get_quick_actions(self):
|
||||
return [
|
||||
{
|
||||
'url': reverse('equipment-detail', args=(self.object.equipment.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la machine'
|
||||
},
|
||||
"url": reverse("equipment-detail", args=(self.object.equipment.pk,)),
|
||||
"category": "secondary",
|
||||
"display": "Retourner à la machine",
|
||||
}
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['edit'] = True
|
||||
context['title'] = 'Modifier'
|
||||
context['equipment'] = self.object.equipment
|
||||
context["edit"] = True
|
||||
context["title"] = "Modifier"
|
||||
context["equipment"] = self.object.equipment
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||
return reverse("equipment-detail", kwargs={"pk": self.object.equipment.pk})
|
||||
|
||||
|
||||
class RoundDeleteView(LoginRequiredMixin, generic.DeleteView):
|
||||
model = Round
|
||||
template_name = 'gym/confirm_delete.html'
|
||||
template_name = "gym/confirm_delete.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['article'] = 'une'
|
||||
context['name'] = 'série'
|
||||
context['message'] = ('Êtes-vous sûr de vouloir supprimer '
|
||||
'la série <code>{}, {}x{}{}</code> pour la séance "{}" ?'.format(
|
||||
self.object.equipment,
|
||||
self.object.repetition_number,
|
||||
self.object.chosen_weight,
|
||||
self.object.equipment.unit,
|
||||
self.object.session
|
||||
))
|
||||
context["article"] = "une"
|
||||
context["name"] = "série"
|
||||
context["message"] = (
|
||||
"Êtes-vous sûr de vouloir supprimer "
|
||||
'la série <code>{}, {}x{}{}</code> pour la séance "{}" ?'.format(
|
||||
self.object.equipment,
|
||||
self.object.repetition_number,
|
||||
self.object.chosen_weight,
|
||||
self.object.equipment.unit,
|
||||
self.object.session,
|
||||
)
|
||||
)
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||
return reverse("equipment-detail", kwargs={"pk": self.object.equipment.pk})
|
||||
|
|
|
@ -5,11 +5,11 @@ import requests
|
|||
|
||||
|
||||
def main():
|
||||
port = os.getenv('PORT', 8000)
|
||||
res = requests.get(f'http://127.0.0.1:{port}/')
|
||||
port = os.getenv("PORT", 8000)
|
||||
res = requests.get(f"http://127.0.0.1:{port}/")
|
||||
if res.status_code >= 400:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -21,79 +21,80 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = os.getenv('SECRET_KEY', 'x*8q7sd14&a%cu95$h@jl&&#bb&j(j*-6h5!3atz*v%!zo3hd4')
|
||||
SECRET_KEY = os.getenv(
|
||||
"SECRET_KEY", "x*8q7sd14&a%cu95$h@jl&&#bb&j(j*-6h5!3atz*v%!zo3hd4"
|
||||
)
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = os.getenv('DJANGO_ENV', 'prod') == 'dev'
|
||||
DEBUG = os.getenv("DJANGO_ENV", "prod") == "dev"
|
||||
|
||||
ALLOWED_HOSTS = ['workout.augendre.info', 'web', 'workout', '127.0.0.1']
|
||||
ALLOWED_HOSTS = ["workout.augendre.info", "web", "workout", "127.0.0.1"]
|
||||
if DEBUG:
|
||||
ALLOWED_HOSTS.extend([
|
||||
'localhost',
|
||||
os.getenv('CURRENT_IP', '192.168.1.27')
|
||||
])
|
||||
host = os.getenv('HOST', None)
|
||||
ALLOWED_HOSTS.extend(["localhost", os.getenv("CURRENT_IP", "192.168.1.27")])
|
||||
host = os.getenv("HOST", None)
|
||||
if host:
|
||||
ALLOWED_HOSTS.append(host)
|
||||
|
||||
ADMINS = [('Gabriel', os.getenv('ADMIN_EMAIL')), ]
|
||||
SERVER_EMAIL = os.getenv('SERVER_EMAIL')
|
||||
EMAIL_SUBJECT_PREFIX = '[Workout] '
|
||||
ADMINS = [("Gabriel", os.getenv("ADMIN_EMAIL"))]
|
||||
SERVER_EMAIL = os.getenv("SERVER_EMAIL")
|
||||
EMAIL_SUBJECT_PREFIX = "[Workout] "
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'whitenoise.runserver_nostatic',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize',
|
||||
'gym',
|
||||
'bootstrap4',
|
||||
"whitenoise.runserver_nostatic",
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.humanize",
|
||||
"gym",
|
||||
"bootstrap4",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'django.middleware.http.ConditionalGetMiddleware',
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"django.middleware.http.ConditionalGetMiddleware",
|
||||
]
|
||||
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||
|
||||
ROOT_URLCONF = 'workout.urls'
|
||||
ROOT_URLCONF = "workout.urls"
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [],
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
"django.template.context_processors.debug",
|
||||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
]
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'workout.wsgi.application'
|
||||
WSGI_APPLICATION = "workout.wsgi.application"
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': dj_database_url.config(default='sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3'), conn_max_age=600)
|
||||
"default": dj_database_url.config(
|
||||
default="sqlite:///" + os.path.join(BASE_DIR, "db.sqlite3"), conn_max_age=600
|
||||
)
|
||||
}
|
||||
|
||||
# Password validation
|
||||
|
@ -101,25 +102,19 @@ DATABASES = {
|
|||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
|
||||
},
|
||||
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
|
||||
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
|
||||
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
|
||||
]
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.0/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'fr-fr'
|
||||
LANGUAGE_CODE = "fr-fr"
|
||||
|
||||
TIME_ZONE = 'Europe/Paris'
|
||||
TIME_ZONE = "Europe/Paris"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
|
@ -130,12 +125,11 @@ USE_TZ = True
|
|||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.0/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
||||
STATIC_URL = "/static/"
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
||||
|
||||
LOGIN_REDIRECT_URL = 'rooms-list'
|
||||
|
||||
EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
|
||||
MAILGUN_ACCESS_KEY = os.getenv('MAILGUN_ACCESS_KEY', '')
|
||||
MAILGUN_SERVER_NAME = os.getenv('MAILGUN_SERVER_NAME', '')
|
||||
LOGIN_REDIRECT_URL = "rooms-list"
|
||||
|
||||
EMAIL_BACKEND = "django_mailgun.MailgunBackend"
|
||||
MAILGUN_ACCESS_KEY = os.getenv("MAILGUN_ACCESS_KEY", "")
|
||||
MAILGUN_SERVER_NAME = os.getenv("MAILGUN_SERVER_NAME", "")
|
||||
|
|
|
@ -18,7 +18,7 @@ from django.contrib import admin
|
|||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('accounts/', include('django.contrib.auth.urls')),
|
||||
url(r'', include('gym.urls')),
|
||||
path("admin/", admin.site.urls),
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
url(r"", include("gym.urls")),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue