forked from DGNum/gestioCOF
Compare commits
3 commits
master
...
kerl/facto
Author | SHA1 | Date | |
---|---|---|---|
|
4ecff9f909 | ||
|
dc79de4031 | ||
|
4d96d2c645 |
479 changed files with 3737 additions and 12644 deletions
1
.envrc
1
.envrc
|
@ -1 +0,0 @@
|
|||
use nix
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -5,7 +5,6 @@ cof/settings.py
|
|||
settings.py
|
||||
*~
|
||||
venv/
|
||||
.venv/
|
||||
.vagrant
|
||||
/src
|
||||
media/
|
||||
|
@ -19,5 +18,4 @@ media/
|
|||
.cache
|
||||
|
||||
# VSCode
|
||||
.vscode/
|
||||
.direnv
|
||||
.vscode/
|
|
@ -17,15 +17,12 @@ variables:
|
|||
# psql password authentication
|
||||
PGPASSWORD: $POSTGRES_PASSWORD
|
||||
|
||||
# apps to check migrations for
|
||||
MIGRATION_APPS: "bda bds cofcms clubs events gestioncof kfet kfetauth kfetcms open petitscours shared"
|
||||
|
||||
.test_template:
|
||||
before_script:
|
||||
- mkdir -p vendor/{pip,apt}
|
||||
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client libldap2-dev libsasl2-dev
|
||||
- sed -E 's/^REDIS_HOST.*/REDIS_HOST = "redis"/' gestioasso/settings/secret_example.py > gestioasso/settings/secret.py
|
||||
- sed -i.bak -E 's;^REDIS_PASSWD = .*$;REDIS_PASSWD = "";' gestioasso/settings/secret.py
|
||||
- sed -E 's/^REDIS_HOST.*/REDIS_HOST = "redis"/' cof/settings/secret_example.py > cof/settings/secret.py
|
||||
- sed -i.bak -E 's;^REDIS_PASSWD = .*$;REDIS_PASSWD = "";' cof/settings/secret.py
|
||||
# Remove the old test database if it has not been done yet
|
||||
- psql --username=$POSTGRES_USER --host=$DBHOST -c "DROP DATABASE IF EXISTS test_$POSTGRES_DB"
|
||||
- pip install --upgrade -r requirements-prod.txt coverage tblib
|
||||
|
@ -43,27 +40,19 @@ variables:
|
|||
# Keep this disabled for now, as it may kill GitLab...
|
||||
# coverage: '/TOTAL.*\s(\d+\.\d+)\%$/'
|
||||
|
||||
kfettest:
|
||||
stage: test
|
||||
extends: .test_template
|
||||
variables:
|
||||
DJANGO_SETTINGS_MODULE: "gestioasso.settings.cof_prod"
|
||||
script:
|
||||
- coverage run manage.py test kfet
|
||||
|
||||
coftest:
|
||||
stage: test
|
||||
extends: .test_template
|
||||
variables:
|
||||
DJANGO_SETTINGS_MODULE: "gestioasso.settings.cof_prod"
|
||||
DJANGO_SETTINGS_MODULE: "cof.settings.cof_prod"
|
||||
script:
|
||||
- coverage run manage.py test gestioncof bda petitscours shared --parallel
|
||||
- coverage run manage.py test gestioncof bda kfet petitscours shared --parallel
|
||||
|
||||
bdstest:
|
||||
stage: test
|
||||
extends: .test_template
|
||||
variables:
|
||||
DJANGO_SETTINGS_MODULE: "gestioasso.settings.bds_prod"
|
||||
DJANGO_SETTINGS_MODULE: "cof.settings.bds_prod"
|
||||
script:
|
||||
- coverage run manage.py test bds clubs events --parallel
|
||||
|
||||
|
@ -74,9 +63,9 @@ linters:
|
|||
- pip install --upgrade black isort flake8
|
||||
script:
|
||||
- black --check .
|
||||
- isort --check --diff .
|
||||
- isort --recursive --check-only --diff bda bds clubs cof events gestioncof kfet petitscours provisioning shared
|
||||
# Print errors only
|
||||
- flake8 --exit-zero bda bds clubs gestioasso events gestioncof kfet petitscours provisioning shared
|
||||
- flake8 --exit-zero bda bds clubs cof events gestioncof kfet petitscours provisioning shared
|
||||
cache:
|
||||
key: linters
|
||||
paths:
|
||||
|
@ -86,14 +75,14 @@ linters:
|
|||
migration_checks:
|
||||
stage: test
|
||||
variables:
|
||||
DJANGO_SETTINGS_MODULE: "gestioasso.settings.local"
|
||||
DJANGO_SETTINGS_MODULE: "cof.settings.local"
|
||||
before_script:
|
||||
- mkdir -p vendor/{pip,apt}
|
||||
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client libldap2-dev libsasl2-dev
|
||||
- cp gestioasso/settings/secret_example.py gestioasso/settings/secret.py
|
||||
- cp cof/settings/secret_example.py cof/settings/secret.py
|
||||
- pip install --upgrade -r requirements-devel.txt
|
||||
- python --version
|
||||
script: python manage.py makemigrations --dry-run --check $MIGRATION_APPS
|
||||
script: python manage.py makemigrations --dry-run --check
|
||||
services:
|
||||
# this should not be necessary…
|
||||
- postgres:11.7
|
||||
|
|
|
@ -48,7 +48,7 @@ if type isort &>/dev/null; then
|
|||
ISORT_OUTPUT="/tmp/gc-isort-output.log"
|
||||
touch $ISORT_OUTPUT
|
||||
|
||||
if ! echo "$STAGED_PYTHON_FILES" | xargs -d'\n' isort --check &>$ISORT_OUTPUT; then
|
||||
if ! echo "$STAGED_PYTHON_FILES" | xargs -d'\n' isort --check-only &>$ISORT_OUTPUT; then
|
||||
echo "$STAGED_PYTHON_FILES" | xargs -d'\n' isort &>$ISORT_OUTPUT
|
||||
printf "Reformatted.\n"
|
||||
formatter_updated=1
|
||||
|
|
203
CHANGELOG.md
203
CHANGELOG.md
|
@ -16,210 +16,25 @@ Liste des changements notables dans GestioCOF depuis la version 0.1 (septembre
|
|||
- Vue d'inscription à un événement **ou** intégration propre dans la vue
|
||||
"inscription d'un nouveau membre"
|
||||
|
||||
### Nouveau module BDS
|
||||
|
||||
Uniquement un modèle BDSProfile pour le moment…
|
||||
|
||||
### Nouveau module de gestion des clubs
|
||||
|
||||
Uniquement un modèle simple de clubs avec des respos. Aucune gestion des
|
||||
adhérents ni des cotisations.
|
||||
|
||||
## TODO Prod
|
||||
|
||||
- Lancer `python manage.py update_translation_fields` après la migration
|
||||
- Mettre à jour les units systemd `daphne.service` et `worker.service`
|
||||
|
||||
- Créer un compte hCaptcha (https://www.hcaptcha.com/), au COF, et remplacer les secrets associés
|
||||
|
||||
## Version ??? - ??/??/????
|
||||
|
||||
## Version 0.15.1 - 15/06/2023
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- Rattrape les erreurs d'envoi de mail de négatif
|
||||
- Utilise l'adresse chefs pour les envois de négatifs
|
||||
|
||||
## Version 0.15 - 22/05/2023
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- Rajoute un formulaire de contact
|
||||
- Rajoute un formulaire de demande de soirée
|
||||
- Désactive les mails d'envoi de négatifs sur les comptes gelés
|
||||
|
||||
## Version 0.14 - 19/05/2023
|
||||
|
||||
- Répare les dépendances en spécifiant toutes les versions
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- Répare la gestion des changement d'heure via moment.js
|
||||
|
||||
## Version 0.13 - 19/02/2023
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- Rajoute la valeur des inventaires
|
||||
- Résout les problèmes de négatif ne disparaissant pas
|
||||
- Affiche son surnom s'il y en a un
|
||||
- Bugfixes
|
||||
|
||||
## Version 0.12.1 - 03/10/2022
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- Fixe un problème de rendu causé par l'agrandissement du menu
|
||||
|
||||
- Mise à jour vers Channels 3.x et Django 3.2
|
||||
|
||||
## Version 0.12 - 17/06/2022
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- Ajoute une exception à la limite d'historique pour les comptes `LIQ` et `#13`
|
||||
- Répare le problème des étiquettes LIQ/Comptes K-Fêt inversées dans les stats des articles K-Fêt
|
||||
|
||||
## Version 0.11 - 26/10/2021
|
||||
|
||||
### COF
|
||||
|
||||
- Répare un problème de rendu sur le wagtail du COF
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- Ajoute de mails de rappels pour les comptes en négatif
|
||||
- La recherche de comptes sur K-Psul remarche normalement
|
||||
- Le pointeur de la souris change de forme quand on survole un item d'autocomplétion
|
||||
- Modification du gel de compte:
|
||||
- on ne peut plus geler/dégeler son compte soi-même (il faut la permission "Gérer les permissions K-Fêt")
|
||||
- on ne peut rien compter sur un compte gelé (aucune override possible), et les K-Fêteux·ses dont le compte est gelé perdent tout accès à K-Psul
|
||||
- les comptes actuellement gelés (sur l'ancien système) sont dégelés automatiquement
|
||||
- Modification du fonctionnement des négatifs
|
||||
- impossible d'avoir des négatifs inférieurs à `kfet_config.overdraft_amount`
|
||||
- il n'y a plus de limite de temps sur les négatifs
|
||||
- supression des autorisations de négatif
|
||||
- il n'est plus possible de réinitialiser la durée d'un négatif en faisant puis en annulant une charge
|
||||
- La gestion des erreurs passe du client au serveur, ce qui permet d'avoir des messages plus explicites
|
||||
- La supression d'opérations anciennes est réparée
|
||||
|
||||
## Version 0.10 - 18/04/2021
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- On fait sauter la limite qui empêchait de vendre plus de 24 unités d'un item à
|
||||
la fois.
|
||||
- L'interface indique plus clairement quand on fait une erreur en modifiant un
|
||||
compte.
|
||||
- On supprime la fonction "décalage de balance".
|
||||
- L'accès à l'historique est maintenant limité à 7 jours pour raison de
|
||||
confidentialité. Les chefs/trez peuvent disposer d'une permission
|
||||
supplémentaire pour accéder à jusqu'à 30 jours en cas de problème de compta.
|
||||
L'accès à son historique personnel n'est pas limité. Les durées sont
|
||||
configurables dans `settings/cof_prod.py`.
|
||||
|
||||
### COF
|
||||
|
||||
- Le Captcha sur la page de demande de petits cours utilise maintenant hCaptcha
|
||||
au lieu de ReCaptcha, pour mieux respecter la vie privée des utilisateur·ices
|
||||
|
||||
## Version 0.9 - 06/02/2020
|
||||
|
||||
### COF / BdA
|
||||
|
||||
- Le COF peut remettre à zéro la liste de ses adhérents en août (sans passer par
|
||||
KDE).
|
||||
- La page d'accueil affiche la date de fermeture des tirages BdA.
|
||||
- On peut revendre une place dès qu'on l'a payée, plus besoin de payer toutes
|
||||
ses places pour pouvoir revendre.
|
||||
- On s'assure que l'email fourni lors d'une demande de petit cours est valide.
|
||||
|
||||
### BDS
|
||||
|
||||
- Le burô peut maintenant accorder ou révoquer le statut de membre du Burô
|
||||
en modifiant le profil d'un membre du BDS.
|
||||
- Le burô peut exporter la liste de ses membres avec email au format CSV depuis
|
||||
la page d'accueil.
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- On affiche les articles actuellement en vente en premier lors des inventaires
|
||||
et des commandes.
|
||||
- On peut supprimer un inventaire. Seuls les articles dont c'est le dernier
|
||||
inventaire sont affectés.
|
||||
|
||||
## Version 0.8 - 03/12/2020
|
||||
|
||||
### COF
|
||||
|
||||
- La page "Mes places" dans la section BdA indique quelles places sont sur
|
||||
listing.
|
||||
- ergonomie de l'interface admin du BdA : moins d'options inutiles lors de
|
||||
la sélection de participants.
|
||||
- les tirages sont maintenant archivables pour éviter d'avoir encore d'autres
|
||||
options inutiles.
|
||||
- l'autocomplétion dans l'admin BdA est réparée.
|
||||
- Les icones de la page de gestion des petits cours sont (à nouveau) réparées.
|
||||
- On a supprimé la possibilité de modifier les mails automatiques depuis
|
||||
l'interface admin car trop problématique. Faute de mieux, envoyer un mail à
|
||||
KDE pour modifier ces mails.
|
||||
- corrige un crash sporadique sur la page d'inscription au système de petits
|
||||
cours
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- (fix partiel) Empêche la K-Fêt de modifier des données COF (e.g. nom, prénom,
|
||||
username) lors de la création d'un nouveau compte.
|
||||
- Les statistiques de conso globales montrent deux courbes COF / non-COF au
|
||||
lieu de LIQ / sur compte.
|
||||
- Un bug empêchait de fermer manuellement la K-Fêt depuis un compte non
|
||||
privilégié en tapant un mot de passe. C'est corrigé.
|
||||
|
||||
## Version 0.7.2 - 08/09/2020
|
||||
|
||||
- Nouvelle page 404
|
||||
- Correction de bug en K-Fêt : le lien pour créer un nouveau compte exté apparaît
|
||||
à nouveau dans l'autocomplétion
|
||||
|
||||
## Version 0.7.1 - 05/09/2020
|
||||
|
||||
Petits ajustements sur le site du COF :
|
||||
|
||||
- Possibilité d'ajouter des champs d'infos supplémentaires en plus de l'email et
|
||||
de la page web dans les annuaires (clubs et partenaires).
|
||||
- Corrige un bug d'affichage des adresses emails de clubs
|
||||
|
||||
## Version 0.7 - 29/08/2020
|
||||
|
||||
### GestioBDS
|
||||
|
||||
- Ajout d'un bouton pour supprimer un compte
|
||||
- Le nombre d'adhérent⋅es est affiché sur la page d'accueil
|
||||
- le groupe BDS a les bonnes permissions
|
||||
|
||||
### Site du COF
|
||||
|
||||
- Captcha fonctionnel pour les mailing-listes
|
||||
|
||||
### K-Fêt
|
||||
|
||||
- L'autocomplétion pour la création de compte K-Fêt se lance à 3 caractères seulement,
|
||||
donc est plus rapide.
|
||||
|
||||
## Version 0.6 - 27/07/2020
|
||||
|
||||
Arrivée du BDS !
|
||||
GestioCOF et GestioBDS ont du code en commun mais tournent de façon séparée, les
|
||||
deux bases de données sont distinctes.
|
||||
|
||||
## Version 0.5 - 11/07/2020
|
||||
## Upcoming
|
||||
|
||||
### Problèmes corrigés
|
||||
|
||||
- La recherche d'utilisateurices (COF + K-Fêt) fonctionne de nouveau
|
||||
- Bug d'affichage quand on a beaucoup de clubs dans le cadre "Accès rapide" sur
|
||||
la page des clubs (nouveau site du COF)
|
||||
la page des clubs
|
||||
- Version mobile plus ergonimique sur le nouveau site du COF
|
||||
- Cliquer sur "visualiser" sur les pages de clubs dans wagtail ne provoque plus
|
||||
d'erreurs 500 (nouveau site du COF)
|
||||
- L'historique des ventes des articles K-Fêt fonctionne à nouveau
|
||||
d'erreurs 500.
|
||||
- L'historique des ventes des articles fonctionne à nouveau
|
||||
- Les montants en K-Fêt sont à nouveau affichés en UKF (et non en €).
|
||||
- Les boutons "afficher/cacher" des mails et noms des participant⋅e⋅s à un
|
||||
spectacle BdA fonctionnent à nouveau.
|
||||
|
@ -228,7 +43,7 @@ deux bases de données sont distinctes.
|
|||
|
||||
### Nouvelles fonctionnalités
|
||||
|
||||
- On n'affiche que 4 articles sur la pages "nouveautés" (nouveau site du COF)
|
||||
- On n'affiche que 4 articles sur la pages "nouveautés"
|
||||
- Plus de traductions sur le nouveau site du COF
|
||||
- Les transferts apparaissent maintenant dans l'historique K-Fêt et l'historique
|
||||
personnel.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# GestioCOF / GestioBDS
|
||||
# GestioCOF
|
||||
|
||||
[![pipeline status](https://git.eleves.ens.fr/cof-geek/gestioCOF/badges/master/pipeline.svg)](https://git.eleves.ens.fr/cof-geek/gestioCOF/commits/master)
|
||||
[![coverage report](https://git.eleves.ens.fr/cof-geek/gestioCOF/badges/master/coverage.svg)](https://git.eleves.ens.fr/cof-geek/gestioCOF/commits/master)
|
||||
|
@ -38,11 +38,11 @@ Vous pouvez maintenant installer les dépendances Python depuis le fichier
|
|||
pip install -U pip # parfois nécessaire la première fois
|
||||
pip install -r requirements-devel.txt
|
||||
|
||||
Pour terminer, copier le fichier `gestioasso/settings/secret_example.py` vers
|
||||
`gestioasso/settings/secret.py`. Sous Linux ou Mac, préférez plutôt un lien symbolique
|
||||
Pour terminer, copier le fichier `cof/settings/secret_example.py` vers
|
||||
`cof/settings/secret.py`. Sous Linux ou Mac, préférez plutôt un lien symbolique
|
||||
pour profiter de façon transparente des mises à jour du fichier:
|
||||
|
||||
ln -s secret_example.py gestioasso/settings/secret.py
|
||||
ln -s secret_example.py cof/settings/secret.py
|
||||
|
||||
Nous avons un git hook de pre-commit pour formatter et vérifier que votre code
|
||||
vérifie nos conventions. Pour bénéficier des mises à jour du hook, préférez
|
||||
|
|
42
Vagrantfile
vendored
42
Vagrantfile
vendored
|
@ -1,19 +1,47 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# Configuration de base pour GestioCOF.
|
||||
# Voir https://docs.vagrantup.com pour plus d'informations.
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure(2) do |config|
|
||||
# On se base sur Debian 10 (Buster) pour avoir le même environnement qu'en
|
||||
# production.
|
||||
config.vm.box = "debian/contrib-buster64"
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
config.vm.box = "ubuntu/xenial64"
|
||||
|
||||
# On associe le port 80 dans la machine virtuelle avec le port 8080 de notre
|
||||
# ordinateur, et le port 8000 avec le port 8000.
|
||||
config.vm.network :forwarded_port, guest: 80, host: 8080
|
||||
config.vm.network :forwarded_port, guest: 8000, host: 8000
|
||||
|
||||
# Le restes de la configuration (installation de paquets, etc) est géré un
|
||||
# script shell.
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
# vb.memory = "1024"
|
||||
# end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
# config.vm.provision "shell", inline: <<-SHELL
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y apache2
|
||||
# SHELL
|
||||
config.vm.provision :shell, path: "provisioning/bootstrap.sh"
|
||||
end
|
||||
|
|
83
bda/admin.py
83
bda/admin.py
|
@ -1,11 +1,10 @@
|
|||
from datetime import timedelta
|
||||
|
||||
from custommail.shortcuts import send_mass_custom_mail
|
||||
from dal.autocomplete import ModelSelect2
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.core.mail import send_mass_mail
|
||||
from django.db.models import Count, Q, Sum
|
||||
from django.template import loader
|
||||
from django.template.defaultfilters import pluralize
|
||||
from django.utils import timezone
|
||||
|
||||
|
@ -33,6 +32,20 @@ class ReadOnlyMixin(object):
|
|||
return readonly_fields + self.readonly_fields_update
|
||||
|
||||
|
||||
class ChoixSpectacleAdminForm(forms.ModelForm):
|
||||
class Meta:
|
||||
widgets = {
|
||||
"participant": ModelSelect2(url="bda-participant-autocomplete"),
|
||||
"spectacle": ModelSelect2(url="bda-spectacle-autocomplete"),
|
||||
}
|
||||
|
||||
|
||||
class ChoixSpectacleInline(admin.TabularInline):
|
||||
model = ChoixSpectacle
|
||||
form = ChoixSpectacleAdminForm
|
||||
sortable_field_name = "priority"
|
||||
|
||||
|
||||
class AttributionTabularAdminForm(forms.ModelForm):
|
||||
listing = None
|
||||
|
||||
|
@ -80,17 +93,14 @@ class WithoutListingAttributionInline(AttributionInline):
|
|||
class ParticipantAdminForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
queryset = Spectacle.objects.select_related("location")
|
||||
|
||||
if self.instance.pk is not None:
|
||||
queryset = queryset.filter(tirage=self.instance.tirage)
|
||||
|
||||
self.fields["choicesrevente"].queryset = queryset
|
||||
self.fields["choicesrevente"].queryset = Spectacle.objects.select_related(
|
||||
"location"
|
||||
)
|
||||
|
||||
|
||||
class ParticipantPaidFilter(admin.SimpleListFilter):
|
||||
"""
|
||||
Permet de filtrer les participants sur s'ils ont payé leurs places ou pas
|
||||
Permet de filtrer les participants sur s'ils ont payé leurs places ou pas
|
||||
"""
|
||||
|
||||
title = "A payé"
|
||||
|
@ -159,23 +169,19 @@ class ParticipantAdmin(ReadOnlyMixin, admin.ModelAdmin):
|
|||
form = ParticipantAdminForm
|
||||
|
||||
def send_attribs(self, request, queryset):
|
||||
emails = []
|
||||
datatuple = []
|
||||
for member in queryset.all():
|
||||
subject = "Résultats du tirage au sort"
|
||||
attribs = member.attributions.all()
|
||||
context = {"member": member.user}
|
||||
|
||||
template_name = ""
|
||||
shortname = ""
|
||||
if len(attribs) == 0:
|
||||
template_name = "bda/mails/attributions-decus.txt"
|
||||
shortname = "bda-attributions-decus"
|
||||
else:
|
||||
template_name = "bda/mails/attributions.txt"
|
||||
shortname = "bda-attributions"
|
||||
context["places"] = attribs
|
||||
|
||||
message = loader.render_to_string(template_name, context)
|
||||
emails.append((subject, message, "bda@ens.fr", [member.user.email]))
|
||||
|
||||
send_mass_mail(emails)
|
||||
print(context)
|
||||
datatuple.append((shortname, context, "bda@ens.fr", [member.user.email]))
|
||||
send_mass_custom_mail(datatuple)
|
||||
count = len(queryset.all())
|
||||
if count == 1:
|
||||
message_bit = "1 membre a"
|
||||
|
@ -191,6 +197,17 @@ class ParticipantAdmin(ReadOnlyMixin, admin.ModelAdmin):
|
|||
|
||||
|
||||
class AttributionAdminForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if "spectacle" in self.fields:
|
||||
self.fields["spectacle"].queryset = Spectacle.objects.select_related(
|
||||
"location"
|
||||
)
|
||||
if "participant" in self.fields:
|
||||
self.fields["participant"].queryset = Participant.objects.select_related(
|
||||
"user", "tirage"
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
participant = cleaned_data.get("participant")
|
||||
|
@ -203,14 +220,9 @@ class AttributionAdminForm(forms.ModelForm):
|
|||
)
|
||||
return cleaned_data
|
||||
|
||||
class Meta:
|
||||
widgets = {
|
||||
"participant": ModelSelect2(url="bda-participant-autocomplete"),
|
||||
"spectacle": ModelSelect2(url="bda-spectacle-autocomplete"),
|
||||
}
|
||||
|
||||
|
||||
class AttributionAdmin(ReadOnlyMixin, admin.ModelAdmin):
|
||||
|
||||
list_display = ("id", "spectacle", "participant", "given", "paid")
|
||||
search_fields = (
|
||||
"spectacle__title",
|
||||
|
@ -223,7 +235,7 @@ class AttributionAdmin(ReadOnlyMixin, admin.ModelAdmin):
|
|||
|
||||
|
||||
class ChoixSpectacleAdmin(admin.ModelAdmin):
|
||||
autocomplete_fields = ["participant", "spectacle"]
|
||||
form = ChoixSpectacleAdminForm
|
||||
|
||||
def tirage(self, obj):
|
||||
return obj.participant.tirage
|
||||
|
@ -267,14 +279,15 @@ class SalleAdmin(admin.ModelAdmin):
|
|||
class SpectacleReventeAdminForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
qset = Participant.objects.select_related("user", "tirage")
|
||||
|
||||
if self.instance.pk is not None:
|
||||
qset = qset.filter(tirage=self.instance.seller.tirage)
|
||||
|
||||
self.fields["confirmed_entry"].queryset = qset
|
||||
self.fields["seller"].queryset = qset
|
||||
self.fields["soldTo"].queryset = qset
|
||||
self.fields["confirmed_entry"].queryset = Participant.objects.select_related(
|
||||
"user", "tirage"
|
||||
)
|
||||
self.fields["seller"].queryset = Participant.objects.select_related(
|
||||
"user", "tirage"
|
||||
)
|
||||
self.fields["soldTo"].queryset = Participant.objects.select_related(
|
||||
"user", "tirage"
|
||||
)
|
||||
|
||||
|
||||
class SpectacleReventeAdmin(admin.ModelAdmin):
|
||||
|
|
|
@ -2,6 +2,7 @@ import random
|
|||
|
||||
|
||||
class Algorithm(object):
|
||||
|
||||
shows = None
|
||||
ranks = None
|
||||
origranks = None
|
||||
|
@ -9,10 +10,10 @@ class Algorithm(object):
|
|||
|
||||
def __init__(self, shows, members, choices):
|
||||
"""Initialisation :
|
||||
- on aggrège toutes les demandes pour chaque spectacle dans
|
||||
show.requests
|
||||
- on crée des tables de demandes pour chaque personne, afin de
|
||||
pouvoir modifier les rankings"""
|
||||
- on aggrège toutes les demandes pour chaque spectacle dans
|
||||
show.requests
|
||||
- on crée des tables de demandes pour chaque personne, afin de
|
||||
pouvoir modifier les rankings"""
|
||||
self.max_group = 2 * max(choice.priority for choice in choices)
|
||||
self.shows = []
|
||||
showdict = {}
|
||||
|
|
|
@ -3,7 +3,7 @@ from django.forms.models import BaseInlineFormSet
|
|||
from django.template import loader
|
||||
from django.utils import timezone
|
||||
|
||||
from bda.models import SpectacleRevente
|
||||
from bda.models import Attribution, Spectacle, SpectacleRevente
|
||||
|
||||
|
||||
class InscriptionInlineFormSet(BaseInlineFormSet):
|
||||
|
@ -77,7 +77,7 @@ class ResellForm(forms.Form):
|
|||
super().__init__(*args, **kwargs)
|
||||
self.fields["attributions"] = TemplateLabelField(
|
||||
queryset=participant.attribution_set.filter(
|
||||
spectacle__date__gte=timezone.now(), paid=True
|
||||
spectacle__date__gte=timezone.now()
|
||||
)
|
||||
.exclude(revente__seller=participant)
|
||||
.select_related("spectacle", "spectacle__location", "participant__user"),
|
||||
|
|
|
@ -81,7 +81,7 @@ class Command(MyBaseCommand):
|
|||
shows = random.sample(
|
||||
list(tirage.spectacle_set.all()), tirage.spectacle_set.count() // 2
|
||||
)
|
||||
for rank, show in enumerate(shows):
|
||||
for (rank, show) in enumerate(shows):
|
||||
choices.append(
|
||||
ChoixSpectacle(
|
||||
participant=part,
|
||||
|
|
|
@ -6,6 +6,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -35,6 +35,7 @@ def fill_tirage_fields(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0001_initial")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0002_add_tirage")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0003_update_tirage_and_spectacle")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0004_mails-rappel")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -18,6 +18,7 @@ def forwards_func(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0005_encoding")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0006_add_tirage_switch")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0007_extends_spectacle")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -6,6 +6,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0008_py3")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -12,15 +12,15 @@ def forwards_func(apps, schema_editor):
|
|||
|
||||
for revente in SpectacleRevente.objects.all():
|
||||
is_expired = timezone.now() > revente.date_tirage()
|
||||
is_direct = (
|
||||
revente.attribution.spectacle.date >= revente.date
|
||||
and timezone.now() > revente.date + timedelta(minutes=15)
|
||||
is_direct = revente.attribution.spectacle.date >= revente.date and timezone.now() > revente.date + timedelta(
|
||||
minutes=15
|
||||
)
|
||||
revente.shotgun = is_expired or is_direct
|
||||
revente.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0009_revente")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0010_spectaclerevente_shotgun")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0011_tirage_appear_catalogue")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -13,6 +13,7 @@ def swap_double_choice(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0011_tirage_appear_catalogue")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -6,6 +6,7 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0012_notif_time"), ("bda", "0012_swap_double_choice")]
|
||||
|
||||
operations = []
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0013_merge_20180524_2123")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -29,6 +29,7 @@ def set_participant_payment(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0014_attribution_paid_field")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0015_move_bda_payment")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0016_delete_participant_paid")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
# Generated by Django 2.2.12 on 2020-10-21 16:18
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("bda", "0017_participant_accepte_charte"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="participant",
|
||||
options={"ordering": ("-tirage", "user__last_name", "user__first_name")},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="tirage",
|
||||
name="archived",
|
||||
field=models.BooleanField(default=False, verbose_name="Archivé"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="participant",
|
||||
name="tirage",
|
||||
field=models.ForeignKey(
|
||||
limit_choices_to={"archived": False},
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="bda.Tirage",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="participant",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("tirage", "user"), name="unique_tirage"
|
||||
),
|
||||
),
|
||||
]
|
|
@ -1,23 +0,0 @@
|
|||
# Generated by Django 3.2.13 on 2022-06-30 10:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bda", "0018_auto_20201021_1818"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name="choixspectacle",
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="choixspectacle",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("participant", "spectacle"), name="unique_participation"
|
||||
),
|
||||
),
|
||||
]
|
115
bda/models.py
115
bda/models.py
|
@ -2,14 +2,14 @@ import calendar
|
|||
import random
|
||||
from datetime import timedelta
|
||||
|
||||
from custommail.models import CustomMail
|
||||
from custommail.shortcuts import send_mass_custom_mail
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core import mail
|
||||
from django.core.mail import EmailMessage, send_mass_mail
|
||||
from django.db import models
|
||||
from django.db.models import Count, Exists
|
||||
from django.template import loader
|
||||
from django.utils import formats, timezone
|
||||
|
||||
|
||||
|
@ -31,7 +31,6 @@ class Tirage(models.Model):
|
|||
"Tirage à afficher dans le catalogue", default=False
|
||||
)
|
||||
enable_do_tirage = models.BooleanField("Le tirage peut être lancé", default=False)
|
||||
archived = models.BooleanField("Archivé", default=False)
|
||||
|
||||
def __str__(self):
|
||||
return "%s - %s" % (
|
||||
|
@ -117,19 +116,16 @@ class Spectacle(models.Model):
|
|||
bda_generic.nb_attr = 1
|
||||
members.append(bda_generic)
|
||||
# On écrit un mail personnalisé à chaque participant
|
||||
mails = [
|
||||
datatuple = [
|
||||
(
|
||||
str(self),
|
||||
loader.render_to_string(
|
||||
"bda/mails/rappel.txt",
|
||||
context={"member": member, "nb_attr": member.nb_attr, "show": self},
|
||||
),
|
||||
"bda-rappel",
|
||||
{"member": member, "nb_attr": member.nb_attr, "show": self},
|
||||
settings.MAIL_DATA["rappels"]["FROM"],
|
||||
[member.email],
|
||||
)
|
||||
for member in members
|
||||
]
|
||||
send_mass_mail(mails)
|
||||
send_mass_custom_mail(datatuple)
|
||||
# On enregistre le fait que l'envoi a bien eu lieu
|
||||
self.rappel_sent = timezone.now()
|
||||
self.save()
|
||||
|
@ -176,8 +172,8 @@ class Attribution(models.Model):
|
|||
|
||||
class ParticipantPaidQueryset(models.QuerySet):
|
||||
"""
|
||||
Un manager qui annote le queryset avec un champ `paid`,
|
||||
indiquant si un participant a payé toutes ses attributions.
|
||||
Un manager qui annote le queryset avec un champ `paid`,
|
||||
indiquant si un participant a payé toutes ses attributions.
|
||||
"""
|
||||
|
||||
def annotate_paid(self):
|
||||
|
@ -198,9 +194,7 @@ class Participant(models.Model):
|
|||
attributions = models.ManyToManyField(
|
||||
Spectacle, through="Attribution", related_name="attributed_to"
|
||||
)
|
||||
tirage = models.ForeignKey(
|
||||
Tirage, on_delete=models.CASCADE, limit_choices_to={"archived": False}
|
||||
)
|
||||
tirage = models.ForeignKey(Tirage, on_delete=models.CASCADE)
|
||||
accepte_charte = models.BooleanField("A accepté la charte BdA", default=False)
|
||||
choicesrevente = models.ManyToManyField(
|
||||
Spectacle, related_name="subscribed", blank=True
|
||||
|
@ -211,12 +205,6 @@ class Participant(models.Model):
|
|||
def __str__(self):
|
||||
return "%s - %s" % (self.user, self.tirage.title)
|
||||
|
||||
class Meta:
|
||||
ordering = ("-tirage", "user__last_name", "user__first_name")
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=("tirage", "user"), name="unique_tirage"),
|
||||
]
|
||||
|
||||
|
||||
DOUBLE_CHOICES = (
|
||||
("1", "1 place"),
|
||||
|
@ -253,11 +241,7 @@ class ChoixSpectacle(models.Model):
|
|||
|
||||
class Meta:
|
||||
ordering = ("priority",)
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["participant", "spectacle"], name="unique_participation"
|
||||
)
|
||||
]
|
||||
unique_together = (("participant", "spectacle"),)
|
||||
verbose_name = "voeu"
|
||||
verbose_name_plural = "voeux"
|
||||
|
||||
|
@ -364,24 +348,21 @@ class SpectacleRevente(models.Model):
|
|||
BdA-Revente à tous les intéressés.
|
||||
"""
|
||||
inscrits = self.attribution.spectacle.subscribed.select_related("user")
|
||||
mails = [
|
||||
datatuple = [
|
||||
(
|
||||
"BdA-Revente : {}".format(self.attribution.spectacle.title),
|
||||
loader.render_to_string(
|
||||
"bda/mails/revente-new.txt",
|
||||
context={
|
||||
"member": participant.user,
|
||||
"show": self.attribution.spectacle,
|
||||
"revente": self,
|
||||
"site": Site.objects.get_current(),
|
||||
},
|
||||
),
|
||||
"bda-revente",
|
||||
{
|
||||
"member": participant.user,
|
||||
"show": self.attribution.spectacle,
|
||||
"revente": self,
|
||||
"site": Site.objects.get_current(),
|
||||
},
|
||||
settings.MAIL_DATA["revente"]["FROM"],
|
||||
[participant.user.email],
|
||||
)
|
||||
for participant in inscrits
|
||||
]
|
||||
send_mass_mail(mails)
|
||||
send_mass_custom_mail(datatuple)
|
||||
self.notif_sent = True
|
||||
self.notif_time = timezone.now()
|
||||
self.save()
|
||||
|
@ -392,23 +373,20 @@ class SpectacleRevente(models.Model):
|
|||
leur indiquer qu'il est désormais disponible au shotgun.
|
||||
"""
|
||||
inscrits = self.attribution.spectacle.subscribed.select_related("user")
|
||||
mails = [
|
||||
datatuple = [
|
||||
(
|
||||
"BdA-Revente : {}".format(self.attribution.spectacle.title),
|
||||
loader.render_to_string(
|
||||
"bda/mails/revente-shotgun.txt",
|
||||
context={
|
||||
"member": participant.user,
|
||||
"show": self.attribution.spectacle,
|
||||
"site": Site.objects.get_current(),
|
||||
},
|
||||
),
|
||||
"bda-shotgun",
|
||||
{
|
||||
"member": participant.user,
|
||||
"show": self.attribution.spectacle,
|
||||
"site": Site.objects.get_current(),
|
||||
},
|
||||
settings.MAIL_DATA["revente"]["FROM"],
|
||||
[participant.user.email],
|
||||
)
|
||||
for participant in inscrits
|
||||
]
|
||||
send_mass_mail(mails)
|
||||
send_mass_custom_mail(datatuple)
|
||||
self.notif_sent = True
|
||||
self.notif_time = timezone.now()
|
||||
# Flag inutile, sauf si l'horloge interne merde
|
||||
|
@ -440,30 +418,31 @@ class SpectacleRevente(models.Model):
|
|||
"show": spectacle,
|
||||
}
|
||||
|
||||
subject = "BdA-Revente : {}".format(spectacle.title)
|
||||
c_mails_qs = CustomMail.objects.filter(
|
||||
shortname__in=[
|
||||
"bda-revente-winner",
|
||||
"bda-revente-loser",
|
||||
"bda-revente-seller",
|
||||
]
|
||||
)
|
||||
|
||||
c_mails = {cm.shortname: cm for cm in c_mails_qs}
|
||||
|
||||
mails.append(
|
||||
EmailMessage(
|
||||
subject=subject,
|
||||
body=loader.render_to_string(
|
||||
"bda/mails/revente-tirage-winner.txt",
|
||||
context=context,
|
||||
),
|
||||
c_mails["bda-revente-winner"].get_message(
|
||||
context,
|
||||
from_email=settings.MAIL_DATA["revente"]["FROM"],
|
||||
to=[winner.user.email],
|
||||
)
|
||||
)
|
||||
|
||||
mails.append(
|
||||
EmailMessage(
|
||||
subject=subject,
|
||||
body=loader.render_to_string(
|
||||
"bda/mails/revente-tirage-seller.txt",
|
||||
context=context,
|
||||
),
|
||||
c_mails["bda-revente-seller"].get_message(
|
||||
context,
|
||||
from_email=settings.MAIL_DATA["revente"]["FROM"],
|
||||
to=[seller.user.email],
|
||||
reply_to=[winner.user.email],
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
# Envoie un mail aux perdants
|
||||
|
@ -473,15 +452,11 @@ class SpectacleRevente(models.Model):
|
|||
new_context["acheteur"] = inscrit.user
|
||||
|
||||
mails.append(
|
||||
EmailMessage(
|
||||
subject=subject,
|
||||
body=loader.render_to_string(
|
||||
"bda/mails/revente-tirage-loser.txt",
|
||||
context=new_context,
|
||||
),
|
||||
c_mails["bda-revente-loser"].get_message(
|
||||
new_context,
|
||||
from_email=settings.MAIL_DATA["revente"]["FROM"],
|
||||
to=[inscrit.user.email],
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
mail_conn = mail.get_connection()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block extra_head %}
|
||||
<link type="text/css" rel="stylesheet" href="{% static "bda/css/bda.css" %}" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block realcontent %}
|
||||
<h2>État des inscriptions BdA</h2>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block extra_head %}
|
||||
<script type="text/javascript" src="{% static 'vendor/jquery/jquery-ui.min.js' %}" ></script>
|
||||
|
|
|
@ -26,6 +26,13 @@
|
|||
|
||||
<hr \>
|
||||
|
||||
<p>
|
||||
<em>Note :</em> le template de ce mail peut être modifié à
|
||||
<a href="{% url 'admin:custommail_custommail_change' custommail.pk %}">cette adresse</a>
|
||||
</p>
|
||||
|
||||
<hr \>
|
||||
|
||||
<h3>Forme des mails</h3>
|
||||
|
||||
<h4>Une seule place</h4>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
Cher-e {{ member.first_name }},
|
||||
|
||||
Tu t'es inscrit-e pour le tirage au sort du BdA. Malheureusement, tu n'as
|
||||
obtenu aucune place.
|
||||
|
||||
Nous proposons cependant de nombreuses offres hors-tirage tout au long de
|
||||
l'année, et nous t'invitons à nous contacter si l'une d'entre elles
|
||||
t'intéresse !
|
||||
--
|
||||
Le Bureau des Arts
|
|
@ -1,31 +0,0 @@
|
|||
Cher-e {{ member.first_name }},
|
||||
|
||||
Tu t'es inscrit-e pour le tirage au sort du BdA. Tu as été sélectionné-e
|
||||
pour les spectacles suivants :
|
||||
{% for place in places %}
|
||||
- 1 place pour {{ place }}{% endfor %}
|
||||
|
||||
*Paiement*
|
||||
L'intégralité de ces places de spectacles est à régler dès maintenant et AVANT
|
||||
vendredi prochain, au bureau du COF pendant les heures de permanences (du lundi au vendredi
|
||||
entre 12h et 14h, et entre 18h et 20h). Des facilités de paiement sont bien
|
||||
évidemment possibles : nous pouvons ne pas encaisser le chèque immédiatement,
|
||||
ou bien découper votre paiement en deux fois. Pour ceux qui ne pourraient pas
|
||||
venir payer au bureau, merci de nous contacter par mail.
|
||||
|
||||
*Mode de retrait des places*
|
||||
Au moment du paiement, certaines places vous seront remises directement,
|
||||
d'autres seront à récupérer au cours de l'année, d'autres encore seront
|
||||
nominatives et à retirer le soir même dans les théâtres correspondants.
|
||||
Pour chaque spectacle, vous recevrez un mail quelques jours avant la
|
||||
représentation vous indiquant le mode de retrait.
|
||||
|
||||
Nous vous rappelons que l'obtention de places du BdA vous engage à
|
||||
respecter les règles de fonctionnement :
|
||||
https://bda.ens.fr/lequipe/charte-bda/
|
||||
Un système de revente des places via les mails BdA-revente est disponible
|
||||
directement sur votre compte GestioCOF.
|
||||
|
||||
En vous souhaitant de très beaux spectacles tout au long de l'année,
|
||||
--
|
||||
Le Bureau des Arts
|
|
@ -1,23 +0,0 @@
|
|||
Bonjour {{ member.first_name }},
|
||||
|
||||
Nous te rappellons que tu as eu la chance d'obtenir {{ nb_attr|pluralize:"une place,deux places" }}
|
||||
pour {{ show.title }}, le {{ show.date }} au {{ show.location }}. N'oublie pas de t'y rendre !
|
||||
{% if nb_attr == 2 %}
|
||||
Tu as obtenu deux places pour ce spectacle. Nous te rappelons que
|
||||
ces places sont strictement réservées aux personnes de moins de 28 ans.
|
||||
{% endif %}
|
||||
{% if show.listing %}Pour ce spectacle, tu as reçu {{ nb_attr|pluralize:"une place,des places" }} sur
|
||||
listing. Il te faudra donc te rendre 15 minutes en avance sur les lieux de la représentation
|
||||
pour {{ nb_attr|pluralize:"la,les" }} retirer.
|
||||
{% else %}Pour assister à ce spectacle, tu dois présenter les billets qui ont
|
||||
été distribués au burô.
|
||||
{% endif %}
|
||||
|
||||
Si tu ne peux plus assister à cette représentation, tu peux
|
||||
revendre ta place via BdA-revente, accessible directement sur
|
||||
GestioCOF (lien "revendre une place du premier tirage" sur la page
|
||||
d'accueil https://www.cof.ens.fr/gestion/).
|
||||
|
||||
En te souhaitant un excellent spectacle,
|
||||
--
|
||||
Le Bureau des Arts
|
|
@ -1,12 +0,0 @@
|
|||
Bonjour {{ member.first_name }}
|
||||
|
||||
Une place pour le spectacle {{ show.title }} ({{ show.date }})
|
||||
a été postée sur BdA-Revente.
|
||||
|
||||
Si ce spectacle t'intéresse toujours, merci de nous le signaler en cliquant
|
||||
sur ce lien : https://{{ site }}{% url "bda-revente-confirm" revente.id %}.
|
||||
Dans le cas où plusieurs personnes seraient intéressées, nous procèderons à
|
||||
un tirage au sort le {{ revente.date_tirage|date:"DATE_FORMAT" }}.
|
||||
|
||||
Chaleureusement,
|
||||
Le BdA
|
|
@ -1,13 +0,0 @@
|
|||
Bonjour {{ vendeur.first_name }},
|
||||
|
||||
Tu t’es bien inscrit·e pour revendre une place pour {{ show.title }}.
|
||||
|
||||
{% with revente.date_tirage as time %}
|
||||
Le tirage au sort entre tout·e·s les racheteuse·eur·s potentiel·le·s aura lieu
|
||||
le {{ time|date:"DATE_FORMAT" }} à {{ time|time:"TIME_FORMAT" }} (dans {{time|timeuntil }}).
|
||||
Si personne ne s’est inscrit pour racheter la place, celle-ci apparaîtra parmi
|
||||
les « Places disponibles immédiatement à la revente » sur GestioCOF.
|
||||
{% endwith %}
|
||||
|
||||
Bonne revente !
|
||||
Le Bureau des Arts
|
|
@ -1,6 +0,0 @@
|
|||
Bonjour {{ vendeur.first_name }} !
|
||||
|
||||
Je souhaiterais racheter ta place pour {{ show.title }} le {{ show.date }} ({{ show.location }}) à {{ show.price|floatformat:2 }}€.
|
||||
Contacte-moi si tu es toujours intéressé·e !
|
||||
|
||||
{{ acheteur.get_full_name }} ({{ acheteur.email }})
|
|
@ -1,11 +0,0 @@
|
|||
Bonjour {{ member.first_name }}
|
||||
|
||||
Une place pour le spectacle {{ show.title }} ({{ show.date }})
|
||||
a été postée sur BdA-Revente.
|
||||
|
||||
Puisque ce spectacle a lieu dans moins de 24h, il n'y a pas de tirage au sort pour
|
||||
cette place : elle est disponible immédiatement à l'adresse
|
||||
https://{{ site }}{% url "bda-revente-buy" show.id %}, à la disposition de tous.
|
||||
|
||||
Chaleureusement,
|
||||
Le BdA
|
|
@ -1,9 +0,0 @@
|
|||
Bonjour {{ acheteur.first_name }},
|
||||
|
||||
Tu t'étais inscrit·e pour la revente de la place de {{ vendeur.get_full_name }}
|
||||
pour {{ show.title }}.
|
||||
Malheureusement, une autre personne a été tirée au sort pour racheter la place.
|
||||
Tu pourras certainement retenter ta chance pour une autre revente !
|
||||
|
||||
À très bientôt,
|
||||
Le Bureau des Arts
|
|
@ -1,7 +0,0 @@
|
|||
Bonjour {{ vendeur.first_name }},
|
||||
|
||||
La personne tirée au sort pour racheter ta place pour {{ show.title }} est {{ acheteur.get_full_name }}.
|
||||
Tu peux le/la contacter à l'adresse {{ acheteur.email }}, ou en répondant à ce mail.
|
||||
|
||||
Chaleureusement,
|
||||
Le BdA
|
|
@ -1,7 +0,0 @@
|
|||
Bonjour {{ acheteur.first_name }},
|
||||
|
||||
Tu as été tiré·e au sort pour racheter une place pour {{ show.title }} le {{ show.date }} ({{ show.location }}) à {{ show.price|floatformat:2 }}€.
|
||||
Tu peux contacter le/la vendeur·se à l'adresse {{ vendeur.email }}.
|
||||
|
||||
Chaleureusement,
|
||||
Le BdA
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block realcontent %}
|
||||
<h2>{{ spectacle }}</h2>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<tbody>
|
||||
{% for participant in participants %}
|
||||
<tr>
|
||||
<td data-sort-value="{{ participant.name}}">{{participant.name}}</td>
|
||||
<td data-sort-value="{{ participan.name}}">{{participant.name}}</td>
|
||||
<td data-sort-value="{{participant.nb_places}}">{{participant.nb_places}} place{{participant.nb_places|pluralize}}</td>
|
||||
<td data-sort-value="{{participant.email}}">{{participant.email}}</td>
|
||||
<td data-sort-value="{{ participant.paid}}" class={%if participant.paid %}"greenratio"{%else%}"redratio"{%endif%}>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
<td>{{place.spectacle.location}}</td>
|
||||
<td>{{place.spectacle.date}}</td>
|
||||
<td>{% if place.double %}deux places{%else%}une place{% endif %}</td>
|
||||
<td>{% if place.spectacle.listing %}sur listing{% else %}place physique{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
|
||||
{%block realcontent %}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block realcontent %}
|
||||
<h2>Inscription à une revente</h2>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block realcontent %}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block realcontent %}
|
||||
|
||||
|
|
6
bda/templates/bda/revente/notpaid.html
Normal file
6
bda/templates/bda/revente/notpaid.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% extends "base_title.html" %}
|
||||
|
||||
{% block realcontent %}
|
||||
<h2><strong>Nope</strong></h2>
|
||||
<p>Avant de revendre des places, il faut aller les payer !</p>
|
||||
{% endblock %}
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles%}
|
||||
|
||||
{% block realcontent %}
|
||||
<h2>Inscriptions pour BdA-Revente</h2>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block realcontent %}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load static %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block extra_head %}
|
||||
<link type="text/css" rel="stylesheet" href="{% static "bda/css/bda.css" %}" />
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management import call_command
|
||||
from django.utils import timezone
|
||||
|
||||
from shared.tests.mixins import ViewTestCaseMixin
|
||||
|
@ -24,6 +28,12 @@ class BdATestHelpers:
|
|||
if self.bda_testdata:
|
||||
self.load_bda_testdata()
|
||||
|
||||
def require_custommails(self):
|
||||
data_file = os.path.join(
|
||||
settings.BASE_DIR, "gestioncof", "management", "data", "custommail.json"
|
||||
)
|
||||
call_command("syncmails", data_file, verbosity=0)
|
||||
|
||||
def load_bda_testdata(self):
|
||||
self.tirage = Tirage.objects.create(
|
||||
title="Test tirage",
|
||||
|
|
|
@ -19,6 +19,8 @@ User = get_user_model()
|
|||
|
||||
|
||||
class SpectacleReventeTests(TestCase):
|
||||
fixtures = ["gestioncof/management/data/custommail.json"]
|
||||
|
||||
def setUp(self):
|
||||
now = timezone.now()
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class InscriptionViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/gestion/bda/inscription/{}".format(self.tirage.id)
|
||||
return "/bda/inscription/{}".format(self.tirage.id)
|
||||
|
||||
def test_get_opened(self):
|
||||
self.tirage.ouverture = timezone.now() - timedelta(days=1)
|
||||
|
@ -149,7 +149,7 @@ class PlacesViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/gestion/bda/places/{}".format(self.tirage.id)
|
||||
return "/bda/places/{}".format(self.tirage.id)
|
||||
|
||||
|
||||
class EtatPlacesViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
||||
|
@ -166,7 +166,7 @@ class EtatPlacesViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/gestion/bda/etat-places/{}".format(self.tirage.id)
|
||||
return "/bda/etat-places/{}".format(self.tirage.id)
|
||||
|
||||
|
||||
class TirageViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
||||
|
@ -185,7 +185,7 @@ class TirageViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/gestion/bda/tirage/{}".format(self.tirage.id)
|
||||
return "/bda/tirage/{}".format(self.tirage.id)
|
||||
|
||||
def test_perform_tirage_disabled(self):
|
||||
# Cannot be performed if disabled
|
||||
|
@ -225,7 +225,7 @@ class SpectacleListViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/gestion/bda/spectacles/{}".format(self.tirage.id)
|
||||
return "/bda/spectacles/{}".format(self.tirage.id)
|
||||
|
||||
|
||||
class SpectacleViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
||||
|
@ -242,7 +242,7 @@ class SpectacleViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/gestion/bda/spectacles/{}/{}".format(self.tirage.id, self.show1.id)
|
||||
return "/bda/spectacles/{}/{}".format(self.tirage.id, self.show1.id)
|
||||
|
||||
|
||||
class UnpaidViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
||||
|
@ -259,7 +259,7 @@ class UnpaidViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/gestion/bda/spectacles/unpaid/{}".format(self.tirage.id)
|
||||
return "/bda/spectacles/unpaid/{}".format(self.tirage.id)
|
||||
|
||||
|
||||
class SendRemindersViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
||||
|
@ -276,9 +276,10 @@ class SendRemindersViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/gestion/bda/mails-rappel/{}".format(self.show1.id)
|
||||
return "/bda/mails-rappel/{}".format(self.show1.id)
|
||||
|
||||
def test_post(self):
|
||||
self.require_custommails()
|
||||
resp = self.client.post(self.url)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
# TODO: check that emails are sent
|
||||
|
@ -291,7 +292,7 @@ class CatalogueViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
bda_testdata = True
|
||||
|
||||
def test_api_list(self):
|
||||
url_list = "/gestion/bda/catalogue/list"
|
||||
url_list = "/bda/catalogue/list"
|
||||
resp = self.client.get(url_list)
|
||||
self.assertJSONEqual(
|
||||
resp.content.decode("utf-8"),
|
||||
|
@ -299,7 +300,7 @@ class CatalogueViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
)
|
||||
|
||||
def test_api_details(self):
|
||||
url_details = "/gestion/bda/catalogue/details?id={}".format(self.tirage.id)
|
||||
url_details = "/bda/catalogue/details?id={}".format(self.tirage.id)
|
||||
resp = self.client.get(url_details)
|
||||
self.assertJSONEqual(
|
||||
resp.content.decode("utf-8"),
|
||||
|
@ -310,9 +311,7 @@ class CatalogueViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase):
|
|||
)
|
||||
|
||||
def test_api_descriptions(self):
|
||||
url_descriptions = "/gestion/bda/catalogue/descriptions?id={}".format(
|
||||
self.tirage.id
|
||||
)
|
||||
url_descriptions = "/bda/catalogue/descriptions?id={}".format(self.tirage.id)
|
||||
resp = self.client.get(url_descriptions)
|
||||
raw = resp.content.decode("utf-8")
|
||||
try:
|
||||
|
@ -356,9 +355,7 @@ class TestReventeManageTest(TestCase):
|
|||
|
||||
def test_can_get(self):
|
||||
client = Client()
|
||||
client.force_login(
|
||||
self.user, backend="django.contrib.auth.backends.ModelBackend"
|
||||
)
|
||||
client.force_login(self.user)
|
||||
r = client.get(self.url)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
|
|
42
bda/urls.py
42
bda/urls.py
|
@ -1,80 +1,74 @@
|
|||
from django.urls import re_path
|
||||
from django.conf.urls import url
|
||||
|
||||
from bda import views
|
||||
from bda.views import SpectacleListView
|
||||
from gestioncof.decorators import buro_required
|
||||
|
||||
urlpatterns = [
|
||||
re_path(
|
||||
url(
|
||||
r"^inscription/(?P<tirage_id>\d+)$",
|
||||
views.inscription,
|
||||
name="bda-tirage-inscription",
|
||||
),
|
||||
re_path(r"^places/(?P<tirage_id>\d+)$", views.places, name="bda-places-attribuees"),
|
||||
re_path(
|
||||
r"^etat-places/(?P<tirage_id>\d+)$", views.etat_places, name="bda-etat-places"
|
||||
),
|
||||
re_path(r"^tirage/(?P<tirage_id>\d+)$", views.tirage, name="bda-tirage"),
|
||||
re_path(
|
||||
url(r"^places/(?P<tirage_id>\d+)$", views.places, name="bda-places-attribuees"),
|
||||
url(r"^etat-places/(?P<tirage_id>\d+)$", views.etat_places, name="bda-etat-places"),
|
||||
url(r"^tirage/(?P<tirage_id>\d+)$", views.tirage, name="bda-tirage"),
|
||||
url(
|
||||
r"^spectacles/(?P<tirage_id>\d+)$",
|
||||
buro_required(SpectacleListView.as_view()),
|
||||
name="bda-liste-spectacles",
|
||||
),
|
||||
re_path(
|
||||
url(
|
||||
r"^spectacles/(?P<tirage_id>\d+)/(?P<spectacle_id>\d+)$",
|
||||
views.spectacle,
|
||||
name="bda-spectacle",
|
||||
),
|
||||
re_path(
|
||||
url(
|
||||
r"^spectacles/unpaid/(?P<tirage_id>\d+)$",
|
||||
views.UnpaidParticipants.as_view(),
|
||||
name="bda-unpaid",
|
||||
),
|
||||
re_path(
|
||||
url(
|
||||
r"^spectacles/autocomplete$",
|
||||
views.spectacle_autocomplete,
|
||||
name="bda-spectacle-autocomplete",
|
||||
),
|
||||
re_path(
|
||||
url(
|
||||
r"^participants/autocomplete$",
|
||||
views.participant_autocomplete,
|
||||
name="bda-participant-autocomplete",
|
||||
),
|
||||
# Urls BdA-Revente
|
||||
re_path(
|
||||
url(
|
||||
r"^revente/(?P<tirage_id>\d+)/manage$",
|
||||
views.revente_manage,
|
||||
name="bda-revente-manage",
|
||||
),
|
||||
re_path(
|
||||
url(
|
||||
r"^revente/(?P<tirage_id>\d+)/subscribe$",
|
||||
views.revente_subscribe,
|
||||
name="bda-revente-subscribe",
|
||||
),
|
||||
re_path(
|
||||
url(
|
||||
r"^revente/(?P<tirage_id>\d+)/tirages$",
|
||||
views.revente_tirages,
|
||||
name="bda-revente-tirages",
|
||||
),
|
||||
re_path(
|
||||
url(
|
||||
r"^revente/(?P<spectacle_id>\d+)/buy$",
|
||||
views.revente_buy,
|
||||
name="bda-revente-buy",
|
||||
),
|
||||
re_path(
|
||||
url(
|
||||
r"^revente/(?P<revente_id>\d+)/confirm$",
|
||||
views.revente_confirm,
|
||||
name="bda-revente-confirm",
|
||||
),
|
||||
re_path(
|
||||
url(
|
||||
r"^revente/(?P<tirage_id>\d+)/shotgun$",
|
||||
views.revente_shotgun,
|
||||
name="bda-revente-shotgun",
|
||||
),
|
||||
re_path(
|
||||
r"^mails-rappel/(?P<spectacle_id>\d+)$", views.send_rappel, name="bda-rappels"
|
||||
),
|
||||
re_path(
|
||||
r"^catalogue/(?P<request_type>[a-z]+)$", views.catalogue, name="bda-catalogue"
|
||||
),
|
||||
url(r"^mails-rappel/(?P<spectacle_id>\d+)$", views.send_rappel, name="bda-rappels"),
|
||||
url(r"^catalogue/(?P<request_type>[a-z]+)$", views.catalogue, name="bda-catalogue"),
|
||||
]
|
||||
|
|
63
bda/views.py
63
bda/views.py
|
@ -4,17 +4,17 @@ import random
|
|||
import time
|
||||
from collections import defaultdict
|
||||
|
||||
from custommail.models import CustomMail
|
||||
from custommail.shortcuts import send_custom_mail, send_mass_custom_mail
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core import serializers
|
||||
from django.core.exceptions import NON_FIELD_ERRORS
|
||||
from django.core.mail import send_mail, send_mass_mail
|
||||
from django.db import transaction
|
||||
from django.db.models import Count, Prefetch
|
||||
from django.forms.models import inlineformset_factory
|
||||
from django.http import HttpResponseBadRequest, HttpResponseRedirect, JsonResponse
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.template import loader
|
||||
from django.template.defaultfilters import pluralize
|
||||
from django.urls import reverse
|
||||
from django.utils import formats, timezone
|
||||
|
@ -274,13 +274,13 @@ def do_tirage(tirage_elt, token):
|
|||
results = Algorithm(data["shows"], data["members"], choices)(token)
|
||||
|
||||
# On compte les places attribuées et les déçus
|
||||
for _, members, losers in results:
|
||||
for (_, members, losers) in results:
|
||||
data["total_slots"] += len(members)
|
||||
data["total_losers"] += len(losers)
|
||||
|
||||
# On calcule le déficit et les bénéfices pour le BdA
|
||||
# FIXME: le traitement de l'opéra est sale
|
||||
for show, members, _ in results:
|
||||
for (show, members, _) in results:
|
||||
deficit = (show.slots - len(members)) * show.price
|
||||
data["total_sold"] += show.slots * show.price
|
||||
if deficit >= 0:
|
||||
|
@ -293,8 +293,8 @@ def do_tirage(tirage_elt, token):
|
|||
# so assign a single object for each Participant id
|
||||
members_uniq = {}
|
||||
members2 = {}
|
||||
for show, members, _ in results:
|
||||
for member, _, _, _ in members:
|
||||
for (show, members, _) in results:
|
||||
for (member, _, _, _) in members:
|
||||
if member.id not in members_uniq:
|
||||
members_uniq[member.id] = member
|
||||
members2[member] = []
|
||||
|
@ -385,6 +385,12 @@ def revente_manage(request, tirage_id):
|
|||
user=request.user, tirage=tirage
|
||||
)
|
||||
|
||||
# If the participant has just been created, the `paid` field is not
|
||||
# automatically added by our custom ObjectManager. Skip the check in this
|
||||
# scenario.
|
||||
if not created and not participant.paid:
|
||||
return render(request, "bda/revente/notpaid.html", {})
|
||||
|
||||
resellform = ResellForm(participant, prefix="resell")
|
||||
annulform = AnnulForm(participant, prefix="annul")
|
||||
soldform = SoldForm(participant, prefix="sold")
|
||||
|
@ -394,7 +400,7 @@ def revente_manage(request, tirage_id):
|
|||
if "resell" in request.POST:
|
||||
resellform = ResellForm(participant, request.POST, prefix="resell")
|
||||
if resellform.is_valid():
|
||||
mails = []
|
||||
datatuple = []
|
||||
attributions = resellform.cleaned_data["attributions"]
|
||||
with transaction.atomic():
|
||||
for attribution in attributions:
|
||||
|
@ -409,17 +415,16 @@ def revente_manage(request, tirage_id):
|
|||
"show": attribution.spectacle,
|
||||
"revente": revente,
|
||||
}
|
||||
mails.append(
|
||||
datatuple.append(
|
||||
(
|
||||
"BdA-Revente : {}".format(attribution.spectacle),
|
||||
loader.render_to_string(
|
||||
"bda/mails/revente-seller.txt", context=context
|
||||
),
|
||||
"bda-revente-new",
|
||||
context,
|
||||
settings.MAIL_DATA["revente"]["FROM"],
|
||||
[participant.user.email],
|
||||
)
|
||||
)
|
||||
send_mass_mail(mails)
|
||||
revente.save()
|
||||
send_mass_custom_mail(datatuple)
|
||||
# On annule une revente
|
||||
elif "annul" in request.POST:
|
||||
annulform = AnnulForm(participant, request.POST, prefix="annul")
|
||||
|
@ -638,16 +643,12 @@ def revente_buy(request, spectacle_id):
|
|||
"acheteur": request.user,
|
||||
"vendeur": revente.seller.user,
|
||||
}
|
||||
|
||||
send_mail(
|
||||
"BdA-Revente : {}".format(spectacle.title),
|
||||
loader.render_to_string(
|
||||
"bda/mails/revente-shotgun-seller.txt", context=context
|
||||
),
|
||||
request.user.email,
|
||||
send_custom_mail(
|
||||
"bda-buy-shotgun",
|
||||
"bda@ens.fr",
|
||||
[revente.seller.user.email],
|
||||
context=context,
|
||||
)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"bda/revente/mail-success.html",
|
||||
|
@ -700,7 +701,7 @@ def spectacle(request, tirage_id, spectacle_id):
|
|||
"username": participant.user.username,
|
||||
"email": participant.user.email,
|
||||
"given": int(attrib.given),
|
||||
"paid": attrib.paid,
|
||||
"paid": True,
|
||||
"nb_places": 1,
|
||||
}
|
||||
if participant.id in participants:
|
||||
|
@ -750,21 +751,19 @@ class UnpaidParticipants(BuroRequiredMixin, ListView):
|
|||
def send_rappel(request, spectacle_id):
|
||||
show = get_object_or_404(Spectacle, id=spectacle_id)
|
||||
# Mails d'exemples
|
||||
subject = show.title
|
||||
body_mail_1place = loader.render_to_string(
|
||||
"bda/mails/rappel.txt",
|
||||
context={"member": request.user, "show": show, "nb_attr": 1},
|
||||
custommail = CustomMail.objects.get(shortname="bda-rappel")
|
||||
exemple_mail_1place = custommail.render(
|
||||
{"member": request.user, "show": show, "nb_attr": 1}
|
||||
)
|
||||
body_mail_2places = loader.render_to_string(
|
||||
"bda/mails/rappel.txt",
|
||||
context={"member": request.user, "show": show, "nb_attr": 2},
|
||||
exemple_mail_2places = custommail.render(
|
||||
{"member": request.user, "show": show, "nb_attr": 2}
|
||||
)
|
||||
|
||||
# Contexte
|
||||
ctxt = {
|
||||
"show": show,
|
||||
"exemple_mail_1place": (subject, body_mail_1place),
|
||||
"exemple_mail_2places": (subject, body_mail_2places),
|
||||
"exemple_mail_1place": exemple_mail_1place,
|
||||
"exemple_mail_2places": exemple_mail_2places,
|
||||
"custommail": custommail,
|
||||
}
|
||||
# Envoi confirmé
|
||||
if request.method == "POST":
|
||||
|
|
25
bds/apps.py
25
bds/apps.py
|
@ -1,28 +1,5 @@
|
|||
from django.apps import AppConfig, apps as global_apps
|
||||
from django.db.models import Q
|
||||
from django.db.models.signals import post_migrate
|
||||
|
||||
|
||||
def bds_group_perms(app_config, apps=global_apps, **kwargs):
|
||||
try:
|
||||
Permission = apps.get_model("auth", "Permission")
|
||||
Group = apps.get_model("auth", "Group")
|
||||
|
||||
group = Group.objects.get(name="Burô du BDS")
|
||||
perms = Permission.objects.filter(
|
||||
Q(content_type__app_label="bds")
|
||||
| Q(content_type__app_label="auth") & Q(content_type__model="user")
|
||||
)
|
||||
group.permissions.set(perms)
|
||||
group.save()
|
||||
|
||||
except (LookupError, Group.DoesNotExist):
|
||||
return
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BdsConfig(AppConfig):
|
||||
name = "bds"
|
||||
verbose_name = "Gestion des adhérent·e·s du BDS"
|
||||
|
||||
def ready(self):
|
||||
post_migrate.connect(bds_group_perms, sender=self)
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
from urllib.parse import urlencode
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db.models import Q
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from shared import autocomplete
|
||||
|
@ -24,7 +21,7 @@ class BDSMemberSearch(autocomplete.ModelSearch):
|
|||
return user.username
|
||||
|
||||
def result_link(self, user):
|
||||
return reverse("bds:user.update", args=(user.pk,))
|
||||
return "#TODO"
|
||||
|
||||
|
||||
class BDSOthersSearch(autocomplete.ModelSearch):
|
||||
|
@ -41,15 +38,12 @@ class BDSOthersSearch(autocomplete.ModelSearch):
|
|||
return user.username
|
||||
|
||||
def result_link(self, user):
|
||||
return reverse("bds:user.update", args=(user.pk,))
|
||||
return "#TODO"
|
||||
|
||||
|
||||
class BDSLDAPSearch(autocomplete.LDAPSearch):
|
||||
def result_link(self, clipper):
|
||||
url = reverse("bds:user.create.fromclipper", args=(clipper.clipper,))
|
||||
get = {"fullname": clipper.fullname, "mail": clipper.mail}
|
||||
|
||||
return "{}?{}".format(url, urlencode(get))
|
||||
return "#TODO"
|
||||
|
||||
|
||||
class BDSSearch(autocomplete.Compose):
|
||||
|
|
41
bds/forms.py
41
bds/forms.py
|
@ -1,41 +0,0 @@
|
|||
from django import forms
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from bds.models import BDSProfile
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class UserForm(forms.ModelForm):
|
||||
is_buro = forms.BooleanField(label=_("Membre du Burô"), required=False)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["email", "first_name", "last_name"]
|
||||
|
||||
|
||||
class UserFromClipperForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["username"].disabled = True
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["username", "email", "first_name", "last_name"]
|
||||
|
||||
|
||||
class UserFromScratchForm(UserCreationForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["username", "email", "first_name", "last_name"]
|
||||
|
||||
|
||||
class ProfileForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = BDSProfile
|
||||
exclude = ["user"]
|
||||
widgets = {
|
||||
"birthdate": forms.DateInput(attrs={"type": "date"}, format="%Y-%m-%d")
|
||||
}
|
|
@ -8,6 +8,7 @@ import bds.models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]
|
||||
|
|
|
@ -1,14 +1,28 @@
|
|||
# Generated by Django 2.2 on 2019-07-17 14:56
|
||||
|
||||
from django.contrib.auth.management import create_permissions
|
||||
from django.db import migrations
|
||||
from django.db.models import Q
|
||||
|
||||
|
||||
def create_bds_buro_group(apps, schema_editor):
|
||||
for app_config in apps.get_app_configs():
|
||||
create_permissions(app_config, apps=apps, verbosity=0)
|
||||
|
||||
Group = apps.get_model("auth", "Group")
|
||||
Group.objects.get_or_create(name="Burô du BDS")
|
||||
Permission = apps.get_model("auth", "Permission")
|
||||
group, created = Group.objects.get_or_create(name="Burô du BDS")
|
||||
if created:
|
||||
perms = Permission.objects.filter(
|
||||
Q(content_type__app_label="bds")
|
||||
| Q(content_type__app_label="auth") & Q(content_type__model="user")
|
||||
)
|
||||
group.permissions.set(perms)
|
||||
group.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bds", "0001_initial")]
|
||||
|
||||
operations = [
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bds", "0002_bds_group"),
|
||||
]
|
||||
|
@ -17,8 +18,5 @@ class Migration(migrations.Migration):
|
|||
"verbose_name_plural": "Profils BDS",
|
||||
},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="bdsprofile",
|
||||
name="is_buro",
|
||||
),
|
||||
migrations.RemoveField(model_name="bdsprofile", name="is_buro",),
|
||||
]
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bds", "0003_staff_permission"),
|
||||
]
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
# Generated by Django 2.2.14 on 2020-07-27 20:14
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("bds", "0004_is_member_cotiz_type"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="bdsprofile",
|
||||
name="certificate_file",
|
||||
),
|
||||
]
|
|
@ -1,22 +0,0 @@
|
|||
# Generated by Django 2.2.12 on 2020-08-28 12:14
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("bds", "0005_remove_bdsprofile_certificate_file"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="bdsprofile",
|
||||
name="comments",
|
||||
field=models.TextField(
|
||||
blank=True,
|
||||
help_text="Attention : l'utilisateur·ice dispose d'un droit d'accès"
|
||||
" aux données le/la concernant, dont le contenu de ce champ !",
|
||||
verbose_name="commentaires",
|
||||
),
|
||||
),
|
||||
]
|
119
bds/mixins.py
119
bds/mixins.py
|
@ -1,122 +1,5 @@
|
|||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.views.generic.base import ContextMixin, TemplateResponseMixin, View
|
||||
|
||||
|
||||
class StaffRequiredMixin(PermissionRequiredMixin):
|
||||
permission_required = "bds.is_team"
|
||||
|
||||
|
||||
class MultipleFormMixin(ContextMixin):
|
||||
"""Mixin pour gérer plusieurs formulaires dans la même vue.
|
||||
Le fonctionnement est relativement identique à celui de
|
||||
FormMixin, dont la documentation est disponible ici :
|
||||
https://docs.djangoproject.com/en/3.0/ref/class-based-views/mixins-editing/
|
||||
|
||||
Les principales différences sont :
|
||||
- au lieu de form_class, il faut donner comme attribut un dict de la forme
|
||||
{<form_name>: <form_class>}, avec tous les formulaires à instancier. On
|
||||
peut aussi redéfinir `get_form_classes`
|
||||
|
||||
- les données initiales se récupèrent pour chaque form via l'attribut
|
||||
`<form_name>_initial` ou la fonction `get_<form_name>_initial`. De même,
|
||||
si certaines forms sont des `ModelForm`s, on peut définir la fonction
|
||||
`get_<form_name>_instance`.
|
||||
|
||||
- chaque form a un préfixe rajouté, par défaut <form_name>, mais qui peut
|
||||
être customisé via `prefixes` ou `get_prefixes`.
|
||||
"""
|
||||
|
||||
form_classes = {}
|
||||
prefixes = {}
|
||||
initial = {}
|
||||
|
||||
success_url = None
|
||||
|
||||
def get_form_classes(self):
|
||||
return self.form_classes
|
||||
|
||||
def get_initial(self, form_name):
|
||||
initial_attr = "%s_initial" % form_name
|
||||
|
||||
initial_method = "get_%s_initial" % form_name
|
||||
initial_method = getattr(self, initial_method, None)
|
||||
|
||||
if hasattr(self, initial_attr):
|
||||
return getattr(self, initial_attr)
|
||||
elif callable(initial_method):
|
||||
return initial_method()
|
||||
else:
|
||||
return self.initial.copy()
|
||||
|
||||
def get_prefix(self, form_name):
|
||||
return self.prefixes.get(form_name, form_name)
|
||||
|
||||
def get_instance(self, form_name):
|
||||
# Au cas où certaines des forms soient des ModelForms
|
||||
instance_method = "get_%s_instance" % form_name
|
||||
instance_method = getattr(self, instance_method, None)
|
||||
|
||||
if callable(instance_method):
|
||||
return instance_method()
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_form_kwargs(self, form_name):
|
||||
kwargs = {
|
||||
"initial": self.get_initial(form_name),
|
||||
"prefix": self.get_prefix(form_name),
|
||||
"instance": self.get_instance(form_name),
|
||||
}
|
||||
|
||||
if self.request.method in ("POST", "PUT"):
|
||||
kwargs.update({"data": self.request.POST, "files": self.request.FILES})
|
||||
|
||||
return kwargs
|
||||
|
||||
def get_forms(self):
|
||||
form_classes = self.get_form_classes()
|
||||
return {
|
||||
form_name: form_class(**self.get_form_kwargs(form_name))
|
||||
for form_name, form_class in form_classes.items()
|
||||
}
|
||||
|
||||
def get_success_url(self):
|
||||
if not self.success_url:
|
||||
raise ImproperlyConfigured("No URL to redirect to. Provide a success_url.")
|
||||
return str(self.success_url)
|
||||
|
||||
def form_valid(self, forms):
|
||||
# on garde le nom form_valid pour l'interface avec SuccessMessageMixin
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def form_invalid(self, forms):
|
||||
"""If the form is invalid, render the invalid form."""
|
||||
return self.render_to_response(self.get_context_data(forms=forms))
|
||||
|
||||
|
||||
class ProcessMultipleFormView(View):
|
||||
"""Équivalent de `ProcessFormView` pour plusieurs forms.
|
||||
Note : il faut que *tous* les formulaires soient valides pour
|
||||
qu'ils soient sauvegardés !
|
||||
"""
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
forms = self.get_forms()
|
||||
return self.render_to_response(self.get_context_data(forms=forms))
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
forms = self.get_forms()
|
||||
if all(form.is_valid() for form in forms.values()):
|
||||
return self.form_valid(forms)
|
||||
else:
|
||||
return self.form_invalid(forms)
|
||||
|
||||
|
||||
class BaseMultipleFormView(MultipleFormMixin, ProcessMultipleFormView):
|
||||
pass
|
||||
|
||||
|
||||
class MultipleFormView(TemplateResponseMixin, BaseMultipleFormView):
|
||||
pass
|
||||
permission_required = "bds:is_team"
|
||||
|
|
|
@ -3,7 +3,6 @@ from os.path import splitext
|
|||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from shared.utils import choices_length
|
||||
|
@ -63,11 +62,14 @@ class BDSProfile(models.Model):
|
|||
null=True,
|
||||
)
|
||||
|
||||
is_member = models.BooleanField(_("adhérent⋅e du BDS"), default=False)
|
||||
|
||||
mails_bds = models.BooleanField(_("recevoir les mails du BDS"), default=False)
|
||||
|
||||
has_certificate = models.BooleanField(_("certificat médical"), default=False)
|
||||
certificate_file = models.FileField(
|
||||
_("fichier de certificat médical"),
|
||||
upload_to=get_certificate_filename,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
ASPSL_number = models.CharField(
|
||||
_("numéro AS PSL"), max_length=50, blank=True, null=True
|
||||
|
@ -75,6 +77,8 @@ class BDSProfile(models.Model):
|
|||
FFSU_number = models.CharField(
|
||||
_("numéro FFSU"), max_length=50, blank=True, null=True
|
||||
)
|
||||
|
||||
is_member = models.BooleanField(_("adhérent⋅e du BDS"), default=False)
|
||||
cotisation_period = models.CharField(
|
||||
_("inscription"), default="NO", choices=COTIZ_DURATION_CHOICES, max_length=3
|
||||
)
|
||||
|
@ -85,25 +89,6 @@ class BDSProfile(models.Model):
|
|||
_("type de cotisation"), choices=TYPE_COTIZ_CHOICES, max_length=9
|
||||
)
|
||||
|
||||
comments = models.TextField(
|
||||
_("commentaires"),
|
||||
blank=True,
|
||||
help_text=_(
|
||||
"Attention : l'utilisateur·ice dispose d'un droit d'accès aux données "
|
||||
"le/la concernant, dont le contenu de ce champ !"
|
||||
),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def expired_members(cls):
|
||||
now = timezone.now()
|
||||
qs = cls.objects.filter(is_member=True)
|
||||
if now.month > 1 and now.month < 7:
|
||||
return qs.filter(cotisation_period="SE1")
|
||||
elif now.month < 2 or now.month > 8:
|
||||
return qs.none()
|
||||
return qs
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Profil BDS")
|
||||
verbose_name_plural = _("Profils BDS")
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,42 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
viewBox="0 0 2560 2560"
|
||||
height="256"
|
||||
width="256"
|
||||
version="1.0">
|
||||
<g
|
||||
transform="translate(-220,50)"
|
||||
stroke="none"
|
||||
fill="#ffffff"
|
||||
id="layer101">
|
||||
<path
|
||||
id="path2"
|
||||
d="M 0,1230 V 0 H 1500 3000 V 1230 2460 H 1500 0 Z" />
|
||||
</g>
|
||||
<g
|
||||
transform="translate(-220,50)"
|
||||
stroke="none"
|
||||
fill="#3e2263"
|
||||
id="layer102">
|
||||
<path
|
||||
id="path5"
|
||||
d="M 220,1230 V -50 H 1500 2780 V 1230 2510 H 1500 220 Z m 1496,765 c 103,-17 204,-46 284,-83 l 55,-25 -40,-8 c -80,-16 -169,-10 -245,16 -123,42 -232,59 -385,59 -126,0 -278,-18 -341,-40 -13,-5 -16,-4 -9,4 14,15 166,60 254,76 102,19 315,19 427,1 z m -703,-217 c 15,-6 27,-13 27,-17 0,-4 -37,-25 -82,-47 -86,-43 -182,-120 -193,-155 -8,-26 32,-113 78,-167 44,-52 46,-62 10,-62 -39,1 -106,33 -165,80 -40,31 -54,38 -64,29 -21,-18 -17,-50 16,-116 57,-113 151,-199 259,-235 49,-16 51,-18 16,-13 -123,19 -260,151 -322,310 -15,39 -14,-81 1,-147 25,-107 55,-176 112,-251 49,-65 52,-73 38,-88 -21,-23 -104,-62 -216,-100 -51,-18 -97,-35 -102,-40 -4,-4 32,-10 80,-14 106,-9 256,13 317,48 l 39,22 56,-33 c 32,-18 114,-61 184,-95 80,-39 126,-67 123,-74 -6,-19 12,-16 19,3 9,24 28,5 22,-22 -7,-26 8,-34 18,-9 11,29 28,16 21,-18 -6,-30 -5,-31 10,-13 8,11 15,24 15,29 0,4 5,5 10,2 6,-3 8,-18 4,-33 -5,-26 -5,-26 10,-8 15,19 18,19 118,-12 113,-35 284,-72 329,-72 24,0 29,4 29,25 0,34 -36,125 -63,158 l -22,28 -59,-30 c -74,-39 -165,-43 -233,-10 -24,11 -43,25 -43,30 0,4 28,6 63,2 49,-4 71,-2 98,12 46,23 79,55 79,75 0,16 -48,66 -135,139 l -40,33 43,-23 c 55,-30 166,-121 188,-154 9,-13 13,-29 9,-36 -15,-23 -100,-69 -129,-69 -17,0 -38,-5 -46,-10 -12,-8 -10,-10 10,-10 49,1 104,19 149,51 l 45,31 24,-28 c 33,-40 72,-128 79,-180 10,-79 -25,-96 -233,-114 -84,-7 -148,-7 -218,0 -106,12 -269,51 -317,76 -28,14 -31,13 -62,-10 -56,-43 -167,-89 -225,-94 l -55,-5 6,29 c 2,16 14,55 26,86 21,57 27,112 15,142 -3,9 -34,38 -68,64 l -62,49 -104,7 c -166,12 -192,34 -83,70 34,12 65,24 68,28 4,4 -7,27 -24,52 -118,171 -124,402 -16,571 18,29 50,88 70,131 42,93 99,154 168,184 82,35 212,44 280,18 z m 540,-39 c 60,-16 70,-41 75,-196 l 5,-134 -39,3 -39,3 -5,114 c -4,93 -8,116 -22,125 -31,19 -41,-7 -47,-126 l -6,-113 -32,-3 c -41,-4 -44,6 -34,151 9,143 25,172 101,186 3,0 22,-4 43,-10 z m 322,-34 c 0,-30 0,-30 -64,-33 l -64,-3 7,-130 7,-129 h -35 -36 v 165 166 l 93,-3 92,-3 z m 115,-55 5,-84 18,27 c 21,33 39,34 60,5 15,-22 16,-18 16,60 l 1,82 h 35 35 l -2,-162 -3,-163 h -40 c -38,0 -41,2 -53,43 -16,49 -24,48 -42,-7 -12,-38 -16,-41 -50,-41 -34,0 -38,3 -44,31 -8,43 -8,284 1,293 4,4 19,6 33,4 24,-3 25,-6 30,-88 z m 370,-42 c 193,-243 228,-505 100,-759 -61,-120 -195,-260 -328,-343 -66,-41 -60,-26 13,33 36,29 92,85 125,126 182,230 209,500 75,753 -42,79 -45,89 -45,163 0,44 4,79 9,79 5,0 28,-24 51,-52 z M 1249,1314 c 76,-30 94,-102 41,-156 -27,-27 -29,-32 -17,-47 34,-40 25,-100 -19,-120 -30,-13 -143,-15 -164,-1 -11,7 -15,42 -18,164 l -4,156 23,9 c 37,15 115,13 158,-5 z m 571,-9 c 84,-43 61,-135 -43,-173 -46,-18 -52,-23 -52,-48 0,-39 30,-42 79,-9 l 37,25 -3,-41 c -4,-49 -32,-76 -90,-85 -32,-6 -41,-2 -68,24 -24,25 -30,39 -30,74 0,57 21,85 87,114 40,18 54,29 51,42 -5,29 -71,28 -111,-2 -19,-14 -36,-26 -39,-26 -11,0 -16,55 -7,72 24,45 131,63 189,33 z m -303,-12 c 56,-26 75,-65 71,-150 -3,-67 -6,-75 -38,-108 -43,-44 -94,-61 -146,-48 l -39,9 -3,144 c -1,79 0,150 2,157 8,19 110,17 153,-4 z" />
|
||||
<path
|
||||
id="path7"
|
||||
d="m 1503,633 c 4,-3 10,-3 14,0 3,4 0,7 -7,7 -7,0 -10,-3 -7,-7 z" />
|
||||
<path
|
||||
id="path9"
|
||||
d="m 1532,448 c 3,-7 15,-14 29,-16 23,-2 23,-2 5,13 -24,18 -39,20 -34,3 z" />
|
||||
<path
|
||||
id="path11"
|
||||
d="m 1140,1231 c 0,-45 10,-61 36,-61 26,0 64,32 64,53 0,23 -23,37 -62,37 -35,0 -38,-2 -38,-29 z" />
|
||||
<path
|
||||
id="path13"
|
||||
d="m 1140,1070 c 0,-35 17,-45 56,-36 20,5 25,12 22,34 -3,23 -8,27 -40,30 -36,3 -38,2 -38,-28 z" />
|
||||
<path
|
||||
id="path15"
|
||||
d="m 1430,1151 c 0,-72 3,-91 14,-91 28,0 47,13 61,41 31,60 10,121 -47,135 l -28,6 z" />
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 4 KiB |
|
@ -1,7 +0,0 @@
|
|||
$(function () {
|
||||
// Close notifications when delete button is pressed
|
||||
$(".notification .delete").on("click", function () {
|
||||
$(this).parent().remove();
|
||||
});
|
||||
|
||||
});
|
|
@ -1,152 +0,0 @@
|
|||
// Compilation command :
|
||||
// sass -I shared/static/src/ --watch bds/static/src/sass/bds.scss bds/static/bds/css/bds.css --style compressed
|
||||
|
||||
$text: black;
|
||||
|
||||
@import "bulma/bulma.sass";
|
||||
|
||||
$primary_color: #3e2263;
|
||||
$background_color: #ddcecc;
|
||||
|
||||
html, body {
|
||||
background: $background_color;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #a82305;
|
||||
}
|
||||
|
||||
/* header */
|
||||
|
||||
#search-bar {
|
||||
background-color: $primary_color;
|
||||
padding: 0 1em;
|
||||
margin-bottom: 0;
|
||||
|
||||
#logout-mobile {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@include mobile {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
#logout-mobile {
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#logout {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#search-input {
|
||||
flex: 0 1 100%;
|
||||
}
|
||||
}
|
||||
|
||||
// Workaround : `justify-content : <left/right>` pas encore supporté
|
||||
// Voir https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content
|
||||
& :first-child, & :last-child {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
& :last-child {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
input {
|
||||
border-radius: 0;
|
||||
margin: 10px 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Autocomplétion du BDS */
|
||||
|
||||
.highlight {
|
||||
text-decoration: underline;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.yourlabs-autocomplete {
|
||||
ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
li {
|
||||
height: 2em;
|
||||
line-height: 2em;
|
||||
padding: 0;
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
li.hilight {
|
||||
background: #e8554e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.autocomplete-item {
|
||||
display: block;
|
||||
width: 480px;
|
||||
height: 100%;
|
||||
padding: 2px 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.autocomplete-header {
|
||||
background: #b497e1;
|
||||
}
|
||||
|
||||
.autocomplete-value, .autocomplete-new, .autocomplete-more {
|
||||
background: white;
|
||||
}
|
||||
|
||||
/* --- Forms --- */
|
||||
|
||||
$button_color: lighten($primary_color, 10);
|
||||
|
||||
input[type="submit"] {
|
||||
background-color: $button_color;
|
||||
color: findColorInvert($button_color);
|
||||
|
||||
&:hover {
|
||||
background-color: $primary_color;
|
||||
color: findColorInvert($primary_color);
|
||||
}
|
||||
}
|
||||
|
||||
.button.is-primary {
|
||||
background-color: $button_color;
|
||||
color: findColorInvert($button_color);
|
||||
|
||||
&:hover {
|
||||
background-color: $primary_color;
|
||||
color: findColorInvert($primary_color);
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Message styling --- */
|
||||
|
||||
.notification {
|
||||
padding: 0.5em 0;
|
||||
font-size: 1.2em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* --- Modals --- */
|
||||
|
||||
.modal-card-head {
|
||||
background-color: $primary_color;
|
||||
|
||||
.modal-card-title {
|
||||
color: findColorInvert($primary_color);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
{% load static %}
|
||||
{% load bulma_utils %}
|
||||
{% load staticfiles %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -11,40 +10,14 @@
|
|||
|
||||
{# CSS #}
|
||||
<link rel="stylesheet" href="{% static "bds/css/bds.css" %}">
|
||||
<link type="text/css" rel="stylesheet" href="{% static 'vendor/font-awesome/css/font-awesome.min.css' %}">
|
||||
|
||||
{# Javascript #}
|
||||
<script src="{% static 'vendor/jquery/jquery-3.3.1.min.js' %}"></script>
|
||||
<script src="{% static "vendor/jquery/jquery.autocomplete-light.min.js" %}"></script>
|
||||
<script src="{% static 'bds/js/bds.js' %}"></script>
|
||||
|
||||
{% block extra_head %}{% endblock extra_head %}
|
||||
</head>
|
||||
<body>
|
||||
{% include "bds/nav.html" %}
|
||||
{% block layout %}
|
||||
<div class="columns">
|
||||
<div class="column is-two-thirds is-offset-2">
|
||||
<section class="section">
|
||||
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="notification is-{{ message.level_tag|bulma_message_tag }}">
|
||||
{% if 'safe' in message.tags %}
|
||||
{{ message|safe }}
|
||||
{% else %}
|
||||
{{ message }}
|
||||
{% endif %}
|
||||
<button class="delete"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock layout %}
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
{% extends "bds/base.html" %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1 class="title">Liste des adhésions expirées</h1>
|
||||
|
||||
{% if object_list %}
|
||||
<div class="content">
|
||||
<ul>
|
||||
{% for p in object_list %}
|
||||
<li>{{ p.user.first_name }} {{ p.user.last_name }} ({{ p.user.username }}), {{ p.get_cotisation_period_display }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="buttons is-centered">
|
||||
<a class="button is-danger" href="{% url 'bds:members.reset' %}">Réinitialiser les adhésions expirées</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
|
@ -1,16 +0,0 @@
|
|||
<div class="control">
|
||||
{% if field.auto_id %}
|
||||
<label class="checkbox {% if field.field.required %}{{ form.required_css_class }}{% endif %}">
|
||||
{{ field }} {{ field.label }}
|
||||
</label>
|
||||
{% endif %}
|
||||
{% for error in field.errors %}
|
||||
<span class="help is-danger {{ form.error_css_class }}">{{ error }}</span>
|
||||
{% endfor %}
|
||||
|
||||
{% if field.help_text %}
|
||||
<p class="help">
|
||||
{{ field.help_text|safe }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,33 +0,0 @@
|
|||
{% load bulma_utils %}
|
||||
|
||||
<div class="field">
|
||||
{% if field|is_checkbox %}
|
||||
|
||||
{% include "bds/forms/checkbox.html" with field=field %}
|
||||
|
||||
{% elif field|is_radio %}
|
||||
|
||||
{% include "bds/forms/radio.html" with field=field %}
|
||||
|
||||
{% elif field|is_input %}
|
||||
|
||||
{% include "bds/forms/input.html" with field=field %}
|
||||
|
||||
{% elif field|is_textarea %}
|
||||
|
||||
{% include "bds/forms/textarea.html" with field=field %}
|
||||
|
||||
{% elif field|is_select %}
|
||||
|
||||
{% include "bds/forms/select.html" with field=field %}
|
||||
|
||||
{% elif field|is_file %}
|
||||
|
||||
{% include "bds/forms/file.html" with field=field %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% include "bds/forms/other.html" with field=field %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,31 +0,0 @@
|
|||
{% load bulma_utils %}
|
||||
{% load i18n %}
|
||||
|
||||
<label class="label {% if field.field.required %}{{ form.required_css_class }}{% endif %}">
|
||||
{{ field.label }}
|
||||
</label>
|
||||
|
||||
<div class="control">
|
||||
|
||||
<label class="file-label">
|
||||
{{ field|bulmafy:'file-input' }}
|
||||
<span class="file-cta">
|
||||
<span class="file-icon">
|
||||
<i class="fa fa-upload"></i>
|
||||
</span>
|
||||
<span class="file-label">
|
||||
{% trans "Choisissez un fichier..." %}
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
{% for error in field.errors %}
|
||||
<span class="help is-danger {{ form.error_css_class }}">{{ error }}</span>
|
||||
{% endfor %}
|
||||
|
||||
{% if field.help_text %}
|
||||
<p class="help">
|
||||
{{ field.help_text|safe }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,22 +0,0 @@
|
|||
{% if errors %}
|
||||
{% if form.non_field_errors %}
|
||||
<div class="message is-danger">
|
||||
<div class="message-header">
|
||||
<button class="delete" aria-label="delete"></button>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
{% for non_field_error in form.non_field_errors %}
|
||||
{{ non_field_error }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% for field in form.hidden_fields %}
|
||||
{{ field }}
|
||||
{% endfor %}
|
||||
|
||||
{% for field in form.visible_fields %}
|
||||
{% include 'bds/forms/field.html' %}
|
||||
{% endfor %}
|
|
@ -1,19 +0,0 @@
|
|||
{% load bulma_utils %}
|
||||
|
||||
<label class="label {% if field.field.required %}{{ form.required_css_class }}{% endif %}">
|
||||
{{ field.label }}
|
||||
</label>
|
||||
|
||||
<div class="control">
|
||||
{{ field|bulmafy:'input' }}
|
||||
|
||||
{% for error in field.errors %}
|
||||
<span class="help is-danger {{ form.error_css_class }}">{{ error }}</span>
|
||||
{% endfor %}
|
||||
|
||||
{% if field.help_text %}
|
||||
<p class="help">
|
||||
{{ field.help_text|safe }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,19 +0,0 @@
|
|||
{% if field.auto_id %}
|
||||
<label class="label {% if field.field.required %}{{ form.required_css_class }}{% endif %}" for="{{ field.auto_id }}">
|
||||
{{ field.label }}
|
||||
</label>
|
||||
{% endif %}
|
||||
|
||||
<div class="control {% if field|is_multiple_checkbox %}multiple-checkbox{% endif %}">
|
||||
{{ field }}
|
||||
|
||||
{% for error in field.errors %}
|
||||
<span class="help is-danger {{ form.error_css_class }}">{{ error }}</span>
|
||||
{% endfor %}
|
||||
|
||||
{% if field.help_text %}
|
||||
<p class="help">
|
||||
{{ field.help_text|safe }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,24 +0,0 @@
|
|||
{% if field.auto_id %}
|
||||
<label class="label {% if field.field.required %}{{ form.required_css_class }}{% endif %}">
|
||||
{{ field.label }}
|
||||
</label>
|
||||
{% endif %}
|
||||
|
||||
<div class="control">
|
||||
{% for choice in field %}
|
||||
<label class="radio">
|
||||
{{ choice.tag }}
|
||||
{{ choice.choice_label }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
|
||||
{% for error in field.errors %}
|
||||
<span class="help is-danger {{ form.error_css_class }}">{{ error }}</span>
|
||||
{% endfor %}
|
||||
|
||||
{% if field.help_text %}
|
||||
<p class="help">
|
||||
{{ field.help_text|safe }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,21 +0,0 @@
|
|||
{% load bulma_utils %}
|
||||
|
||||
<label class="label {% if field.field.required %}{{ form.required_css_class }}{% endif %}">
|
||||
{{ field.label }}
|
||||
</label>
|
||||
|
||||
<div class="control">
|
||||
<span class="select{% if field|is_multiple_select %} is-multiple{% endif %}{% if field.errors|length > 0 %} is-danger{% endif %}">
|
||||
{{ field }}
|
||||
</span>
|
||||
|
||||
{% for error in field.errors %}
|
||||
<span class="help is-danger {{ form.error_css_class }}">{{ error }}</span>
|
||||
{% endfor %}
|
||||
|
||||
{% if field.help_text %}
|
||||
<p class="help">
|
||||
{{ field.help_text|safe }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,19 +0,0 @@
|
|||
{% load bulma_utils %}
|
||||
|
||||
<label class="label {% if field.field.required %}{{ form.required_css_class }}{% endif %}">
|
||||
{{ field.label }}
|
||||
</label>
|
||||
|
||||
<div class="control">
|
||||
{{ field|bulmafy:'textarea' }}
|
||||
|
||||
{% for error in field.errors %}
|
||||
<span class="help is-danger {{ form.error_css_class }}">{{ error }}</span>
|
||||
{% endfor %}
|
||||
|
||||
{% if field.help_text %}
|
||||
<p class="help">
|
||||
{{ field.help_text|safe }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,62 +1,22 @@
|
|||
{% extends "bds/base.html" %}
|
||||
{% load bulma_utils %}
|
||||
|
||||
{% block layout %}
|
||||
<div class="columns">
|
||||
<div class="column is-2">
|
||||
<section class="section">
|
||||
<div class="box">
|
||||
<div class="content has-text-centered">
|
||||
<h1>{{ member_count }}</h1>
|
||||
adhérent·e·s
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="column is-two-thirds">
|
||||
<section class="section">
|
||||
{% block content %}
|
||||
<div style="width: 60%; margin: auto; padding-top: 2em;">
|
||||
Bienvenue sur GestioBDS !
|
||||
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="notification is-{{ message.level_tag|bulma_message_tag }}">
|
||||
{% if 'safe' in message.tags %}
|
||||
{{ message|safe }}
|
||||
{% else %}
|
||||
{{ message }}
|
||||
{% endif %}
|
||||
<button class="delete"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<div class="container">
|
||||
Bienvenue sur GestioBDS !
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<a class=button href="{% url 'bds:export.members' %}">Télécharger la liste des membres (CSV)</a>
|
||||
|
||||
<a class=button href="{% url 'bds:members.expired' %}">Liste des adhésions expirées ({{ nb_expired }})</a>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
Le site est encore en développement.
|
||||
<br>
|
||||
Suivez notre avancement sur
|
||||
<a href="https://git.eleves.ens.fr/klub-dev-ens/gestioCOF/merge_requests?milestone_title=Int%C3%A9gration+du+BDS">
|
||||
cette milestone</a> sur le gitlab de l'ENS.
|
||||
<br>
|
||||
Faites vos remarques par mail à
|
||||
<a href="mailto:klub-dev@ens.fr"><tt>klub-dev@ens.fr</tt></a>
|
||||
ou en ouvrant une
|
||||
<a href="#https://git.eleves.ens.fr/klub-dev-ens/gestioCOF/issues?milestone_title=Int%C3%A9gration+du+BDS">
|
||||
issue</a>.
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
Le site est encore en développement.
|
||||
<br>
|
||||
Suivez notre avancement sur
|
||||
<a href="https://git.eleves.ens.fr/klub-dev-ens/gestioCOF/merge_requests?milestone_title=Int%C3%A9gration+du+BDS">
|
||||
cette milestone</a> sur le gitlab de l'ENS.
|
||||
<br>
|
||||
Faites vos remarques par mail à
|
||||
<a href="mailto:klub-dev@ens.fr"><tt>klub-dev@ens.fr</tt></a>
|
||||
ou en ouvrant une
|
||||
<a href="#https://git.eleves.ens.fr/klub-dev-ens/gestioCOF/issues?milestone_title=Int%C3%A9gration+du+BDS">
|
||||
issue</a>.
|
||||
</div>
|
||||
{% endblock layout %}
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,26 +1,13 @@
|
|||
{% load i18n %}
|
||||
{% load static %}
|
||||
|
||||
<nav id="search-bar" class="level">
|
||||
<div class="level-item" id="logo">
|
||||
<figure class="image is-64x64">
|
||||
<a href="{% url "bds:home" %}">
|
||||
<img src="{% static "bds/images/logo_square.svg" %}" alt="bds-logo">
|
||||
</a>
|
||||
</figure>
|
||||
</div>
|
||||
<nav id="search-bar">
|
||||
<a href="{% url "bds:home" %}">
|
||||
<img src="{% static "bds/images/logo.svg" %}" alt="bds-logo">
|
||||
</a>
|
||||
|
||||
<div class="level-item" id="logout-mobile">
|
||||
<figure class="image is-64x64">
|
||||
<a href="{% url 'authens:logout' %}">
|
||||
<img src="{% static "bds/images/logout.svg" %}" alt="logout">
|
||||
</a>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<div class="level-item" id="search-input">
|
||||
<div>
|
||||
<input
|
||||
class="input"
|
||||
type="text"
|
||||
name="q"
|
||||
id="search_autocomplete"
|
||||
|
@ -29,13 +16,9 @@
|
|||
<div class="yourlabs-autocomplete"></div>
|
||||
</div>
|
||||
|
||||
<div class="level-item" id="logout">
|
||||
<figure class="image is-64x64">
|
||||
<a href="{% url 'authens:logout' %}">
|
||||
<img src="{% static "bds/images/logout.svg" %}" alt="logout">
|
||||
</a>
|
||||
</figure>
|
||||
</div>
|
||||
<a href="#TODO">
|
||||
<img src="{% static "bds/images/logout.svg" %}" alt="logout">
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{% endif %}
|
||||
</li>
|
||||
<li class="autocomplete-new">
|
||||
<a class="autocomplete-item" href="{% url "bds:user.create" %}">
|
||||
<a class="autocomplete-item" href="#TODO">
|
||||
{% trans "Créer un compte" %}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
{% extends "bds/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% for form in forms.values %}
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="notification is-danger">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
<h1 class="title">{% trans "Création d'un profil" %}</h1>
|
||||
|
||||
<div class="container">
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{% for form in forms.values %}
|
||||
{% include "bds/forms/form.html" with form=form errors=False %}
|
||||
{% endfor %}
|
||||
|
||||
<div class="field">
|
||||
<p class="control">
|
||||
<input class="button is-fullwidth" type="submit" value="Enregistrer">
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -1,104 +0,0 @@
|
|||
{% extends "bds/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% for form in forms.values %}
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="notification is-danger">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
<h1 class="title">{% trans "Modification du profil " %}{{ view.user.username }}</h1>
|
||||
|
||||
<div class="container">
|
||||
<form method="post" action="" id="user-update-form">
|
||||
{% csrf_token %}
|
||||
|
||||
{% for form in forms.values %}
|
||||
{% include "bds/forms/form.html" with form=form errors=False %}
|
||||
{% endfor %}
|
||||
</form>
|
||||
|
||||
<form method="post" action="{% url 'bds:user.delete' view.user.pk %}" id="user-delete-form">
|
||||
{% csrf_token %}
|
||||
</form>
|
||||
|
||||
<div class="columns is-gapless mt-5">
|
||||
<div class="column is-5">
|
||||
<button id="user-update-button" class="button is-fullwidth is-primary">Enregistrer</button>
|
||||
</div>
|
||||
<div class="column is-2">
|
||||
</div>
|
||||
<div class="column is-5">
|
||||
<button id="user-delete-button" class="button is-fullwidth is-danger">Supprimer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hidden by default -->
|
||||
<div id="confirm-delete-modal" class="modal">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-card">
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">Confirmer la suppression</p>
|
||||
<button id="modal-close" class="delete" aria-label="close"></button>
|
||||
</header>
|
||||
<section class="modal-card-body">
|
||||
Voulez-vous réellement supprimer ce compte ? Attention, cette opération est irréversible !
|
||||
</section>
|
||||
<footer class="modal-card-foot">
|
||||
<button id="confirm-delete-button" class="button is-primary">Supprimer</button>
|
||||
<button id="cancel-delete-button" class="button">Annuler</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
"use strict";
|
||||
|
||||
// Adapted from https://bulma.io/lib/main.js
|
||||
function openModal(target) {
|
||||
$(document).addClass('is-clipped');
|
||||
$(`#${target}`).addClass('is-active');
|
||||
}
|
||||
|
||||
function closeModals() {
|
||||
$(document).removeClass('is-clipped');
|
||||
$(".modal").removeClass('is-active');
|
||||
}
|
||||
|
||||
// Si on clique sur enregistrer, ça marche
|
||||
$("#user-update-button").on("click", function() {
|
||||
$("#user-update-form").submit();
|
||||
})
|
||||
|
||||
// Si on clique sur supprimer, confirmation demandée
|
||||
$("#user-delete-button").on("click", function() {
|
||||
openModal("confirm-delete-modal");
|
||||
});
|
||||
|
||||
$(".modal-background, #modal-close, #cancel-delete-button").on("click", closeModals);
|
||||
|
||||
$("#confirm-delete-button").on("click", function() {
|
||||
$("#user-delete-form").submit();
|
||||
});
|
||||
|
||||
$(document).on("keydown", function(e) {
|
||||
if (e.key == "Escape") {
|
||||
closeModals();
|
||||
}
|
||||
|
||||
if (e.key == "Enter") {
|
||||
$("#user-update-form").submit();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
|
@ -1,74 +0,0 @@
|
|||
from django import forms, template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def widget_type(field):
|
||||
return field.field.widget
|
||||
|
||||
|
||||
@register.filter
|
||||
def is_select(field):
|
||||
return isinstance(field.field.widget, forms.Select)
|
||||
|
||||
|
||||
@register.filter
|
||||
def is_multiple_select(field):
|
||||
return isinstance(field.field.widget, forms.SelectMultiple)
|
||||
|
||||
|
||||
@register.filter
|
||||
def is_textarea(field):
|
||||
return isinstance(field.field.widget, forms.Textarea)
|
||||
|
||||
|
||||
@register.filter
|
||||
def is_input(field):
|
||||
return isinstance(
|
||||
field.field.widget,
|
||||
(
|
||||
forms.TextInput,
|
||||
forms.NumberInput,
|
||||
forms.EmailInput,
|
||||
forms.PasswordInput,
|
||||
forms.URLInput,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@register.filter
|
||||
def is_checkbox(field):
|
||||
return isinstance(field.field.widget, forms.CheckboxInput)
|
||||
|
||||
|
||||
@register.filter
|
||||
def is_multiple_checkbox(field):
|
||||
return isinstance(field.field.widget, forms.CheckboxSelectMultiple)
|
||||
|
||||
|
||||
@register.filter
|
||||
def is_radio(field):
|
||||
return isinstance(field.field.widget, forms.RadioSelect)
|
||||
|
||||
|
||||
@register.filter
|
||||
def is_file(field):
|
||||
return isinstance(field.field.widget, forms.FileInput)
|
||||
|
||||
|
||||
@register.filter
|
||||
def bulmafy(field, css_class):
|
||||
if len(field.errors) > 0:
|
||||
css_class += " is-danger"
|
||||
field_classes = field.field.widget.attrs.get("class", "")
|
||||
field_classes += f" {css_class}"
|
||||
return field.as_widget(attrs={"class": field_classes})
|
||||
|
||||
|
||||
@register.filter
|
||||
def bulma_message_tag(tag):
|
||||
if tag == "error":
|
||||
return "danger"
|
||||
|
||||
return tag
|
|
@ -1,76 +0,0 @@
|
|||
from unittest import mock
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.test import Client, TestCase
|
||||
from django.urls import reverse, reverse_lazy
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
def give_bds_buro_permissions(user: User) -> None:
|
||||
perm = Permission.objects.get(content_type__app_label="bds", codename="is_team")
|
||||
user.user_permissions.add(perm)
|
||||
|
||||
|
||||
def login_url(next=None):
|
||||
login_url = reverse_lazy(settings.LOGIN_URL)
|
||||
if next is None:
|
||||
return login_url
|
||||
else:
|
||||
return "{}?next={}".format(login_url, next)
|
||||
|
||||
|
||||
class TestHomeView(TestCase):
|
||||
@mock.patch("gestioncof.signals.messages")
|
||||
def test_get(self, mock_messages):
|
||||
user = User.objects.create_user(username="random_user")
|
||||
give_bds_buro_permissions(user)
|
||||
self.client.force_login(
|
||||
user, backend="django.contrib.auth.backends.ModelBackend"
|
||||
)
|
||||
resp = self.client.get(reverse("bds:home"))
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
|
||||
class TestRegistrationView(TestCase):
|
||||
@mock.patch("gestioncof.signals.messages")
|
||||
def test_get_autocomplete(self, mock_messages):
|
||||
user = User.objects.create_user(username="toto")
|
||||
url = reverse("bds:autocomplete") + "?q=foo"
|
||||
client = Client()
|
||||
|
||||
# Anonymous GET
|
||||
resp = client.get(url)
|
||||
self.assertRedirects(resp, login_url(next=url))
|
||||
|
||||
# Logged-in but unprivileged GET
|
||||
client.force_login(user, backend="django.contrib.auth.backends.ModelBackend")
|
||||
resp = client.get(url)
|
||||
self.assertEqual(resp.status_code, 403)
|
||||
|
||||
# Burô user GET
|
||||
give_bds_buro_permissions(user)
|
||||
resp = client.get(url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
@mock.patch("gestioncof.signals.messages")
|
||||
def test_get(self, mock_messages):
|
||||
user = User.objects.create_user(username="toto")
|
||||
url = reverse("bds:user.update", args=(user.id,))
|
||||
client = Client()
|
||||
|
||||
# Anonymous GET
|
||||
resp = client.get(url)
|
||||
self.assertRedirects(resp, login_url(next=url))
|
||||
|
||||
# Logged-in but unprivileged GET
|
||||
client.force_login(user, backend="django.contrib.auth.backends.ModelBackend")
|
||||
resp = client.get(url)
|
||||
self.assertEqual(resp.status_code, 403)
|
||||
|
||||
# Burô user GET
|
||||
give_bds_buro_permissions(user)
|
||||
resp = client.get(url)
|
||||
self.assertEqual(resp.status_code, 200)
|
15
bds/urls.py
15
bds/urls.py
|
@ -6,19 +6,4 @@ app_name = "bds"
|
|||
urlpatterns = [
|
||||
path("", views.Home.as_view(), name="home"),
|
||||
path("autocomplete", views.BDSAutocompleteView.as_view(), name="autocomplete"),
|
||||
path("user/update/<int:pk>", views.UserUpdateView.as_view(), name="user.update"),
|
||||
path("user/create/", views.UserCreateView.as_view(), name="user.create"),
|
||||
path(
|
||||
"user/create/<slug:clipper>",
|
||||
views.UserCreateView.as_view(),
|
||||
name="user.create.fromclipper",
|
||||
),
|
||||
path("user/delete/<int:pk>", views.UserDeleteView.as_view(), name="user.delete"),
|
||||
path("members", views.export_members, name="export.members"),
|
||||
path(
|
||||
"members/expired",
|
||||
views.ResetMembershipListView.as_view(),
|
||||
name="members.expired",
|
||||
),
|
||||
path("members/reset", views.ResetMembershipView.as_view(), name="members.reset"),
|
||||
]
|
||||
|
|
174
bds/views.py
174
bds/views.py
|
@ -1,23 +1,9 @@
|
|||
import csv
|
||||
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import DeleteView, ListView, RedirectView, TemplateView
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from bds.autocomplete import bds_search
|
||||
from bds.forms import ProfileForm, UserForm, UserFromClipperForm, UserFromScratchForm
|
||||
from bds.mixins import MultipleFormView, StaffRequiredMixin
|
||||
from bds.models import BDSProfile
|
||||
from bds.mixins import StaffRequiredMixin
|
||||
from shared.views import AutocompleteView
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class BDSAutocompleteView(StaffRequiredMixin, AutocompleteView):
|
||||
template_name = "bds/search_results.html"
|
||||
|
@ -26,159 +12,3 @@ class BDSAutocompleteView(StaffRequiredMixin, AutocompleteView):
|
|||
|
||||
class Home(StaffRequiredMixin, TemplateView):
|
||||
template_name = "bds/home.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["member_count"] = BDSProfile.objects.filter(is_member=True).count()
|
||||
context["nb_expired"] = BDSProfile.expired_members().count()
|
||||
return context
|
||||
|
||||
|
||||
class UserUpdateView(StaffRequiredMixin, MultipleFormView):
|
||||
template_name = "bds/user_update.html"
|
||||
|
||||
form_classes = {
|
||||
"user": UserForm,
|
||||
"profile": ProfileForm,
|
||||
}
|
||||
|
||||
def get_user_initial(self):
|
||||
return {"is_buro": self.get_user_instance().has_perm("bds.is_team")}
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.user = get_object_or_404(User, pk=self.kwargs["pk"])
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_user_instance(self):
|
||||
return self.user
|
||||
|
||||
def get_profile_instance(self):
|
||||
return getattr(self.user, "bds", None)
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse("bds:user.update", args=(self.user.pk,))
|
||||
|
||||
def form_valid(self, forms):
|
||||
user = forms["user"].save()
|
||||
profile = forms["profile"].save(commit=False)
|
||||
perm = Permission.objects.get(content_type__app_label="bds", codename="is_team")
|
||||
if forms["user"].cleaned_data["is_buro"]:
|
||||
user.user_permissions.add(perm)
|
||||
else:
|
||||
user.user_permissions.remove(perm)
|
||||
profile.user = user
|
||||
profile.save()
|
||||
messages.success(self.request, _("Profil mis à jour avec succès !"))
|
||||
|
||||
return super().form_valid(forms)
|
||||
|
||||
def form_invalid(self, forms):
|
||||
messages.error(self.request, _("Veuillez corriger les erreurs ci-dessous"))
|
||||
return super().form_invalid(forms)
|
||||
|
||||
|
||||
class UserCreateView(StaffRequiredMixin, MultipleFormView):
|
||||
template_name = "bds/user_create.html"
|
||||
|
||||
def get_form_classes(self):
|
||||
profile_class = ProfileForm
|
||||
|
||||
if "clipper" in self.kwargs:
|
||||
user_class = UserFromClipperForm
|
||||
else:
|
||||
user_class = UserFromScratchForm
|
||||
|
||||
return {"user": user_class, "profile": profile_class}
|
||||
|
||||
def get_user_initial(self):
|
||||
if "clipper" in self.kwargs:
|
||||
clipper = self.kwargs["clipper"]
|
||||
email = self.request.GET.get("mail", "{}@clipper.ens.fr".format(clipper))
|
||||
fullname = self.request.GET.get("fullname", None)
|
||||
|
||||
if fullname:
|
||||
# Heuristique : le premier mot est le prénom
|
||||
first_name = fullname.split()[0]
|
||||
last_name = " ".join(fullname.split()[1:])
|
||||
else:
|
||||
first_name = ""
|
||||
last_name = ""
|
||||
|
||||
return {
|
||||
"username": clipper,
|
||||
"email": email,
|
||||
"first_name": first_name,
|
||||
"last_name": last_name,
|
||||
}
|
||||
else:
|
||||
return {}
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse("bds:user.update", args=(self.user.pk,))
|
||||
|
||||
def form_valid(self, forms):
|
||||
# On redéfinit self.user pour get_success_url
|
||||
self.user = forms["user"].save()
|
||||
profile = forms["profile"].save(commit=False)
|
||||
profile.user = self.user
|
||||
profile.save()
|
||||
messages.success(self.request, _("Profil créé avec succès !"))
|
||||
|
||||
return super().form_valid(forms)
|
||||
|
||||
def form_invalid(self, forms):
|
||||
messages.error(self.request, _("Veuillez corriger les erreurs ci-dessous"))
|
||||
return super().form_invalid(forms)
|
||||
|
||||
|
||||
class UserDeleteView(StaffRequiredMixin, DeleteView):
|
||||
model = User
|
||||
success_url = reverse_lazy("bds:home")
|
||||
success_message = "Profil supprimé avec succès !"
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
# SuccessMessageMixin does not work with DeleteView, see :
|
||||
# https://code.djangoproject.com/ticket/21926
|
||||
messages.success(request, self.success_message)
|
||||
|
||||
return super().delete(request, *args, **kwargs)
|
||||
|
||||
|
||||
class ResetMembershipListView(StaffRequiredMixin, ListView):
|
||||
model = BDSProfile
|
||||
template_name = "bds/expired_members.html"
|
||||
|
||||
def get_queryset(self):
|
||||
return BDSProfile.expired_members()
|
||||
|
||||
|
||||
class ResetMembershipView(StaffRequiredMixin, RedirectView):
|
||||
url = reverse_lazy("bds:members.expired")
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
qs = BDSProfile.expired_members()
|
||||
nb = qs.count()
|
||||
|
||||
qs.update(cotisation_period="NO", is_member=False, mails_bds=False)
|
||||
|
||||
messages.success(request, f"{nb} adhésions réinitialisées")
|
||||
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
|
||||
@permission_required("bds.is_team")
|
||||
def export_members(request):
|
||||
response = HttpResponse(content_type="text/csv")
|
||||
response["Content-Disposition"] = "attachment; filename=membres_bds.csv"
|
||||
|
||||
writer = csv.writer(response)
|
||||
for profile in BDSProfile.objects.filter(is_member=True).all():
|
||||
user = profile.user
|
||||
bits = [
|
||||
user.username,
|
||||
user.get_full_name(),
|
||||
user.email,
|
||||
]
|
||||
writer.writerow([str(bit) for bit in bits])
|
||||
|
||||
return response
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue