mirror of
https://gitlab.crans.org/bde/nk20-scripts
synced 2025-06-15 05:27:28 +02:00
Compare commits
No commits in common. "e5799c29f973947872903fc2505f9c57c8476b7e" and "694831a314aab57489f46c5f6fa24162b0e93b69" have entirely different histories.
e5799c29f9
...
694831a314
@ -1,41 +0,0 @@
|
|||||||
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
from datetime import date, timedelta
|
|
||||||
|
|
||||||
from django.core.mail import send_mail
|
|
||||||
from django.core.management import BaseCommand
|
|
||||||
from django.template.loader import render_to_string
|
|
||||||
from django.utils.translation import activate
|
|
||||||
from food.models import Food
|
|
||||||
from member.models import Club
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
|
||||||
def add_arguments(self, parser):
|
|
||||||
parser.add_argument("--report", "-r", action='store_true', help="Report the list of food to GCKs")
|
|
||||||
parser.add_argument("--club", "-c", action='store_true', help="Report the list of food to club")
|
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
|
||||||
activate('fr')
|
|
||||||
|
|
||||||
foods = Food.objects.filter(end_of_life='').order_by('expiry_date').distinct().all()
|
|
||||||
|
|
||||||
if options["report"]:
|
|
||||||
plain_text = render_to_string("scripts/food_report.txt", context=dict(foods=foods))
|
|
||||||
html = render_to_string("scripts/food_report.html", context=dict(foods=foods))
|
|
||||||
send_mail("[Note Kfet] Liste de la nourriture à la Kfet", plain_text, "Note Kfet 2020 <notekfet2020@crans.org>",
|
|
||||||
recipient_list=["respo-info.bde@lists.crans.org", "gck.bde@lists.crans.org"],
|
|
||||||
html_message=html)
|
|
||||||
|
|
||||||
if options["club"]:
|
|
||||||
for club in Club.objects.all():
|
|
||||||
if Food.objects.filter(end_of_life='', owner=club).count() > 0:
|
|
||||||
plain_text = render_to_string("scripts/food_report.txt",
|
|
||||||
context=dict(foods=foods.filter(owner=club)))
|
|
||||||
html = render_to_string("scripts/food_report.html",
|
|
||||||
context=dict(foods=foods.filter(owner=club)))
|
|
||||||
send_mail("[Note Kfet] Liste de la nourriture de votre club", plain_text, "Note Kfet 2020 <notekfet2020@crans.org>",
|
|
||||||
recipient_list=[club.email],
|
|
||||||
html_message=html)
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
{% now "Y-m-d" as today %}
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>[Note Kfet] Liste de la bouffe</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Club</th>
|
|
||||||
<th>Nom</th>
|
|
||||||
<th>Date de péremption</th>
|
|
||||||
<th>DLC/DDM</th>
|
|
||||||
<th>Consigne pour les GCKs</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for food in foods %}
|
|
||||||
{% if today > food.expiry_date|date:"Y-m-d" %}
|
|
||||||
{% if food.date_type and food.date_type == "DLC" %}
|
|
||||||
<tr bgcolor="red">
|
|
||||||
{% else %}
|
|
||||||
<tr bgcolor="yellow">
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
|
||||||
<tr>
|
|
||||||
{% endif %}
|
|
||||||
<td>{{ food.owner.name }}</td>
|
|
||||||
<td>{{ food.name }}</td>
|
|
||||||
<td>{{ food.expiry_date }}</td>
|
|
||||||
{% if food.date_type %}
|
|
||||||
<td>{{ food.date_type }}</td>
|
|
||||||
{% else %}
|
|
||||||
<td>--</td>
|
|
||||||
{% endif %}
|
|
||||||
<td>{{ food.order }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
--
|
|
||||||
<p>
|
|
||||||
Les GCKs du BDE<br>
|
|
||||||
{% trans "Mail generated by the Note Kfet on the" %} {% now "j F Y à H:i:s" %}
|
|
||||||
</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,14 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
|
|
||||||
Propriétaire | Nom | Date de péremption | DLC/DDM | Consigne pour les GCKs |
|
|
||||||
------------------+---------------------+----------------------+---------+---------------------------------------
|
|
||||||
{% for food in foods %}
|
|
||||||
|
|
||||||
{{ food.owner.name }} | {{ food.name }} | {{ food.expiry_date }} | {% if food.date_type %}{{ food.date_type }}{% else %} -- {% endif %} | {{ food.order }}
|
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
--
|
|
||||||
Les GCKs du BDE
|
|
||||||
|
|
||||||
{% trans "Mail generated by the Note Kfet on the" %} {% now "j F Y à H:i:s" %}
|
|
Loading…
x
Reference in New Issue
Block a user