1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2025-04-27 17:32:39 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Yohann D'ANELLO
4de83344a7 Export games 2020-10-26 15:13:19 +01:00
Yohann D'ANELLO
a64d600645 Index page 2020-10-26 14:44:25 +01:00
Yohann D'ANELLO
22408b16c7 Capitalize title 2020-10-26 14:38:03 +01:00

View File

@ -2,7 +2,7 @@ from argparse import FileType
from sys import stdin
from django.core.management import BaseCommand
from media.models import BD, CD, Manga, Revue, Roman, Vinyle
from media.models import BD, CD, Manga, Revue, Roman, Vinyle, Jeu
class Command(BaseCommand):
@ -16,10 +16,14 @@ class Command(BaseCommand):
def handle(self, *args, **options):
directory = options["directory"]
with open(directory + "/docs/index.md", "w") as f:
f.write("# Media de la Mediatek\n\n\n")
f.write("Ce site répertorie l'intégralité des media présents à la Mediatek de l'ENS Paris-Saclay.\n")
for model_class, file_name in [(BD, "bd.md"), (Manga, "mangas.md"), (Roman, "romans.md"),
(CD, "cd.md"), (Vinyle, "vinyle.md")]:
(CD, "cd.md"), (Vinyle, "vinyles.md")]:
with open(directory + "/docs/" + file_name, "w") as f:
f.write("# " + str(model_class._meta.verbose_name) + "\n\n\n")
f.write("# " + str(model_class._meta.verbose_name_plural).capitalize() + "\n\n\n")
titles = list(set(obj["title"] for obj in model_class.objects.values("title").distinct().all()))
titles.sort()
@ -65,3 +69,17 @@ class Command(BaseCommand):
if medium.day:
f.write(f"Jour : {medium.day}\n\n")
f.write("\n\n\n")
# Traitement différent pour les jeux
with open(directory + "/docs/jeux.md", "w") as f:
f.write("# Jeux\n\n\n")
for game in Jeu.objects.order_by("name").all():
f.write(f"## {game.name}\n\n\n")
f.write(f"Durée : {game.duree}\n\n")
f.write(f"Nombre de joueurs : {game.nombre_joueurs_min} - {game.nombre_joueurs_max}\n\n")
if game.proprietaire.username != "Med":
f.write(f"Propriétaire : {game.proprietaire.username}\n\n")
if game.comment:
f.write(f"Commentaire : {game.comment}\n\n")
f.write("\n\n\n")