Export activities in the Crans Wiki

This commit is contained in:
Yohann D'ANELLO 2020-08-06 12:15:23 +02:00
parent 315af75c45
commit b7ae411f96
5 changed files with 32 additions and 4 deletions

View File

@ -16,3 +16,5 @@ EMAIL_HOST=smtp.localhost
EMAIL_PORT=465
EMAIL_USER=notekfet@localhost
EMAIL_PASSWORD=CHANGE_ME
WIKI_USER=NoteKfet2020
WIKI_PASSWORD=

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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