From b7ae411f96de9c8cb1e71e1965eacc7e023cf27f Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 6 Aug 2020 12:15:23 +0200 Subject: [PATCH] :sparkles: Export activities in the Crans Wiki --- .env_example | 2 ++ README.md | 2 ++ apps/activity/models.py | 23 +++++++++++++++++++++++ note.cron | 3 +-- uwsgi_note.ini | 6 ++++-- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.env_example b/.env_example index 91db0e31..7e90f965 100644 --- a/.env_example +++ b/.env_example @@ -16,3 +16,5 @@ EMAIL_HOST=smtp.localhost EMAIL_PORT=465 EMAIL_USER=notekfet@localhost EMAIL_PASSWORD=CHANGE_ME +WIKI_USER=NoteKfet2020 +WIKI_PASSWORD= \ No newline at end of file diff --git a/README.md b/README.md index c04c7321..e5775b29 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,8 @@ On supposera pour la suite que vous utilisez Debian/Ubuntu sur un serveur tout n EMAIL_PORT=465 EMAIL_USER=notekfet@localhost EMAIL_PASSWORD=CHANGE_ME + WIKI_USER=NoteKfet2020 + WIKI_PASSWORD=CHANGE_ME Ensuite on (re)bascule dans l'environement virtuel et on lance les migrations diff --git a/apps/activity/models.py b/apps/activity/models.py index 45942cc5..93942720 100644 --- a/apps/activity/models.py +++ b/apps/activity/models.py @@ -1,8 +1,11 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later from datetime import timedelta, datetime +from threading import Thread +from django.conf import settings from django.contrib.auth.models import User +from django.core.management import call_command from django.db import models from django.db.models import Q from django.utils import timezone @@ -54,6 +57,13 @@ class Activity(models.Model): verbose_name=_('description'), ) + location = models.CharField( + verbose_name=_('location'), + max_length=255, + blank=True, + default="", + ) + activity_type = models.ForeignKey( ActivityType, on_delete=models.PROTECT, @@ -99,6 +109,19 @@ class Activity(models.Model): verbose_name=_('open'), ) + def save(self, *args, **kwargs): + """ + Update the activity wiki page each time the activity is updated (validation, change description, ...) + """ + ret = super().save(*args, **kwargs) + if self.pk and "scripts" in settings.INSTALLED_APPS: + def refresh_activities(): + from scripts.management.commands.refresh_activities import Command as RefreshActivitiesCommand + RefreshActivitiesCommand.refresh_human_readable_wiki_page("Modification de l'activité " + self.name) + RefreshActivitiesCommand.refresh_raw_wiki_page("Modification de l'activité " + self.name) + Thread(daemon=True, target=refresh_activities).start() + return ret + def __str__(self): return self.name diff --git a/note.cron b/note.cron index 9683b391..f3e18d90 100644 --- a/note.cron +++ b/note.cron @@ -10,9 +10,8 @@ 00 2 * * * root cd /var/www/note_kfet && apps/scripts/shell/backup_db # Vérifier la cohérence de la base et mailer en cas de problème 00 4 * * * root cd /var/www/note_kfet && env/bin/python manage.py check_consistency --sum-all --check-all --mail -# TODO # Mettre à jour le wiki (modification sans (dé)validation, activités passées) -#30 5 * * * root /home/note/note-kfet-2015-serveur/serveur/Wiki.py --human --raw +#30 5 * * * root cd /var/www/note_kfet && env/bin/python manage.py refresh_activities --raw --comment refresh # Spammer les gens en négatif 00 5 * * 2 root cd /var/www/note_kfet && env/bin/python manage.py send_mail_to_negative_balances --spam # Envoyer le rapport mensuel aux trésoriers et respos info diff --git a/uwsgi_note.ini b/uwsgi_note.ini index 83c52e50..34a8ecce 100644 --- a/uwsgi_note.ini +++ b/uwsgi_note.ini @@ -22,5 +22,7 @@ socket = /var/www/note_kfet/note_kfet.sock chmod-socket = 664 # clear environment on exit vacuum = true -#Touch reload -touch-reload = /var/www/note_kfet/note_kfet/settings/__init__.py +# Touch reload +touch-reload = /var/www/note_kfet/note_kfet/settings/__init__.py +# Enable threads +enable-threads = true \ No newline at end of file