diff --git a/.gitignore b/.gitignore index f12190af..ab791b2e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,8 @@ venv/ /src media/ *.log +*.sqlite3 + +# PyCharm +.idea +.cache diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f2635b7b..5080ef32 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,24 +1,20 @@ services: - - mysql:latest + - postgres:latest - redis:latest variables: # GestioCOF settings - DJANGO_SETTINGS_MODULE: "cof.settings_dev" - DBNAME: "cof_gestion" - DBUSER: "cof_gestion" - DBPASSWD: "cof_password" - DBHOST: "mysql" + DJANGO_SETTINGS_MODULE: "cof.settings.prod" + DBHOST: "postgres" REDIS_HOST: "redis" # Cached packages PYTHONPATH: "$CI_PROJECT_DIR/vendor/python" - # mysql service configuration - MYSQL_DATABASE: "$DBNAME" - MYSQL_USER: "$DBUSER" - MYSQL_PASSWORD: "$DBPASSWD" - MYSQL_ROOT_PASSWORD: "root_password" + # postgres service configuration + POSTGRES_PASSWORD: "4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4" + POSTGRES_USER: "cof_gestion" + POSTGRES_DB: "cof_gestion" cache: @@ -29,13 +25,12 @@ cache: before_script: - mkdir -p vendor/{python,pip,apt} - - apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq mysql-client - - mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host="$DBHOST" - -e "GRANT ALL ON test_$DBNAME.* TO '$DBUSER'@'%'" + - apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client + - sed -E 's/^REDIS_HOST.*/REDIS_HOST = "redis"/' cof/settings/secret_example.py > cof/settings/secret.py # Remove the old test database if it has not been done yet - - mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host="$DBHOST" + - psql --username=cof_gestion --password="4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4" --host="$DBHOST" -e "DROP DATABASE test_$DBNAME" || true - - pip install --cache-dir vendor/pip -t vendor/python -r requirements-devel.txt + - pip install --cache-dir vendor/pip -t vendor/python -r requirements.txt test: stage: test diff --git a/README.md b/README.md index 1a3d575e..01f4ead2 100644 --- a/README.md +++ b/README.md @@ -66,119 +66,65 @@ car par défaut Django n'écoute que sur l'adresse locale de la machine virtuell or vous voudrez accéder à GestioCOF depuis votre machine physique. L'url à entrer dans le navigateur est `localhost:8000`. + #### Serveur de développement type production -Sur la VM Vagrant, un serveur apache est configuré pour servir GestioCOF de -façon similaire à la version en production : on utilise +Juste histoire de jouer, pas indispensable pour développer : + +La VM Vagrant héberge en plus un serveur nginx configuré pour servir GestioCOF +comme en production : on utilise [Daphne](https://github.com/django/daphne/) et `python manage.py runworker` -derrière un reverse-proxy apache. Le tout est monitoré par -[supervisor](http://supervisord.org/). +derrière un reverse-proxy nginx. Ce serveur se lance tout seul et est accessible en dehors de la VM à l'url -`localhost:8080`. Toutefois il ne se recharge pas tout seul lorsque le code -change, il faut relancer le worker avec `sudo supervisorctl restart worker` pour -visualiser la dernière version du code. +`localhost:8080/gestion/`. Toutefois il ne se recharge pas tout seul lorsque le +code change, il faut relancer le worker avec `sudo systemctl restart +worker.service` pour visualiser la dernière version du code. + ### Installation manuelle -Si vous optez pour une installation manuelle plutôt que d'utiliser Vagrant, il -est fortement conseillé d'utiliser un environnement virtuel pour Python. +Vous pouvez opter pour une installation manuelle plutôt que d'utiliser Vagrant, +il est fortement conseillé d'utiliser un environnement virtuel pour Python. -Il vous faudra installer pip, les librairies de développement de python, un -client et un serveur MySQL ainsi qu'un serveur redis ; sous Debian et dérivées -(Ubuntu, ...) : +Il vous faudra installer pip, les librairies de développement de python ainsi +que sqlite3, un moteur de base de données léger et simple d'utilisation. Sous +Debian et dérivées (Ubuntu, ...) : - sudo apt-get install python-pip python-dev libmysqlclient-dev redis-server + sudo apt-get install python3-pip python3-dev sqlite3 Si vous décidez d'utiliser un environnement virtuel Python (virtualenv; fortement conseillé), déplacez-vous dans le dossier où est installé GestioCOF (le dossier où se trouve ce README), et créez-le maintenant : - virtualenv env -p $(which python3) + python3 -m venv venv -L'option `-p` sert à préciser l'exécutable python à utiliser. Vous devez choisir -python3, si c'est la version de python par défaut sur votre système, ceci n'est -pas nécessaire. Pour l'activer, il faut faire +Pour l'activer, il faut faire - . env/bin/activate + . venv/bin/activate dans le même dossier. Vous pouvez maintenant installer les dépendances Python depuis le fichier `requirements-devel.txt` : + pip install -U pip pip install -r requirements-devel.txt -Copiez le fichier `cof/settings_dev.py` dans `cof/settings.py`. +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: -#### Installation avec MySQL + ln -s secret_example.py cof/settings/secret.py -Il faut maintenant installer MySQL. Si vous n'avez pas déjà MySQL installé sur -votre serveur, il faut l'installer ; sous Debian et dérivées (Ubuntu, ...) : - - sudo apt-get install mysql-server - -Il vous demandera un mot de passe pour le compte d'administration MySQL, -notez-le quelque part (ou n'en mettez pas, le serveur n'est accessible que -localement par défaut). Si vous utilisez une autre distribution, consultez la -documentation de votre distribution pour savoir comment changer ce mot de passe -et démarrer le serveur MySQL (c'est automatique sous Ubuntu). - -Vous devez alors créer un utilisateur local et une base `cof_gestion`, avec le -mot de passe de votre choix (remplacez `mot_de_passe`) : - - mysql -uroot -e "CREATE DATABASE cof_gestion; GRANT ALL PRIVILEGES ON cof_gestion.* TO 'cof_gestion'@'localhost' IDENTIFIER BY 'mot_de_passe'" - -Éditez maintenant le fichier `cof/settings.py` pour y intégrer ces changements ; -la définition de `DATABASES` doit ressembler à (à nouveau, remplacez -`mot_de_passe` de façon appropriée) : - - DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'cof_gestion', - 'USER': 'cof_gestion', - 'PASSWORD': 'mot_de_passe', - } - } - -#### Installation avec SQLite - -GestioCOF est installé avec MySQL sur la VM COF, et afin d'avoir un -environnement de développement aussi proche que possible de ce qui tourne en -vrai pour éviter les mauvaises surprises, il est conseillé d'utiliser MySQL sur -votre machine de développement également. Toutefois, GestioCOF devrait -fonctionner avec d'autres moteurs SQL, et certains préfèrent utiliser SQLite -pour sa légèreté et facilité d'installation. - -Si vous décidez d'utiliser SQLite, il faut l'installer ; sous Debian et dérivées : - - sudo apt-get install sqlite3 - -puis éditer le fichier `cof/settings.py` pour que la définition de `DATABASES` -ressemble à : - - DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } - } #### Fin d'installation -Il ne vous reste plus qu'à initialiser les modèles de Django avec la commande suivante : +Il ne vous reste plus qu'à initialiser les modèles de Django et peupler la base +de donnée avec les données nécessaires au bon fonctionnement de GestioCOF + des +données bidons bien pratiques pour développer avec la commande suivante : - python manage.py migrate - -Charger les mails indispensables au bon fonctionnement de GestioCOF : - - python manage.py syncmails - -Une base de donnée pré-remplie est disponible en lançant les commandes : - - python manage.py loaddata gestion sites accounts groups articles - python manage.py loaddevdata + bash provisioning/prepare_django.sh Vous êtes prêts à développer ! Lancer GestioCOF en faisant @@ -188,7 +134,7 @@ Vous êtes prêts à développer ! Lancer GestioCOF en faisant Pour mettre à jour les paquets Python, utiliser la commande suivante : - pip install --upgrade -r requirements.txt -r requirements-devel.txt + pip install --upgrade -r requirements-devel.txt Pour mettre à jour les modèles après une migration, il faut ensuite faire : @@ -197,6 +143,6 @@ Pour mettre à jour les modèles après une migration, il faut ensuite faire : ## Documentation utilisateur -Une brève documentation utilisateur pour se familiariser plus vite avec l'outil -est accessible sur le -[wiki](https://git.eleves.ens.fr/cof-geek/gestioCOF/wikis/home). +Une brève documentation utilisateur est accessible sur le +[wiki](https://git.eleves.ens.fr/cof-geek/gestioCOF/wikis/home) pour avoir une +idée de la façon dont le COF utilise GestioCOF. diff --git a/bda/__init__.py b/bda/__init__.py index e69de29b..8b137891 100644 --- a/bda/__init__.py +++ b/bda/__init__.py @@ -0,0 +1 @@ + diff --git a/bda/models.py b/bda/models.py index 0228b4c0..41462d70 100644 --- a/bda/models.py +++ b/bda/models.py @@ -7,11 +7,20 @@ from custommail.shortcuts import send_mass_custom_mail from django.contrib.sites.models import Site from django.db import models +from django.db.models import Count from django.contrib.auth.models import User from django.conf import settings from django.utils import timezone, formats +def get_generic_user(): + generic, _ = User.objects.get_or_create( + username="bda_generic", + defaults={"email": "bda@ens.fr", "first_name": "Bureau des arts"} + ) + return generic + + class Tirage(models.Model): title = models.CharField("Titre", max_length=300) ouverture = models.DateTimeField("Date et heure d'ouverture du tirage") @@ -96,32 +105,29 @@ class Spectacle(models.Model): Envoie un mail de rappel à toutes les personnes qui ont une place pour ce spectacle. """ - # On récupère la liste des participants - members = {} - for attr in Attribution.objects.filter(spectacle=self).all(): - member = attr.participant.user - if member.id in members: - members[member.id][1] = 2 - else: - members[member.id] = [member, 1] - # FIXME : faire quelque chose de ça, un utilisateur bda_generic ? - # # Pour le BdA - # members[0] = ['BdA', 1, 'bda@ens.fr'] - # members[-1] = ['BdA', 2, 'bda@ens.fr'] + # On récupère la liste des participants + le BdA + members = list( + User.objects + .filter(participant__attributions=self) + .annotate(nb_attr=Count("id")).order_by() + ) + bda_generic = get_generic_user() + bda_generic.nb_attr = 1 + members.append(bda_generic) # On écrit un mail personnalisé à chaque participant datatuple = [( 'bda-rappel', - {'member': member[0], 'nb_attr': member[1], 'show': self}, + {'member': member, "nb_attr": member.nb_attr, 'show': self}, settings.MAIL_DATA['rappels']['FROM'], - [member[0].email]) - for member in members.values() + [member.email]) + for member in members ] send_mass_custom_mail(datatuple) # On enregistre le fait que l'envoi a bien eu lieu self.rappel_sent = timezone.now() self.save() # On renvoie la liste des destinataires - return members.values() + return members @property def is_past(self): diff --git a/bda/templates/bda/mails-rappel.html b/bda/templates/bda/mails-rappel.html index 73625d1c..c10503b0 100644 --- a/bda/templates/bda/mails-rappel.html +++ b/bda/templates/bda/mails-rappel.html @@ -3,41 +3,46 @@ {% block realcontent %}
Attention, les mails ont déjà été envoyés le - {{ show.rappel_sent }}
- {% endif %} ++ Note : le template de ce mail peut être modifié à + cette adresse +
+ +{{ part }}- {% endfor %} + {% for part in exemple_mail_1place %} +
{{ part }}+ {% endfor %}
{{ part }}+
{{ part }}{% endfor %} + {% endblock %} diff --git a/bda/templates/bda-participants.html b/bda/templates/bda/participants.html similarity index 77% rename from bda/templates/bda-participants.html rename to bda/templates/bda/participants.html index 289d1761..85af4a2e 100644 --- a/bda/templates/bda-participants.html +++ b/bda/templates/bda/participants.html @@ -36,17 +36,26 @@
-{%for participant in participants %}{{participant.email}}, {%endfor%} --
+++ +{% if config.gestion_banner %} ++ ++ +{% spaceless %} + {% for participant in participants %}{{ participant.email }}, {% endfor %} + {% endspaceless %}++ ++ + + {% block extra_head %}{% endblock %} diff --git a/gestioncof/templates/gestioncof/banner_update.html b/gestioncof/templates/gestioncof/banner_update.html new file mode 100644 index 00000000..b2432eae --- /dev/null +++ b/gestioncof/templates/gestioncof/banner_update.html @@ -0,0 +1,23 @@ +{% extends "base_title.html" %} +{% load bootstrap %} +{% load i18n %} + +{% block page_size %}col-sm-8{%endblock%} + +{% block realcontent %} +{% spaceless %} {% for participant in participants %}{{participant.name}} : {{participant.nb_places}} places {% endfor %} -+ {% endspaceless %} +{% trans "Global configuration" %}
+ +{% endblock %} diff --git a/gestioncof/templates/gestioncof/base_header.html b/gestioncof/templates/gestioncof/base_header.html index a7e29eb7..21441875 100644 --- a/gestioncof/templates/gestioncof/base_header.html +++ b/gestioncof/templates/gestioncof/base_header.html @@ -16,6 +16,14 @@{% if user.first_name %}{{ user.first_name }}{% else %}{{ user.username }}{% endif %}, {% if user.profile.is_cof %}au COF{% else %}non-COF{% endif %}
+ + {{ config.gestion_banner }} ++{% endif %} + {% if messages %} {% for message in messages %}diff --git a/gestioncof/templates/home.html b/gestioncof/templates/home.html index 5f783a48..acc04f30 100644 --- a/gestioncof/templates/home.html +++ b/gestioncof/templates/home.html @@ -1,4 +1,5 @@ {% extends "gestioncof/base_header.html" %} +{% load wagtailcore_tags %} {% block homelink %} {% endblock %} @@ -55,7 +56,8 @@K-Fêt
-
- Page d'accueil
+ {# TODO: Since Django 1.9, we can store result with "as", allowing proper value management (if None) #} +- Page d'accueil
- Calendrier
{% if perms.kfet.is_team %}- K-Psul
diff --git a/gestioncof/urls.py b/gestioncof/urls.py index 9a562e7e..57c2e8f2 100644 --- a/gestioncof/urls.py +++ b/gestioncof/urls.py @@ -10,7 +10,7 @@ export_patterns = [ url(r'^mega/avecremarques$', views.export_mega_remarksonly), url(r'^mega/participants$', views.export_mega_participants), url(r'^mega/orgas$', views.export_mega_orgas), - url(r'^mega/(?P.+)$', views.export_mega_bytype), + # url(r'^mega/(?P .+)$', views.export_mega_bytype), url(r'^mega$', views.export_mega), ] diff --git a/gestioncof/views.py b/gestioncof/views.py index 457a99c4..c5701510 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import unicodecsv import uuid from datetime import timedelta @@ -9,12 +7,18 @@ from custommail.shortcuts import send_custom_mail from django.shortcuts import redirect, get_object_or_404, render from django.http import Http404, HttpResponse, HttpResponseForbidden from django.contrib.auth.decorators import login_required -from django.contrib.auth.views import login as django_login_view +from django.contrib.auth.views import ( + login as django_login_view, logout as django_logout_view, +) from django.contrib.auth.models import User from django.contrib.sites.models import Site +from django.core.urlresolvers import reverse_lazy +from django.views.generic import FormView from django.utils import timezone +from django.utils.translation import ugettext_lazy as _ from django.contrib import messages -import django.utils.six as six + +from django_cas_ng.views import logout as cas_logout_view from gestioncof.models import Survey, SurveyAnswer, SurveyQuestion, \ SurveyQuestionAnswer @@ -24,10 +28,11 @@ from gestioncof.models import EventCommentField, EventCommentValue, \ CalendarSubscription from gestioncof.models import CofProfile, Club from gestioncof.decorators import buro_required, cof_required -from gestioncof.forms import UserProfileForm, EventStatusFilterForm, \ - SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \ - RegistrationProfileForm, EventForm, CalendarForm, EventFormset, \ - RegistrationPassUserForm, ClubsForm +from gestioncof.forms import ( + UserProfileForm, EventStatusFilterForm, SurveyForm, SurveyStatusFilterForm, + RegistrationUserForm, RegistrationProfileForm, EventForm, CalendarForm, + EventFormset, RegistrationPassUserForm, ClubsForm, GestioncofConfigForm +) from bda.models import Tirage, Spectacle @@ -81,15 +86,21 @@ def login_ext(request): @login_required -def logout(request): - try: - profile = request.user.profile - except CofProfile.DoesNotExist: - profile, created = CofProfile.objects.get_or_create(user=request.user) - if profile.login_clipper: - return redirect("django_cas_ng.views.logout") +def logout(request, next_page=None): + if next_page is None: + next_page = request.GET.get('next', None) + + profile = getattr(request.user, 'profile', None) + + if profile and profile.login_clipper: + msg = _('Déconnexion de GestioCOF et CAS réussie. À bientôt {}.') + logout_view = cas_logout_view else: - return redirect("django.contrib.auth.views.logout") + msg = _('Déconnexion de GestioCOF réussie. À bientôt {}.') + logout_view = django_logout_view + + messages.success(request, msg.format(request.user.get_short_name())) + return logout_view(request, next_page=next_page) @login_required @@ -387,7 +398,6 @@ def registration_form2(request, login_clipper=None, username=None, elif not login_clipper: # new user user_form = RegistrationPassUserForm() - user_form.force_long_username() profile_form = RegistrationProfileForm() event_formset = EventFormset(events=events, prefix='events') clubs_form = ClubsForm() @@ -403,12 +413,8 @@ def registration_form2(request, login_clipper=None, username=None, def registration(request): if request.POST: request_dict = request.POST.copy() - # num ne peut pas être défini manuellement - if "num" in request_dict: - del request_dict["num"] member = None login_clipper = None - success = False # ----- # Remplissage des formulaires @@ -430,12 +436,10 @@ def registration(request): user_form = RegistrationUserForm(request_dict, instance=member) if member.profile.login_clipper: login_clipper = member.profile.login_clipper - else: - user_form.force_long_username() except User.DoesNotExist: - user_form.force_long_username() + pass else: - user_form.force_long_username() + pass # ----- # Validation des formulaires @@ -445,7 +449,6 @@ def registration(request): member = user_form.save() profile, _ = CofProfile.objects.get_or_create(user=member) was_cof = profile.is_cof - request_dict["num"] = profile.num # Maintenant on remplit le formulaire de profil profile_form = RegistrationProfileForm(request_dict, instance=profile) @@ -499,16 +502,18 @@ def registration(request): for club in clubs_form.cleaned_data['clubs']: club.membres.add(member) club.save() - success = True - # Messages - if success: - msg = ("L'inscription de {:s} ({:s}) a été " - "enregistrée avec succès" - .format(member.get_full_name(), member.email)) - if member.profile.is_cof: - msg += "Il est désormais membre du COF n°{:d} !".format( - member.profile.num) - messages.success(request, msg, extra_tags='safe') + + # --- + # Success + # --- + + msg = ("L'inscription de {:s} ({:s}) a été " + "enregistrée avec succès." + .format(member.get_full_name(), member.email)) + if profile.is_cof: + msg += "\nIl est désormais membre du COF n°{:d} !".format( + member.profile.id) + messages.success(request, msg, extra_tags='safe') return render(request, "gestioncof/registration_post.html", {"user_form": user_form, "profile_form": profile_form, @@ -572,10 +577,10 @@ def export_members(request): writer = unicodecsv.writer(response) for profile in CofProfile.objects.filter(is_cof=True).all(): user = profile.user - bits = [profile.num, user.username, user.first_name, user.last_name, + bits = [profile.id, user.username, user.first_name, user.last_name, user.email, profile.phone, profile.occupation, profile.departement, profile.type_cotiz] - writer.writerow([six.text_type(bit) for bit in bits]) + writer.writerow([str(bit) for bit in bits]) return response @@ -591,78 +596,80 @@ def csv_export_mega(filename, qs): comments = "---".join( [comment.content for comment in reg.comments.all()]) bits = [user.username, user.first_name, user.last_name, user.email, - profile.phone, profile.num, + profile.phone, profile.id, profile.comments if profile.comments else "", comments] - writer.writerow([six.text_type(bit) for bit in bits]) + writer.writerow([str(bit) for bit in bits]) return response @buro_required def export_mega_remarksonly(request): - filename = 'remarques_mega_2016.csv' + filename = 'remarques_mega_2017.csv' response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename=' + filename writer = unicodecsv.writer(response) - event = Event.objects.get(title="Mega 2016") - commentfield = event.commentfields.get(name="Commentaires") + event = Event.objects.get(title="MEGA 2017") + commentfield = event.commentfields.get(name="Commentaire") for val in commentfield.values.all(): reg = val.registration user = reg.user profile = user.profile bits = [user.username, user.first_name, user.last_name, user.email, - profile.phone, profile.num, profile.comments, val.content] - writer.writerow([six.text_type(bit) for bit in bits]) + profile.phone, profile.id, profile.comments, val.content] + writer.writerow([str(bit) for bit in bits]) return response -@buro_required -def export_mega_bytype(request, type): - types = {"orga-actif": "Orga élève", - "orga-branleur": "Orga étudiant", - "conscrit-eleve": "Conscrit élève", - "conscrit-etudiant": "Conscrit étudiant"} - - if type not in types: - raise Http404 - - event = Event.objects.get(title="Mega 2016") - type_option = event.options.get(name="Type") - participant_type = type_option.choices.get(value=types[type]).id - qs = EventRegistration.objects.filter(event=event).filter( - options__id__exact=participant_type) - return csv_export_mega(type + '_mega_2016.csv', qs) +# @buro_required +# def export_mega_bytype(request, type): +# types = {"orga-actif": "Orga élève", +# "orga-branleur": "Orga étudiant", +# "conscrit-eleve": "Conscrit élève", +# "conscrit-etudiant": "Conscrit étudiant"} +# +# if type not in types: +# raise Http404 +# +# event = Event.objects.get(title="MEGA 2017") +# type_option = event.options.get(name="Type") +# participant_type = type_option.choices.get(value=types[type]).id +# qs = EventRegistration.objects.filter(event=event).filter( +# options__id__exact=participant_type) +# return csv_export_mega(type + '_mega_2017.csv', qs) @buro_required def export_mega_orgas(request): - event = Event.objects.get(title="Mega 2016") - type_option = event.options.get(name="Conscrit ou orga ?") - participant_type = type_option.choices.get(value="Vieux").id - qs = EventRegistration.objects.filter(event=event).exclude( - options__id=participant_type) - return csv_export_mega('orgas_mega_2016.csv', qs) + event = Event.objects.get(title="MEGA 2017") + type_option = event.options.get(name="Conscrit/Orga ?") + participant_type = type_option.choices.get(value="Orga").id + qs = EventRegistration.objects.filter(event=event).filter( + options__id=participant_type + ) + return csv_export_mega('orgas_mega_2017.csv', qs) @buro_required def export_mega_participants(request): - event = Event.objects.get(title="Mega 2016") - type_option = event.options.get(name="Conscrit ou orga ?") + event = Event.objects.get(title="MEGA 2017") + type_option = event.options.get(name="Conscrit/Orga ?") participant_type = type_option.choices.get(value="Conscrit").id qs = EventRegistration.objects.filter(event=event).filter( - options__id=participant_type) - return csv_export_mega('participants_mega_2016.csv', qs) + options__id=participant_type + ) + return csv_export_mega('participants_mega_2017.csv', qs) @buro_required def export_mega(request): - event = Event.objects.filter(title="Mega 2016") + event = Event.objects.filter(title="MEGA 2017") qs = EventRegistration.objects.filter(event=event) \ .order_by("user__username") - return csv_export_mega('all_mega_2016.csv', qs) + return csv_export_mega('all_mega_2017.csv', qs) @buro_required @@ -764,3 +771,18 @@ def calendar_ics(request, token): response = HttpResponse(content=vcal.to_ical()) response['Content-Type'] = "text/calendar" return response + + +class ConfigUpdate(FormView): + form_class = GestioncofConfigForm + template_name = "gestioncof/banner_update.html" + success_url = reverse_lazy("home") + + def dispatch(self, request, *args, **kwargs): + if request.user is None or not request.user.is_superuser: + raise Http404 + return super().dispatch(request, *args, **kwargs) + + def form_valid(self, form): + form.save() + return super().form_valid(form) diff --git a/kfet/cms/__init__.py b/kfet/cms/__init__.py new file mode 100644 index 00000000..0f6cab45 --- /dev/null +++ b/kfet/cms/__init__.py @@ -0,0 +1 @@ +default_app_config = 'kfet.cms.apps.KFetCMSAppConfig' diff --git a/kfet/cms/apps.py b/kfet/cms/apps.py new file mode 100644 index 00000000..1db0e043 --- /dev/null +++ b/kfet/cms/apps.py @@ -0,0 +1,10 @@ +from django.apps import AppConfig + + +class KFetCMSAppConfig(AppConfig): + name = 'kfet.cms' + label = 'kfetcms' + verbose_name = 'CMS K-Fêt' + + def ready(self): + from . import hooks diff --git a/kfet/cms/context_processors.py b/kfet/cms/context_processors.py new file mode 100644 index 00000000..34f175d1 --- /dev/null +++ b/kfet/cms/context_processors.py @@ -0,0 +1,20 @@ +from kfet.models import Article + + +def get_articles(request=None): + articles = ( + Article.objects + .filter(is_sold=True, hidden=False) + .select_related('category') + .order_by('category__name', 'name') + ) + pressions, others = [], [] + for article in articles: + if article.category.name == 'Pression': + pressions.append(article) + else: + others.append(article) + return { + 'pressions': pressions, + 'articles': others, + } diff --git a/kfet/cms/fixtures/kfet_wagtail_17_05.json b/kfet/cms/fixtures/kfet_wagtail_17_05.json new file mode 100644 index 00000000..f6a46c30 --- /dev/null +++ b/kfet/cms/fixtures/kfet_wagtail_17_05.json @@ -0,0 +1,1456 @@ +[ +{ + "fields": { + "root_page": 9, + "port": 8000, + "site_name": "Global", + "hostname": "localhost", + "is_default_site": true + }, + "pk": 2, + "model": "wagtailcore.site" +}, +{ + "fields": { + "live": true, + "show_in_menus": false, + "numchild": 1, + "title": "Root", + "slug": "root", + "depth": 1, + "expire_at": null, + "search_description": "", + "content_type": [ + "wagtailcore", + "page" + ], + "owner": null, + "expired": false, + "first_published_at": null, + "has_unpublished_changes": false, + "go_live_at": null, + "path": "0001", + "latest_revision_created_at": null, + "url_path": "/", + "locked": false, + "seo_title": "" + }, + "pk": 1, + "model": "wagtailcore.page" +}, +{ + "fields": { + "live": true, + "show_in_menus": true, + "numchild": 5, + "title": "Bienvenue en K-Fêt", + "slug": "k-fet", + "depth": 3, + "expire_at": null, + "search_description": "", + "content_type": [ + "kfetcms", + "kfetpage" + ], + "owner": [ + "root" + ], + "expired": false, + "first_published_at": "2017-05-28T04:20:00.000Z", + "has_unpublished_changes": false, + "go_live_at": null, + "path": "000100010001", + "latest_revision_created_at": null, + "url_path": "/global/k-fet/", + "locked": false, + "seo_title": "Accueil" + }, + "pk": 3, + "model": "wagtailcore.page" +}, +{ + "fields": { + "live": true, + "show_in_menus": true, + "numchild": 0, + "title": "Mode d'emploi", + "slug": "mode-demploi", + "depth": 4, + "expire_at": null, + "search_description": "", + "content_type": [ + "kfetcms", + "kfetpage" + ], + "owner": [ + "root" + ], + "expired": false, + "first_published_at": "2017-05-28T04:20:00.000Z", + "has_unpublished_changes": false, + "go_live_at": null, + "path": "0001000100010001", + "latest_revision_created_at": null, + "url_path": "/global/k-fet/mode-demploi/", + "locked": false, + "seo_title": "" + }, + "pk": 4, + "model": "wagtailcore.page" +}, +{ + "fields": { + "live": true, + "show_in_menus": true, + "numchild": 0, + "title": "L'\u00e9quipe", + "slug": "equipe", + "depth": 4, + "expire_at": null, + "search_description": "", + "content_type": [ + "kfetcms", + "kfetpage" + ], + "owner": [ + "root" + ], + "expired": false, + "first_published_at": "2017-05-28T04:20:00.000Z", + "has_unpublished_changes": false, + "go_live_at": null, + "path": "0001000100010002", + "latest_revision_created_at": null, + "url_path": "/global/k-fet/equipe/", + "locked": false, + "seo_title": "" + }, + "pk": 5, + "model": "wagtailcore.page" +}, +{ + "fields": { + "live": true, + "show_in_menus": true, + "numchild": 0, + "title": "La carte", + "slug": "carte", + "depth": 4, + "expire_at": null, + "search_description": "", + "content_type": [ + "kfetcms", + "kfetpage" + ], + "owner": [ + "root" + ], + "expired": false, + "first_published_at": "2017-05-28T04:20:00.000Z", + "has_unpublished_changes": false, + "go_live_at": null, + "path": "0001000100010003", + "latest_revision_created_at": null, + "url_path": "/global/k-fet/carte/", + "locked": false, + "seo_title": "" + }, + "pk": 6, + "model": "wagtailcore.page" +}, +{ + "fields": { + "live": true, + "show_in_menus": true, + "numchild": 0, + "title": "Les soir\u00e9es", + "slug": "soirees", + "depth": 4, + "expire_at": null, + "search_description": "", + "content_type": [ + "kfetcms", + "kfetpage" + ], + "owner": [ + "root" + ], + "expired": false, + "first_published_at": "2017-05-28T04:20:00.000Z", + "has_unpublished_changes": false, + "go_live_at": null, + "path": "0001000100010004", + "latest_revision_created_at": null, + "url_path": "/global/k-fet/soirees/", + "locked": false, + "seo_title": "" + }, + "pk": 7, + "model": "wagtailcore.page" +}, +{ + "fields": { + "live": true, + "show_in_menus": true, + "numchild": 0, + "title": "Le flipper", + "slug": "flipper", + "depth": 4, + "expire_at": null, + "search_description": "", + "content_type": [ + "kfetcms", + "kfetpage" + ], + "owner": [ + "root" + ], + "expired": false, + "first_published_at": "2017-05-28T04:20:00.000Z", + "has_unpublished_changes": false, + "go_live_at": null, + "path": "0001000100010005", + "latest_revision_created_at": null, + "url_path": "/global/k-fet/flipper/", + "locked": false, + "seo_title": "" + }, + "pk": 8, + "model": "wagtailcore.page" +}, +{ + "fields": { + "live": true, + "show_in_menus": true, + "numchild": 1, + "title": "Global", + "slug": "global", + "depth": 2, + "expire_at": null, + "search_description": "", + "content_type": [ + "wagtailcore", + "page" + ], + "owner": [ + "root" + ], + "expired": false, + "first_published_at": "2017-05-28T04:20:00.000Z", + "has_unpublished_changes": false, + "go_live_at": null, + "path": "00010001", + "latest_revision_created_at": null, + "url_path": "/global/", + "locked": false, + "seo_title": "" + }, + "pk": 9, + "model": "wagtailcore.page" +}, +{ + "fields": { + "live": true, + "show_in_menus": false, + "numchild": 0, + "title": "Mentions l\u00e9gales", + "slug": "mentions-legales", + "depth": 4, + "expire_at": null, + "search_description": "", + "content_type": [ + "kfetcms", + "kfetpage" + ], + "owner": [ + "root" + ], + "expired": false, + "first_published_at": "2017-05-28T04:20:00.000Z", + "has_unpublished_changes": false, + "go_live_at": null, + "path": "0001000100010006", + "latest_revision_created_at": null, + "url_path": "/global/k-fet/mentions-legales/", + "locked": false, + "seo_title": "" + }, + "pk": 10, + "model": "wagtailcore.page" +}, +{ + "fields": { + "name": "Root", + "numchild": 1, + "path": "0001", + "depth": 1 + }, + "pk": 1, + "model": "wagtailcore.collection" +}, +{ + "fields": { + "name": "K-F\u00eat", + "numchild": 0, + "path": "00010001", + "depth": 2 + }, + "pk": 2, + "model": "wagtailcore.collection" +}, +{ + "pk": 1, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Hugo", + "nick_name": "", + "photo": 3, + "last_name": "Manet" + } +}, +{ + "pk": 2, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Lisa", + "nick_name": "", + "photo": 4, + "last_name": "Gourdon" + } +}, +{ + "pk": 3, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Pierre", + "nick_name": "", + "photo": 5, + "last_name": "Quesselaire" + } +}, +{ + "pk": 4, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Thibault", + "nick_name": "", + "photo": 6, + "last_name": "Scoquard" + } +}, +{ + "pk": 5, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Arnaud", + "nick_name": "", + "photo": 7, + "last_name": "Fanthomme" + } +}, +{ + "pk": 6, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Vincent", + "nick_name": "", + "photo": 8, + "last_name": "Balerdi" + } +}, +{ + "pk": 7, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Nathana\u00ebl", + "nick_name": "", + "photo": 9, + "last_name": "Willaime" + } +}, +{ + "pk": 8, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "\u00c9lisabeth", + "nick_name": "", + "photo": 10, + "last_name": "Miller" + } +}, +{ + "pk": 9, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Arthur", + "nick_name": "B2O", + "photo": 11, + "last_name": "Lesage" + } +}, +{ + "pk": 10, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Sarah", + "nick_name": "", + "photo": 12, + "last_name": "Asset" + } +}, +{ + "pk": 11, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Alexandre", + "nick_name": "", + "photo": 13, + "last_name": "Legrand" + } +}, +{ + "pk": 12, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "\u00c9tienne", + "nick_name": "", + "photo": 14, + "last_name": "Baudel" + } +}, +{ + "pk": 13, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Marine", + "nick_name": "", + "photo": 15, + "last_name": "Snape" + } +}, +{ + "pk": 14, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Anatole", + "nick_name": "", + "photo": 16, + "last_name": "Gosset" + } +}, +{ + "pk": 15, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Jacko", + "nick_name": "", + "photo": 17, + "last_name": "Rastikian" + } +}, +{ + "pk": 16, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Alexandre", + "nick_name": "", + "photo": 18, + "last_name": "Jannaud" + } +}, +{ + "pk": 17, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Aur\u00e9lien", + "nick_name": "", + "photo": 19, + "last_name": "Delobelle" + } +}, +{ + "pk": 18, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Sylvain", + "nick_name": "", + "photo": 20, + "last_name": "Douteau" + } +}, +{ + "pk": 19, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Rapha\u00ebl", + "nick_name": "", + "photo": 21, + "last_name": "Lescanne" + } +}, +{ + "pk": 20, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Romain", + "nick_name": "", + "photo": 22, + "last_name": "Gourvil" + } +}, +{ + "pk": 21, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Marie", + "nick_name": "", + "photo": 23, + "last_name": "Labeye" + } +}, +{ + "pk": 22, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Oscar", + "nick_name": "", + "photo": 24, + "last_name": "Blumberg" + } +}, +{ + "pk": 23, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Za\u00efd", + "nick_name": "", + "photo": 25, + "last_name": "Allybokus" + } +}, +{ + "pk": 24, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Damien", + "nick_name": "", + "photo": 26, + "last_name": "Garreau" + } +}, +{ + "pk": 25, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Andr\u00e9a", + "nick_name": "", + "photo": 27, + "last_name": "Londonez-Lopez" + } +}, +{ + "pk": 26, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Tristan", + "nick_name": "", + "photo": 28, + "last_name": "Roussel" + } +}, +{ + "pk": 27, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Guillaume", + "nick_name": "", + "photo": 29, + "last_name": "Vernade" + } +}, +{ + "pk": 28, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Lucas", + "nick_name": "", + "photo": 30, + "last_name": "Mercier" + } +}, +{ + "pk": 29, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Fran\u00e7ois", + "nick_name": "M\u00e9talleux", + "photo": 31, + "last_name": "Maillot" + } +}, +{ + "pk": 30, + "model": "kfetcms.memberteam", + "fields": { + "first_name": "Fabrice", + "nick_name": "", + "photo": 32, + "last_name": "Catoire" + } +}, +{ + "pk": 3, + "model": "kfetcms.kfetpage", + "fields": { + "main_size": "", + "content": "[{\"value\": \" La K-F\\u00eat, c'est quoi ?
\\n\\n\\n Eh bien la K-F\\u00eat, c'est le bar des \\u00e9l\\u00e8ves de l'\\u00c9cole normale\\n sup\\u00e9rieure. Elle est situ\\u00e9e dans les locaux de l'\\u00c9cole, au pied de\\n l'escalier C (plan). On y trouve \\u00e0 boire, bien s\\u00fbr,\\n des bi\\u00e8res en nombre pl\\u00e9thorique mais aussi caf\\u00e9s, th\\u00e9s, softs et de quoi\\n grignoter. Ah oui un point important, on ne va pas \\u00e0 la K-F\\u00eat, on va EN K-F\\u00eat.\\n
\", \"type\": \"rich\"}, {\"value\": \"Mais on n'y fait que boire et manger ?
\\n\\n\\n Que nenni, \\u00f4 jeune et innocent conscrit-e ! La K-F\\u00eat n'est pas un bouge\\n sordide o\\u00f9 des piliers de bar passent leurs journ\\u00e9es \\u00e0 picoler. Enfin pas\\n uniquement. C'est aussi un lieu de divertissement avec\\n son flipper (la mythique, la seule, l'unique,\\n la g\\u00e9niale Amazon Hunt), son baby-foot et le lieu d'\\u00e9lection des \\nbridgeur-se-s, du club jeux, des joueur-se-s de poker voire des quelques\\n irr\\u00e9ductibles du boulot qui y viennent bosser en profitant du point \\nd'acc\\u00e8s wifi. \\n
\", \"type\": \"rich\"}, {\"value\": \"Ah \\u00e7a a l'air bien mais... qui s'en occupe ? C'est ouvert quand ?
\\n\\n\\n L'\\u00e9quipe d'\\u00e9l\\u00e8ves motiv\\u00e9-e-s qui s'occupent de la K-F\\u00eat s'appelle, en toute logique, l'\\u00e9quipe K-F\\u00eat.\\n Elle est men\\u00e9e par un-e leader charismatique et bien-aim\\u00e9-e, \\naccompagn\\u00e9-e de ses troupes de fid\\u00e8les, les K-F\\u00eat wo-men, boys et girls.\\n Le local de la K-F\\u00eat n'est ouvert que si un-e K-F\\u00eat wo-man est \\npr\\u00e9sente. \\u00c0 savoir la plupart du temps entre 12h et 3h du matin.\\n
\", \"type\": \"rich\"}, {\"value\": \"Et je peux y faire ce que je veux ?
\\n\\n\\n Oui et non. Nous ne sommes pas ta grand-m\\u00e8re et nous n'allons\\n certainement pas t'emp\\u00eacher de faire la f\\u00eate, ni de d\\u00e9guster des pintes\\n jusqu'au petit p\\u00f4t. Par contre nous attendons de toi que tu ne sois pas\\n un-e gros-se con-ne. A priori pas de raison de le croire, mais jette tout de m\\u00eame\\n un \\u0153il sur le mode d'emploi de la K-F\\u00eat, \\u00e7a\\n pourrait t'\\u00e9viter de perdre un genoux ou deux...\\n
\", \"type\": \"rich\"}, {\"value\": \"J'adore la K-F\\u00eat, j'aimerais y organiser une soir\\u00e9e, c'est possible ?
\\n\\n\\n Bien s\\u00fbr\\u00a0! Pour cela commence par lire ce petit\\n guide histoire de savoir dans quoi tu t'engages puis contacte ton-ta chef-fe K-F\\u00eat ador\\u00e9-e pour v\\u00e9rifier que la date de ta\\n soir\\u00e9e n'est pas d\\u00e9j\\u00e0 prise par une autre f\\u00eate et obtenir son\\n accord.\\n
\", \"type\": \"rich\"}, {\"value\": \"J'ai une question \\u00e0 vous poser. O\\u00f9 puis-je vous contacter ?
\\n\\n\\n Commence d\\u00e9j\\u00e0 par jeter un oeil sur le mode\\n d'emploi de la K-F\\u00eat. Si la r\\u00e9ponse \\u00e0 tes interrogations ne s'y\\n trouve pas, rien n'est perdu. En effet le service informatique de \\nl'\\u00c9cole, dans sa grande mansu\\u00e9tude, a mis \\u00e0 disposition de l'\\u00e9quipe \\nK-F\\u00eat une adresse e-mail, k-fet@ens.fr. Mais sinon, passe en K-F\\u00eat, il y aura sans doute un K-F\\u00eat wo-man qui saura r\\u00e9pondre \\u00e0 ta question.\\n
\", \"type\": \"rich\"}]", + "layout": "kfet/base_col_mult.html", + "no_header": false, + "col_count": "" + } +}, +{ + "pk": 4, + "model": "kfetcms.kfetpage", + "fields": { + "main_size": "", + "content": "[{\"value\": \"Article 0 : La K-F\\u00eat n'existe pas.
\", \"type\": \"rich\"}, {\"value\": \"La K-F\\u00eat, c'est magique, comment \\u00e7a marche ?
La K-F\\u00eat n'a \\nrien de magique, il n'y a pas de petits d\\u00e9mons qui font le m\\u00e9nage, pas \\nplus que d'arbustes g\\u00e9n\\u00e9tiquement modifi\\u00e9s aux OGM sur lesquels poussent\\n les bouteilles de bi\\u00e8res. La K-F\\u00eat c'est avant tout une \\u00e9quipe qui sacrifie une partie de son temps libre pour que tout se passe pour le mieux.
\", \"type\": \"rich\"}, {\"value\": \"Que puis-je faire pour vous aider un peu ?
D\\u00e9j\\u00e0 ne pas poser \\nde probl\\u00e8mes, c'est \\u00e0 dire ne pas r\\u00e9veiller tout l'internat en sortant, \\nessayer de ne pas finir dans un \\u00e9tat trop avanc\\u00e9 d'alcoolisation, etc...\\n Mine de rien \\u00e7a nous \\u00e9viterait quelques probl\\u00e8mes.
Ensuite, comme\\n tu le sais s\\u00fbrement les bi\\u00e8res sont consign\\u00e9es, il est donc pr\\u00e9f\\u00e9rable \\npour nous que tu n'embarques pas les bouteilles en souvenir dans ta \\nthurne. Mieux, tu peux nous faire gagner du temps de rangement en les \\nramenant au bar en partant. Et encore mieux, tu peux jeter tes d\\u00e9chets \\n(gobelets, boite de pringles, etc...). Si tu fais d\\u00e9j\\u00e0 tout \\u00e7a tu nous \\nsimplifieras grandement la vie.
\", \"type\": \"rich\"}, {\"value\": \"Le syst\\u00e8me mon\\u00e9taire de la K-F\\u00eat
En bon \\u00e9tat souverain et \\nind\\u00e9pendant, la K-F\\u00eat a sa propre monnaie : l'unit\\u00e9 K-F\\u00eat (UKF). Elle \\nvaut 10 centimes d'euro. La K-F\\u00eat ne battant pas monnaie, les UKF que tu\\n poss\\u00e8des sont not\\u00e9es sur ton compte, identifi\\u00e9 par un trigramme (une \\nsuite de trois caract\\u00e8res) et que tu peux recharger en liquide ou par \\nch\\u00e8que. Note que si tu y tiens vraiment, tu peux payer en liquide, mais \\nposs\\u00e9der un compte est bien plus pratique.
\", \"type\": \"rich\"}, {\"value\": \"Comment commander \\u00e0 boire ou \\u00e0 manger ?
Pour commander \\u00e0 boire ou \\u00e0 manger, il suffit de demander \\u00e0 un membre de l'\\u00e9quipe K-F\\u00eat.\\n Et \\u00e7a marche encore mieux si la demande est effectu\\u00e9e avec le sourire \\nau d\\u00e9but et un merci \\u00e0 la fin : l'\\u00e9quipe est constitu\\u00e9e de volontaires \\nb\\u00e9n\\u00e9voles, et mieux vaut ne pas les prendre pour des chiens. EN AUCUN \\nCAS on ne passe derri\\u00e8re le bar si on n'est pas membre de l'\\u00e9quipe K-F\\u00eat.
\", \"type\": \"rich\"}, {\"value\": \"Puis-je fumer en K-F\\u00eat ?
Non ! Imagine-toi les jours de \\nsoir\\u00e9es, la K-F\\u00eat remplie et tout le monde qui fume... On finirait tous \\navec des poumons aussi crades que le sol de la K-F\\u00eat. Ce serait quand \\nm\\u00eame dommage pour la recherche fran\\u00e7aise qu'on cr\\u00e8ve tous avant 30 ans, \\nnon ?
Par contre tu peux fumer dehors, il y a m\\u00eame des cendriers \\njuste pour toi, par contre tu remarqueras que les chambres de l'internat\\n se trouvent juste au dessus de toi. T\\u00e2che donc de ne pas faire trop de \\nbruit.
\", \"type\": \"rich\"}, {\"value\": \"Et amener ma propre bouteille ?
D\\u00e9j\\u00e0 c'est apporter, enfin en\\n tout cas avant de la boire. Ensuite la K-F\\u00eat est un lieu de \\nconvivialit\\u00e9 o\\u00f9 les bi\\u00e8res te sont vendues au prix co\\u00fbtant,\\n franchement ce serait pas fair-play de te la jouer solo. Alors \\n\\u00e9videment il y a des exceptions, par exemple si tu reviens de Belgique \\net que tu veux faire go\\u00fbter de la Wesvleteren \\u00e0 tes amis de l'\\u00e9quipe K-F\\u00eat,\\n ou si tu veux organiser une d\\u00e9gustation de vins avec la charcuterie qui\\n va bien. Tu comprendras qu'un pack de Kro c'est quand m\\u00eame pas la m\\u00eame \\nclasse...
\", \"type\": \"rich\"}, {\"value\": \"Je peux passer ma musique ?
Bien s\\u00fbr, nous sommes tr\\u00e8s loin \\nde penser tout conna\\u00eetre en mati\\u00e8re de musique. Mais comme nous sommes \\nentre gens civilis\\u00e9s, et que je te rappelle que tu n'as pas le droit de \\npasser derri\\u00e8re le bar, il convient de demander \\u00e0 un-e membre de l'\\u00e9quipe K-F\\u00eat\\n afin qu'ille t'indique qui est \\u00e0 l'origine de ces chansons que tu \\nn'appr\\u00e9cies apparemment pas. Apr\\u00e8s avoir obtenu son accord tu peux \\ndemander \\u00e0 quelqu'un de mettre ta playlist, qui peut-\\u00eatre sur un lecteur\\n mp3, sur Deezer ou juste sur l'ordi, mais dans ce dernier cas ce sera plus dur puisque tu n'y aura pas acc\\u00e8s directement.
Le plus simple pour toi (et pour nous) est donc de pr\\u00e9voir des playlists sur Deezer\\n d'avance et de nous les proposer. Par contre, sois gentil-le, n'insiste\\n pas si nous ne voulons pas de ta musique traditionnelle hongroise. Par \\nailleurs, si un trop grand nombre de personnes nous demande de passer de\\n la musique, l'\\u00e9quipe K-F\\u00eat peut ne pas acc\\u00e9der \\u00e0 ta requ\\u00eate.
\", \"type\": \"rich\"}, {\"value\": \"Comment organiser une soir\\u00e9e en K-F\\u00eat ?
Tout membre du COF \\npeut organiser une soir\\u00e9e en K-F\\u00eat \\u00e0 la condition qu'elle soit publique \\net annonc\\u00e9e une semaine \\u00e0 l'avance par des affiches dans l'\\u00e9cole et un \\nmot dans le BOcal. Il faut bien sur aussi l'accord du COF qui s'occupe \\nde voir si \\u00e7a ne pose pas de probl\\u00e8me \\u00e0 l'admin, celui de la K-F\\u00eat team \\npour qu'il y ait des K-F\\u00eat wo-men pour servir et s\\u00fbrement du BOUM pour \\nqu'il s'occupe de la musique. Nous t'avons tout r\\u00e9sum\\u00e9 ici\\n ; merci qui ? Une fois que tu as accompli ces formalit\\u00e9s, il ne te \\nreste plus qu'\\u00e0 imprimer et coller des affiches pour que ta soir\\u00e9e soit \\nun succ\\u00e8s !
\", \"type\": \"rich\"}, {\"value\": \"D'autres remarques ?
Des tonnes, en voici quelques unes :
\", \"type\": \"rich\"}]", + "layout": "kfet/base_col_mult.html", + "no_header": false, + "col_count": "" + } +}, +{ + "pk": 5, + "model": "kfetcms.kfetpage", + "fields": { + "main_size": "", + "content": "[{\"value\": [{\"value\": \"
- Ce n'est pas caf\\u00e8t, ni kfet, ni caf\\u00e9t\\u00e9ria, c'est K-F\\u00eat, avec les majuscules.
- On dit \\\"en K-F\\u00eat\\\".
- On ne passe pas derri\\u00e8re le bar,\\n je sais je l'ai d\\u00e9j\\u00e0 dit, mais \\u00e7a a du mal \\u00e0 rentrer. S'il n'y a \\npersonne pour servir c'est que les K-F\\u00eat people sont soit occup\\u00e9-e-s \\nquelque chose d'important en arri\\u00e8re-K-F\\u00eat, soit sont pos\\u00e9-e-s dans le \\ncanap\\u00e9 \\u00e0 c\\u00f4t\\u00e9 du bar, soit sont en train de jouer \\u00e0 l'Amazon. Demande-leur, ou prends ton mal en patience.
- La K-F\\u00eat n'est pas une porcherie, tu n'es pas oblig\\u00e9-e de laisser tout ton bordel quand tu pars.
- Merci d'avoir lu jusque l\\u00e0.
Les ancien-ne-s Chef-fe-s K-F\\u00eat
Les ancien-ne-s Chef-fe-s K-F\\u00eat doivent bien \\u00eatre pr\\u00e9sent\\u00e9-e-s avant \\nl'\\u00e9quipe actuelle. C'est gr\\u00e2ce \\u00e0 elleux qu'elle tourne encore, gr\\u00e2ce \\u00e0 \\nelleux qu'elle a bien tourn\\u00e9, et puis, de pr\\u00e8s comme de loin, illes \\nveillent encore sur nous. Ce sont les diff\\u00e9rentes facettes de la K-F\\u00eat \\nhistorique, bien que d'un certain point de vue, illes se ressemblent \\ntou-te-s : les Chef-fe-s K-F\\u00eat sont une dynastie, ils n'ont pas \\u00e9t\\u00e9 \\nChef-fe-s apr\\u00e8s avoir prouv\\u00e9 quoi que ce soit, illes l'ont \\u00e9t\\u00e9 parce que\\n ce r\\u00f4le leur revenait de droit. On na\\u00eet Chef-fe K-F\\u00eat, on ne le devient\\n pas. Et on le reste toujours, dans l'\\u00e2me.
\", \"type\": \"rich\"}, {\"value\": {\"members\": [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], \"show_only\": 12}, \"type\": \"group_team\"}], \"type\": \"group\"}, {\"value\": [{\"value\": \"Le chef
Le-la chef-fe K-F\\u00eat, celui-celle qui a le droit de vie et de mort sur les \\u00e2mes \\u00e9gar\\u00e9es qui fr\\u00e9quentent la K-F\\u00eat.
\", \"type\": \"rich\"}, {\"value\": {\"members\": [1, 2], \"show_only\": null}, \"type\": \"group_team\"}], \"type\": \"group\"}, {\"value\": [{\"value\": \"Les K-F\\u00eat Wo-Men
Les K-F\\u00eat wo-men poss\\u00e8dent les cl\\u00e9s de la K-F\\u00eat. Ce sont elleux qui peuvent d\\u00e9cider ou non d'ouvrir la K-F\\u00eat.
\", \"type\": \"rich\"}, {\"value\": {\"members\": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], \"show_only\": null}, \"type\": \"group_team\"}], \"type\": \"group\"}, {\"value\": [{\"value\": \"Les Vieux-illes
Les vieux-illes sont d'ancien-ne-s K-F\\u00eat wo-men qui ne viennent plus \\naussi souvent qu'avant, illes servent toujours, mais n'ont en g\\u00e9n\\u00e9ral \\nplus les cl\\u00e9s. Illes existent n\\u00e9anmoins, et on les garde (pour \\ncertain-e-s) parce qu'au fond, on les aime quand m\\u00eame, et qu'en plus, \\nilles en savent plus que n'importe qui sur la K-F\\u00eat.
\", \"type\": \"rich\"}], \"type\": \"group\"}, {\"value\": \"Les K-F\\u00eat boys et girls
\\n\\nLes K-F\\u00eat boys and girls font de main d'\\u0153uvre bon march\\u00e9 pour la \\nK-F\\u00eat, illes peuvent passer derri\\u00e8re le bar, prendre vos commandes et \\nrecharger votre compte si par malheur il est \\u00e0 sec. La liste de \\ncelleux-ci est trop longue pour tou-te-s les citer, pour les reconna\\u00eetre\\n regarde les gens qui passent derri\\u00e8re le bar tout en conservant leur \\nint\\u00e9grit\\u00e9 physique.
\", \"type\": \"rich\"}, {\"value\": \"Comment devient-on K-F\\u00eat people ?
Grande question que tout le monde se pose un jour ou l'autre. Pour \\nacc\\u00e9der au titre prestigieux de K-F\\u00eat boy-girl, il est n\\u00e9cessaire mais \\npas suffisant d'\\u00eatre assid\\u00fbment pr\\u00e9sent-e en K-F\\u00eat, et d'\\u00eatre pr\\u00eat-e \\u00e0 \\ntrimer pour elle. Si tu es souvent en K-F\\u00eat, que tu es sympathique et \\nmotiv\\u00e9-e, et surtout en fin de compte si le-la chef-fe le veut bien, tu \\npourras devenir K-F\\u00eat boy-girl et passer derri\\u00e8re le bar pour servir. \\nEnsuite, si tu es motiv\\u00e9-e et efficace, ou simplement si t'es un-e pote \\ndu-de la chef-fe et qu'ille n'a aucun scrupule, tu pourras devenir K-F\\u00eat\\n wo-man et avoir la cl\\u00e9.
Et comme la K-F\\u00eat c'est avant tout beaucoup d'emmerdes on a pas envie\\n de te forcer la main, on veut que cela vienne de toi. Donc si tu te \\nsens pr\\u00eat-e \\u00e0 participer \\u00e0 la vie mouvement\\u00e9e de la K-F\\u00eat fais-en part \\nau-\\u00e0 la chef-fe. Ille ne va pas te manger.
\", \"type\": \"rich\"}]", + "layout": "kfet/base_col_mult.html", + "no_header": false, + "col_count": "" + } +}, +{ + "pk": 6, + "model": "kfetcms.kfetpage", + "fields": { + "main_size": "", + "content": "[{\"value\": \"Le service de la bi\\u00e8re est, historiquement, la mission et le sacerdoce \\ndu K-F\\u00eat people. Ille y est d\\u00e9vou\\u00e9-e corps et \\u00e2me, et accomplit sa t\\u00e2che\\n avec ardeur et passion. Voyons comment se d\\u00e9clinent les occasions \\nd'approcher du nirvana brassicole. Les prix donn\\u00e9s sont en UKF. Si tu \\nn'as pas compris, va voir par ici.
\", \"type\": \"rich\"}, {\"value\": null, \"type\": \"carte\"}]", + "layout": "kfet/base_col_mult.html", + "no_header": false, + "col_count": "column-md-2 column-lg-3" + } +}, +{ + "pk": 7, + "model": "kfetcms.kfetpage", + "fields": { + "main_size": "", + "content": "[{\"value\": \"Tu veux organiser une soir\\u00e9e en K-F\\u00eat ? Pas de probl\\u00e8me !
\", \"type\": \"rich\"}, {\"value\": \"Quand puis-je organiser une soir\\u00e9e ?
\\n\\n\\n Tu peux organiser une soir\\u00e9e le jour que tu souhaites, \\u00e0 condition que la\\n date ne soit pas d\\u00e9j\\u00e0 prise par quelqu'un d'autre. Sache par contre que la\\n K-F\\u00eat ne te sera pas enti\\u00e8rement d\\u00e9di\\u00e9e et que les utilisateur-rice-s habituel-le-s\\n continueront de la fr\\u00e9quenter (et risquent fortement de squatter ta\\n soir\\u00e9e). Donc si tu veux un peu d'intimit\\u00e9 les soir\\u00e9es du week-end sont plus\\n conseill\\u00e9es (mais l'\\u00e9quipe risque de ne pas \\u00eatre pr\\u00e9sente), mais aussi\\n plus pris\\u00e9es, d\\u00e9p\\u00eache-toi de r\\u00e9server la tienne.\\n
\", \"type\": \"rich\"}, {\"value\": \"Quelles d\\u00e9marches dois-je effectuer ?
\\n\\n D\\u00e9j\\u00e0 pr\\u00e9venir poliment l'\\u00e9quipe K-F\\u00eat, et\\n surtout le-la chef-fe pour v\\u00e9rifier que la date est encore libre, et qu'il y\\n aura au moins quelqu'un pour t'ouvrir la K-F\\u00eat. Ensuite, si ta soir\\u00e9e\\n n'est pas une simple bouffe qui finit avant minuit il faut pr\\u00e9venir les\\n vigiles via l'administration au moyen d'une demande d'autorisation de\\n soir\\u00e9e qui se trouve sur la section du p\\u00f4le Pr\\u00e9vention et S\\u00e9curit\\u00e9 sur l'intranet : demande d'autorisation de soir\\u00e9e.\\n \\u00c0 faire au moins une semaine avant ta soir\\u00e9e.\\n
\\n\\n Si en plus tu as besoin que le BOUM s'occupe de la musique et/ou PLS des\\n lumi\\u00e8res c'est elleux qu'il faut contacter. Histoire de t'\\u00e9viter\\n d'avoir \\u00e0 chercher voici leur adresse\\u00a0: boum (at) ens (point) fr\\n et pls (at) ens (point) fr.\\n
\", \"type\": \"rich\"}, {\"value\": \"C'est enfin le grand jour, je fais quoi ?
\\n\\n D\\u00e9j\\u00e0 le m\\u00e9nage, oui je sais c'est chiant mais c'est le prix \\u00e0 payer pour\\n profiter du local. Demande \\u00e0 ce qu'un-e K-F\\u00eat wo-man t'ouvre et tu devrais avoir\\n \\u00e0 ta disposition tout ce qu'il faut pour faire briller la K-F\\u00eat (ou au moins on essaiera de\\n trouver ce qu'il faut). Fais par\\n contre attention aux bouteilles de bi\\u00e8re qui sont consign\\u00e9es, s'il n'y a\\n personne pour les ranger contente-toi de les mettre sur le bar, quelqu'un\\n s'en chargera plus tard. Les meubles peuvent \\u00eatre d\\u00e9plac\\u00e9s dans une salle\\n voisine si tu le souhaites, il faudra juste penser \\u00e0 les remettre en place.\\n
\\n\\n Ensuite dans l'id\\u00e9al tu connais tous tes potes, donc en donner une liste \\u00e0\\n la loge permet d'\\u00e9viter quelques probl\\u00e8mes et quelques aller-retours.\\n Au-del\\u00e0 de 21h, les ext\\u00e9rieur-e-s ne peuvent rentrer qu'avec un-e Ulmien-ne ayant sa carte\\n sur lui-elle.\\n
\", \"type\": \"rich\"}, {\"value\": \"Je pourrai passer ma musique ?
\\n\\n\\n Si le BOUM est pr\\u00e9sent, faut voir avec elleux : boum (at) ens (point) fr
\", \"type\": \"rich\"}, {\"value\": \"
\\n Sinon, pr\\u00e9pare ta musique sur un lecteur mp3 ou une playlist\\n Deezer. Lors de la soir\\u00e9e,\\n demande \\u00e0 un-e K-F\\u00eat wo-man de passer ce que tu as pr\\u00e9par\\u00e9.\\nEt pour ce qui est de la nourriture, des boissons ?
\\n\\n Tu peux apporter toute la nourriture que tu souhaites\\u00a0; pr\\u00e9vois assez\\n large, il y a beaucoup de K-F\\u00eat people \\u00e0 nourrir. Pour ce qui est de la\\n boisson, il faut te limiter aux boissons de cat\\u00e9gorie 2, c'est \\u00e0 dire\\n bi\\u00e8res, vins et boissons \\u00e0 base de vin, champagne et bien s\\u00fbr les boissons sans alcool.\\n
\", \"type\": \"rich\"}, {\"value\": \"Et pendant la soir\\u00e9e ?
\\n\\n Ce soir c'est ton soir, il est donc bien s\\u00fbr \\u00e9vident que tu dois\\n rester pr\\u00e9sent-e et joignable du d\\u00e9but \\u00e0 la fin de la soir\\u00e9e. Id\\u00e9alement ce\\n doit aussi \\u00eatre le cas de tes \\\"Responsables ordre et discipline\\\". Vous ne serez pas\\n trop de deux ou trois pour r\\u00e9gler les probl\\u00e8mes qui pourraient survenir,\\n tes potes bourr\\u00e9-e-s, tes potes qui fument, tes potes qui font du bordel dans la cage d'escalier,\\n etc... Tous les probl\\u00e8mes qui pourraient survenir te seront imput\\u00e9s donc\\n pr\\u00e9viens-les, c'est tes potes apr\\u00e8s tout, non ?\\n
\", \"type\": \"rich\"}, {\"value\": \"Apr\\u00e8s c'est bon ?
\\n\\n Eh non, pas encore, apr\\u00e8s (ou le lendemain de) ta soir\\u00e9e il te faudra encore ranger,\\n faire le m\\u00e9nage et passer un coup de javel. Oui encore, mais bon, pense \\u00e0 toutes les fois o\\u00f9\\n c'est nous qui le faisons pour le bien de tou-te-s. Une fois n'est pas\\n coutume demande \\u00e0 un-e K-F\\u00eat wo-man de t'ouvrir et de te fournir tout le\\n mat\\u00e9riel dont tu pourrais avoir besoin, et l\\u00e0 o\\u00f9 c'est vraiment classe\\n c'est que tu peux m\\u00eame faire \\u00e7a en musique si tu le souhaites. N'oublie\\n pas non plus de rapporter les meubles que tu pourrais avoir sortis et que\\n les poubelles ne disparaissent pas toutes seules.\\n
\", \"type\": \"rich\"}, {\"value\": \"Une derni\\u00e8re remarque ?
\\n\\n\\n Ouais, la K-F\\u00eat c'est pas chez m\\u00e9m\\u00e9, alors c'est peut-\\u00eatre ta soir\\u00e9e mais\\n si un-e membre de l'\\u00e9quipe K-F\\u00eat te dit quelque\\n chose (de baisser le son, de virer telle ou telle personne...) tu acceptes avec le sourire.\\n En particulier tu ne passes pas derri\\u00e8re le bar.\\n
\", \"type\": \"rich\"}, {\"value\": \"Je ne parle pas bien fran\\u00e7ais, vous pourriez me faire un r\\u00e9sum\\u00e9 ?
\\n\\n Organiser ta soir\\u00e9e c'est facile :\\n
\\n\\n
- Envoie un mail \\u00e0 la K-F\\u00eat pour demander l'autorisation\\n : k-fet (at) ens (point) fr.
- Lorsque c'est bon, remplis\\n le papier de l'admin, et\\n donne-le au-\\u00e0 la chef-fe K-F\\u00eat.
- Pour la musique, l'alcool, contacte la K-F\\u00eat.
- Le jour de la soir\\u00e9e, viens faire le m\\u00e9nage et donne une liste des\\n ext\\u00e9rieur-e-s \\u00e0 la loge.
- Pendant la soir\\u00e9e, surveille tes invit\\u00e9s (pas trop de bruit \\u00e0\\n l'ext\\u00e9rieur de la K-F\\u00eat, pas de gens trop bourr\\u00e9s qui font des b\\u00eatises\\n avec les alarmes ou les sorties de secours...)
- Apr\\u00e8s la soir\\u00e9e (le lendemain si tu veux) reviens faire le m\\u00e9nage.
\\n Voila, facile, non ?\\n
\", \"type\": \"rich\"}]", + "layout": "kfet/base_col_mult.html", + "no_header": false, + "col_count": "" + } +}, +{ + "pk": 8, + "model": "kfetcms.kfetpage", + "fields": { + "main_size": "", + "content": "[{\"value\": \"Et le baby-foot
\", \"type\": \"rich\"}, {\"value\": \"LE flipper
\\n\\n\\n\\n\\n\\t
\", \"type\": \"rich\"}, {\"value\": \"Le baby-foot
\", \"type\": \"rich\"}, {\"value\": \"La d\\u00e9funte fun machine
\\n\\n\\n\\nCette machine n'est plus. Mais elle reste dans le coeur de ceux qui \\nl'ont connue. C'est pourquoi cette section n'a pas \\u00e9t\\u00e9 retir\\u00e9e.
\", \"type\": \"rich\"}]", + "layout": "kfet/base_col_mult.html", + "no_header": false, + "col_count": "" + } +}, +{ + "pk": 10, + "model": "kfetcms.kfetpage", + "fields": { + "main_size": "", + "content": "[{\"value\": \"Responsable de la publication
\", \"type\": \"rich\"}, {\"value\": \"
- Il s'agit de la pr\\u00e9sidence du COF :
Association des \\u00c9l\\u00e8ves de l'\\u00c9cole Normale Sup\\u00e9rieure
45 rue d'Ulm
75005 ParisInformations prestataires
\", \"type\": \"rich\"}]", + "layout": "kfet/base_col_mult.html", + "no_header": false, + "col_count": "" + } +}, +{ + "model": "wagtaildocs.document", + "pk": 1, + "fields": { + "created_at": "2017-05-30T04:20:00.000Z", + "uploaded_by_user": [ + "root" + ], + "collection": 2, + "title": "K-F\u00eat - Plan d'acc\u00e8s", + "file": "documents/kfet_acces.pdf" + } +}, +{ + "model": "wagtaildocs.document", + "pk": 2, + "fields": { + "created_at": "2017-05-30T04:20:00.000Z", + "uploaded_by_user": [ + "root" + ], + "collection": 2, + "title": "K-F\u00eat - Demande d'autorisation", + "file": "documents/kfet_autorisation.pdf" + } +}, +{ + "model": "wagtaildocs.document", + "pk": 3, + "fields": { + "created_at": "2017-05-30T04:20:00.000Z", + "uploaded_by_user": [ + "root" + ], + "collection": 2, + "title": "K-F\u00eat - Trait\u00e9 de Flipper Th\u00e9orique", + "file": "documents/kfet_flipper.pdf" + } +}, +{ + "model": "wagtailimages.image", + "pk": 1, + "fields": { + "created_at": "2017-05-30T04:20:00.000Z", + "focal_point_width": null, + "height": 300, + "file": "original_images/kfet_amazon.jpg", + "collection": 2, + "focal_point_x": null, + "file_size": null, + "focal_point_height": null, + "focal_point_y": null, + "title": "K-F\u00eat - Amazon Hunt", + "width": 200, + "uploaded_by_user": [ + "root" + ] + } +}, +{ + "model": "wagtailimages.image", + "pk": 2, + "fields": { + "created_at": "2017-05-30T04:20:00.000Z", + "focal_point_width": null, + "height": 300, + "file": "original_images/kfet_funmachine.jpg", + "collection": 2, + "focal_point_x": null, + "file_size": null, + "focal_point_height": null, + "focal_point_y": null, + "title": "K-F\u00eat - Fun Machine", + "width": 200, + "uploaded_by_user": [ + "root" + ] + } +}, +{ + "fields": { + "width": 3020, + "file_size": null, + "file": "original_images/hugo_manet.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 3020, + "focal_point_width": null, + "focal_point_y": null, + "title": "Hugo Manet", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 3 +}, +{ + "fields": { + "width": 1566, + "file_size": null, + "file": "original_images/lisa_gourdon.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 1634, + "focal_point_width": null, + "focal_point_y": null, + "title": "Lisa Gourdon", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 4 +}, +{ + "fields": { + "width": 117, + "file_size": null, + "file": "original_images/pierre_quesselaire.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 153, + "focal_point_width": null, + "focal_point_y": null, + "title": "Pierre Quesselaire", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 5 +}, +{ + "fields": { + "width": 606, + "file_size": null, + "file": "original_images/thibault_scoquart.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 487, + "focal_point_width": null, + "focal_point_y": null, + "title": "Thibault Scoquard", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 6 +}, +{ + "fields": { + "width": 640, + "file_size": null, + "file": "original_images/arnaud_fanthomme.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 320, + "focal_point_width": null, + "focal_point_y": null, + "title": "Arnaud Fanthomme", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 7 +}, +{ + "fields": { + "width": 125, + "file_size": null, + "file": "original_images/vincent_balerdi.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 163, + "focal_point_width": null, + "focal_point_y": null, + "title": "Vincent Balerdi", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 8 +}, +{ + "fields": { + "width": 125, + "file_size": null, + "file": "original_images/nathanel_willaime.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 176, + "focal_point_width": null, + "focal_point_y": null, + "title": "Nathana\u00ebl Willaime", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 9 +}, +{ + "fields": { + "width": 125, + "file_size": null, + "file": "original_images/elisabeth_miller.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 146, + "focal_point_width": null, + "focal_point_y": null, + "title": "\u00c9lisabeth Miller", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 10 +}, +{ + "fields": { + "width": 720, + "file_size": null, + "file": "original_images/arthur_lesage.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 720, + "focal_point_width": null, + "focal_point_y": null, + "title": "Arthur Lesage", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 11 +}, +{ + "fields": { + "width": 445, + "file_size": null, + "file": "original_images/sarah_asset.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 436, + "focal_point_width": null, + "focal_point_y": null, + "title": "Sarah Asset", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 12 +}, +{ + "fields": { + "width": 480, + "file_size": null, + "file": "original_images/alexandre_legrand.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 360, + "focal_point_width": null, + "focal_point_y": null, + "title": "Alexandre Legrand", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 13 +}, +{ + "fields": { + "width": 4608, + "file_size": null, + "file": "original_images/etienne_baudel.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 3456, + "focal_point_width": null, + "focal_point_y": null, + "title": "\u00c9tienne Baudel", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 14 +}, +{ + "fields": { + "width": 358, + "file_size": null, + "file": "original_images/marine_snape.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 435, + "focal_point_width": null, + "focal_point_y": null, + "title": "Marine Snape", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 15 +}, +{ + "fields": { + "width": 121, + "file_size": null, + "file": "original_images/anatole_gosset.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 200, + "focal_point_width": null, + "focal_point_y": null, + "title": "Anatole Gosset", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 16 +}, +{ + "fields": { + "width": 253, + "file_size": null, + "file": "original_images/jacko_rastikian.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 338, + "focal_point_width": null, + "focal_point_y": null, + "title": "Jacko Rastikian", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 17 +}, +{ + "fields": { + "width": 285, + "file_size": null, + "file": "original_images/alexandre_jannaud.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 380, + "focal_point_width": null, + "focal_point_y": null, + "title": "Alexandre Jannaud", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 18 +}, +{ + "fields": { + "width": 283, + "file_size": null, + "file": "original_images/aurelien_delobelle.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 371, + "focal_point_width": null, + "focal_point_y": null, + "title": "Aur\u00e9lien Delobelle", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 19 +}, +{ + "fields": { + "width": 125, + "file_size": null, + "file": "original_images/sylvain_douteau.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 161, + "focal_point_width": null, + "focal_point_y": null, + "title": "Sylvain Douteau", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 20 +}, +{ + "fields": { + "width": 125, + "file_size": null, + "file": "original_images/raphael_lescanne.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 176, + "focal_point_width": null, + "focal_point_y": null, + "title": "Rapha\u00ebl Lescanne", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 21 +}, +{ + "fields": { + "width": 124, + "file_size": null, + "file": "original_images/romain_gourvil.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 157, + "focal_point_width": null, + "focal_point_y": null, + "title": "Romain Gourvil", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 22 +}, +{ + "fields": { + "width": 133, + "file_size": null, + "file": "original_images/marie_labeye.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 163, + "focal_point_width": null, + "focal_point_y": null, + "title": "Marie Labeye", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 23 +}, +{ + "fields": { + "width": 127, + "file_size": null, + "file": "original_images/oscar_blumberg.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 159, + "focal_point_width": null, + "focal_point_y": null, + "title": "Oscar Blumberg", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 24 +}, +{ + "fields": { + "width": 210, + "file_size": null, + "file": "original_images/zaid_allybokus.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 311, + "focal_point_width": null, + "focal_point_y": null, + "title": "Za\u00efd Allybokus", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 25 +}, +{ + "fields": { + "width": 495, + "file_size": null, + "file": "original_images/damien_garreau.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 548, + "focal_point_width": null, + "focal_point_y": null, + "title": "Damien Garreau", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 26 +}, +{ + "fields": { + "width": 323, + "file_size": null, + "file": "original_images/andrea_londono.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 458, + "focal_point_width": null, + "focal_point_y": null, + "title": "Andr\u00e9a Londono-Lopez", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 27 +}, +{ + "fields": { + "width": 120, + "file_size": null, + "file": "original_images/tristan_roussel.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 155, + "focal_point_width": null, + "focal_point_y": null, + "title": "Tristan Roussel", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 28 +}, +{ + "fields": { + "width": 427, + "file_size": null, + "file": "original_images/guillaume_vernade.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 640, + "focal_point_width": null, + "focal_point_y": null, + "title": "Guillaume Vernade", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 29 +}, +{ + "fields": { + "width": 2304, + "file_size": null, + "file": "original_images/lucas_mercier.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 3020, + "focal_point_width": null, + "focal_point_y": null, + "title": "Lucas Mercier", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 30 +}, +{ + "fields": { + "width": 199, + "file_size": null, + "file": "original_images/francois_maillot.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 240, + "focal_point_width": null, + "focal_point_y": null, + "title": "Fran\u00e7ois Maillot", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 31 +}, +{ + "fields": { + "width": 965, + "file_size": null, + "file": "original_images/fabrice_catoire.jpg", + "focal_point_height": null, + "focal_point_x": null, + "height": 1255, + "focal_point_width": null, + "focal_point_y": null, + "title": "Fabrice Catoire", + "collection": 2, + "uploaded_by_user": [ + "root" + ], + "created_at": "2017-05-30T04:20:00.000Z" + }, + "model": "wagtailimages.image", + "pk": 32 +}, +{ + "model": "wagtailmenus.flatmenu", + "fields": { + "max_levels": 1, + "handle": "kfet-nav", + "site": [ + "localhost", + 8000 + ], + "use_specific": 1, + "heading": "", + "title": "K-F\u00eat - Navigation" + }, + "pk": 1 +}, +{ + "pk": 1, + "fields": { + "link_page": 3, + "menu": 1, + "allow_subnav": true, + "handle": "", + "link_text": "Accueil", + "link_url": "", + "sort_order": 0, + "url_append": "" + }, + "model": "wagtailmenus.flatmenuitem" +}, +{ + "pk": 2, + "fields": { + "link_page": 4, + "menu": 1, + "allow_subnav": true, + "handle": "", + "link_text": "", + "link_url": "", + "sort_order": 1, + "url_append": "" + }, + "model": "wagtailmenus.flatmenuitem" +}, +{ + "pk": 3, + "fields": { + "link_page": 5, + "menu": 1, + "allow_subnav": true, + "handle": "", + "link_text": "", + "link_url": "", + "sort_order": 2, + "url_append": "" + }, + "model": "wagtailmenus.flatmenuitem" +}, +{ + "pk": 4, + "fields": { + "link_page": 6, + "menu": 1, + "allow_subnav": true, + "handle": "", + "link_text": "", + "link_url": "", + "sort_order": 3, + "url_append": "" + }, + "model": "wagtailmenus.flatmenuitem" +}, +{ + "pk": 5, + "fields": { + "link_page": 7, + "menu": 1, + "allow_subnav": true, + "handle": "", + "link_text": "", + "link_url": "", + "sort_order": 4, + "url_append": "" + }, + "model": "wagtailmenus.flatmenuitem" +}, +{ + "pk": 6, + "fields": { + "link_page": 8, + "menu": 1, + "allow_subnav": true, + "handle": "", + "link_text": "", + "link_url": "", + "sort_order": 5, + "url_append": "" + }, + "model": "wagtailmenus.flatmenuitem" +} +] diff --git a/kfet/cms/hooks.py b/kfet/cms/hooks.py new file mode 100644 index 00000000..e58aeef5 --- /dev/null +++ b/kfet/cms/hooks.py @@ -0,0 +1,12 @@ +from django.contrib.staticfiles.templatetags.staticfiles import static +from django.utils.html import format_html + +from wagtail.wagtailcore import hooks + + +@hooks.register('insert_editor_css') +def editor_css(): + return format_html( + '', + static('kfetcms/css/editor.css'), + ) diff --git a/kfet/cms/management/commands/kfet_loadwagtail.py b/kfet/cms/management/commands/kfet_loadwagtail.py new file mode 100644 index 00000000..86b94d3e --- /dev/null +++ b/kfet/cms/management/commands/kfet_loadwagtail.py @@ -0,0 +1,35 @@ +from django.contrib.auth.models import Group +from django.core.management import call_command +from django.core.management.base import BaseCommand + +from wagtail.wagtailcore.models import Page, Site + + +class Command(BaseCommand): + help = "Importe des données pour Wagtail" + + def add_arguments(self, parser): + parser.add_argument('--file', default='kfet_wagtail_17_05') + + def handle(self, *args, **options): + + self.stdout.write("Import des données wagtail") + + # Nettoyage des données initiales posées par Wagtail dans la migration + # wagtailcore/0002 + + Group.objects.filter(name__in=('Moderators', 'Editors')).delete() + + try: + homepage = Page.objects.get( + title="Welcome to your new Wagtail site!" + ) + homepage.delete() + Site.objects.filter(root_page=homepage).delete() + except Page.DoesNotExist: + pass + + # Import des données + # Par défaut, il s'agit d'une copie du site K-Fêt (17-05) + + call_command('loaddata', options['file']) diff --git a/kfet/cms/migrations/0001_initial.py b/kfet/cms/migrations/0001_initial.py new file mode 100644 index 00000000..951637c7 --- /dev/null +++ b/kfet/cms/migrations/0001_initial.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import wagtail.wagtailsnippets.blocks +import wagtail.wagtailcore.blocks +import wagtail.wagtailcore.fields +import django.db.models.deletion +import kfet.cms.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0033_remove_golive_expiry_help_text'), + ('wagtailimages', '0019_delete_filter'), + ] + + operations = [ + migrations.CreateModel( + name='KFetPage', + fields=[ + ('page_ptr', models.OneToOneField(serialize=False, primary_key=True, parent_link=True, auto_created=True, to='wagtailcore.Page')), + ('no_header', models.BooleanField(verbose_name='Sans en-tête', help_text="Coché, l'en-tête (avec le titre) de la page n'est pas affiché.", default=False)), + ('content', wagtail.wagtailcore.fields.StreamField((('rich', wagtail.wagtailcore.blocks.RichTextBlock(label='Éditeur')), ('carte', kfet.cms.models.MenuBlock()), ('group_team', wagtail.wagtailcore.blocks.StructBlock((('show_only', wagtail.wagtailcore.blocks.IntegerBlock(help_text='Nombre initial de membres affichés. Laisser vide pour tou-te-s les afficher.', required=False, label='Montrer seulement')), ('members', wagtail.wagtailcore.blocks.ListBlock(wagtail.wagtailsnippets.blocks.SnippetChooserBlock(kfet.cms.models.MemberTeam), classname='team-group', label='K-Fêt-eux-ses'))))), ('group', wagtail.wagtailcore.blocks.StreamBlock((('rich', wagtail.wagtailcore.blocks.RichTextBlock(label='Éditeur')), ('carte', kfet.cms.models.MenuBlock()), ('group_team', wagtail.wagtailcore.blocks.StructBlock((('show_only', wagtail.wagtailcore.blocks.IntegerBlock(help_text='Nombre initial de membres affichés. Laisser vide pour tou-te-s les afficher.', required=False, label='Montrer seulement')), ('members', wagtail.wagtailcore.blocks.ListBlock(wagtail.wagtailsnippets.blocks.SnippetChooserBlock(kfet.cms.models.MemberTeam), classname='team-group', label='K-Fêt-eux-ses')))))), label='Contenu groupé'))), verbose_name='Contenu')), + ('layout', models.CharField(max_length=255, choices=[('kfet/base_col_1.html', 'Une colonne : centrée sur la page'), ('kfet/base_col_2.html', 'Deux colonnes : fixe à gauche, contenu à droite'), ('kfet/base_col_mult.html', 'Contenu scindé sur plusieurs colonnes')], help_text='Comment cette page devrait être affichée ?', verbose_name='Template', default='kfet/base_col_mult.html')), + ('main_size', models.CharField(max_length=255, blank=True, verbose_name='Taille de la colonne de contenu')), + ('col_count', models.CharField(max_length=255, blank=True, verbose_name='Nombre de colonnes', help_text="S'applique au page dont le contenu est scindé sur plusieurs colonnes")), + ], + options={ + 'verbose_name': 'page K-Fêt', + 'verbose_name_plural': 'pages K-Fêt', + }, + bases=('wagtailcore.page',), + ), + migrations.CreateModel( + name='MemberTeam', + fields=[ + ('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)), + ('first_name', models.CharField(blank=True, max_length=255, verbose_name='Prénom', default='')), + ('last_name', models.CharField(blank=True, max_length=255, verbose_name='Nom', default='')), + ('nick_name', models.CharField(verbose_name='Alias', blank=True, default='', max_length=255)), + ('photo', models.ForeignKey(null=True, related_name='+', on_delete=django.db.models.deletion.SET_NULL, verbose_name='Photo', blank=True, to='wagtailimages.Image')), + ], + options={ + 'verbose_name': 'K-Fêt-eux-se', + }, + ), + ] diff --git a/kfet/cms/migrations/0002_alter_kfetpage_colcount.py b/kfet/cms/migrations/0002_alter_kfetpage_colcount.py new file mode 100644 index 00000000..fe91d3e6 --- /dev/null +++ b/kfet/cms/migrations/0002_alter_kfetpage_colcount.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('kfetcms', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='kfetpage', + name='col_count', + field=models.CharField(blank=True, max_length=255, verbose_name='Nombre de colonnes', help_text="S'applique au page dont le contenu est scindé sur plusieurs colonnes."), + ), + ] diff --git a/kfet/cms/migrations/__init__.py b/kfet/cms/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/kfet/cms/models.py b/kfet/cms/models.py new file mode 100644 index 00000000..0dff183f --- /dev/null +++ b/kfet/cms/models.py @@ -0,0 +1,174 @@ +from django.db import models +from django.utils.translation import ugettext_lazy as _ + +from wagtail.wagtailadmin.edit_handlers import ( + FieldPanel, FieldRowPanel, MultiFieldPanel, StreamFieldPanel +) +from wagtail.wagtailcore import blocks +from wagtail.wagtailcore.fields import StreamField +from wagtail.wagtailcore.models import Page +from wagtail.wagtailimages.edit_handlers import ImageChooserPanel +from wagtail.wagtailsnippets.blocks import SnippetChooserBlock +from wagtail.wagtailsnippets.models import register_snippet + +from kfet.cms.context_processors import get_articles + + +@register_snippet +class MemberTeam(models.Model): + first_name = models.CharField( + verbose_name=_('Prénom'), + blank=True, default='', max_length=255, + ) + last_name = models.CharField( + verbose_name=_('Nom'), + blank=True, default='', max_length=255, + ) + nick_name = models.CharField( + verbose_name=_('Alias'), + blank=True, default='', max_length=255, + ) + photo = models.ForeignKey( + 'wagtailimages.Image', + verbose_name=_('Photo'), + on_delete=models.SET_NULL, + null=True, blank=True, + related_name='+', + ) + + class Meta: + verbose_name = _('K-Fêt-eux-se') + + panels = [ + FieldPanel('first_name'), + FieldPanel('last_name'), + FieldPanel('nick_name'), + ImageChooserPanel('photo'), + ] + + def __str__(self): + return self.get_full_name() + + def get_full_name(self): + return '{} {}'.format(self.first_name, self.last_name).strip() + + +class MenuBlock(blocks.StaticBlock): + class Meta: + icon = 'list-ul' + label = _('Carte') + template = 'kfetcms/block_menu.html' + + def get_context(self, *args, **kwargs): + context = super().get_context(*args, **kwargs) + context.update(get_articles()) + return context + + +class GroupTeamBlock(blocks.StructBlock): + show_only = blocks.IntegerBlock( + label=_('Montrer seulement'), + required=False, + help_text=_( + 'Nombre initial de membres affichés. Laisser vide pour tou-te-s ' + 'les afficher.' + ), + ) + members = blocks.ListBlock( + SnippetChooserBlock(MemberTeam), + label=_('K-Fêt-eux-ses'), + classname='team-group', + ) + + class Meta: + icon = 'group' + label = _('Groupe de K-Fêt-eux-ses') + template = 'kfetcms/block_teamgroup.html' + + +class ChoicesStreamBlock(blocks.StreamBlock): + rich = blocks.RichTextBlock(label=_('Éditeur')) + carte = MenuBlock() + group_team = GroupTeamBlock() + + +class KFetStreamBlock(ChoicesStreamBlock): + group = ChoicesStreamBlock(label=_('Contenu groupé')) + + +class KFetPage(Page): + + content = StreamField(KFetStreamBlock, verbose_name=_('Contenu')) + + # Layout fields + + TEMPLATE_COL_1 = 'kfet/base_col_1.html' + TEMPLATE_COL_2 = 'kfet/base_col_2.html' + TEMPLATE_COL_MULT = 'kfet/base_col_mult.html' + + no_header = models.BooleanField( + verbose_name=_('Sans en-tête'), + default=False, + help_text=_( + "Coché, l'en-tête (avec le titre) de la page n'est pas affiché." + ), + ) + layout = models.CharField( + verbose_name=_('Template'), + choices=[ + (TEMPLATE_COL_1, _('Une colonne : centrée sur la page')), + (TEMPLATE_COL_2, _('Deux colonnes : fixe à gauche, contenu à droite')), + (TEMPLATE_COL_MULT, _('Contenu scindé sur plusieurs colonnes')), + ], + default=TEMPLATE_COL_MULT, max_length=255, + help_text=_( + "Comment cette page devrait être affichée ?" + ), + ) + main_size = models.CharField( + verbose_name=_('Taille de la colonne de contenu'), + blank=True, max_length=255, + ) + col_count = models.CharField( + verbose_name=_('Nombre de colonnes'), + blank=True, max_length=255, + help_text=_( + "S'applique au page dont le contenu est scindé sur plusieurs colonnes." + ), + ) + + # Panels + + content_panels = Page.content_panels + [ + StreamFieldPanel('content'), + ] + + layout_panel = [ + FieldPanel('no_header'), + FieldPanel('layout'), + FieldRowPanel([ + FieldPanel('main_size'), + FieldPanel('col_count'), + ]), + ] + + settings_panels = [ + MultiFieldPanel(layout_panel, _('Affichage')) + ] + Page.settings_panels + + # Base template + template = "kfetcms/base.html" + + class Meta: + verbose_name = _('page K-Fêt') + verbose_name_plural = _('pages K-Fêt') + + def get_context(self, request, *args, **kwargs): + context = super().get_context(request, *args, **kwargs) + + page = context['page'] + + if not page.seo_title: + page.seo_title = page.title + + return context diff --git a/kfet/cms/static/kfetcms/css/base.css b/kfet/cms/static/kfetcms/css/base.css new file mode 100644 index 00000000..b580ef94 --- /dev/null +++ b/kfet/cms/static/kfetcms/css/base.css @@ -0,0 +1,93 @@ +.main.cms { + padding: 20px 15px; +} + +@media (min-width: 768px) { + .main.cms { + padding: 35px 30px; + } +} + +.cms { + text-align: justify; + font-size: 1.1em; +} + +@media (min-width:768px) { + .cms { + font-size: 1.2em; + line-height: 1.6em; + } +} + +/* Titles */ + +.cms h2, .cms h3 { + clear: both; + margin: 0 0 15px; + padding-bottom: 10px; + border-bottom: 1px solid #c8102e; + text-align: left; + font-weight: bold; +} + +@media (min-width: 768px) { + .cms h2, .cms h3 { + padding-bottom: 15px; + } +} + +/* Paragraphs */ + +.cms p { + margin-bottom: 20px; + text-indent: 2em; +} + +.cms p + :not(h2):not(h3):not(div) { + margin-top: -10px; +} + +@media (min-width: 768px) { + .cms p { + padding-bottom: 15px; + } + + .cms p + :not(h2):not(h3):not(div) { + margin-top: -30px; + } +} + + +/* Lists */ + +.cms ol, .cms ul { + padding: 0 0 0 15px; + margin: 0 0 10px; +} + +.cms ul { + list-style-type: square; +} + +.cms ol > li, .cms ul > li { + padding-left: 5px; +} + + +/* Images */ + +.cms .richtext-image { + max-height: 100%; + margin: 5px 0 15px; +} + +.cms .richtext-image.left { + float: left; + margin-right: 30px; +} + +.cms .richtext-image.right { + float: right; + margin-left: 30px; +} diff --git a/kfet/cms/static/kfetcms/css/editor.css b/kfet/cms/static/kfetcms/css/editor.css new file mode 100644 index 00000000..f97e9895 --- /dev/null +++ b/kfet/cms/static/kfetcms/css/editor.css @@ -0,0 +1,18 @@ +.snippets.listing thead, .snippets.listing thead tr { + border: 0; +} + +.snippets.listing tbody { + display: block; + column-count: 2; +} + +.snippets.listing tbody tr { + display: block; +} + +@media (min-width: 992px) { + .snippets.listing tbody { + column-count: 3; + } +} diff --git a/kfet/cms/static/kfetcms/css/index.css b/kfet/cms/static/kfetcms/css/index.css new file mode 100644 index 00000000..647515e3 --- /dev/null +++ b/kfet/cms/static/kfetcms/css/index.css @@ -0,0 +1,3 @@ +@import url("base.css"); +@import url("menu.css"); +@import url("team.css"); diff --git a/kfet/cms/static/kfetcms/css/menu.css b/kfet/cms/static/kfetcms/css/menu.css new file mode 100644 index 00000000..f1952c69 --- /dev/null +++ b/kfet/cms/static/kfetcms/css/menu.css @@ -0,0 +1,58 @@ +.carte { + margin-bottom: 15px; + font-family: "Roboto Slab"; +} + +.carte .carte-title { + padding-top: 0; + margin-top: 0; + margin-bottom: 0; +} + +.carte .carte-list { + width: 100%; + padding: 15px; + list-style-type: none; +} + +.carte .carte-item { + position: relative; + text-align: right; + white-space: nowrap; + padding: 0; +} + +.carte .carte-item .filler { + position: absolute; + left: 0; + right: 0; + border-bottom: 2px dotted #333; + height: 75%; +} + +.carte .carte-item > span { + position: relative; +} + +.carte .carte-item .carte-label { + background: white; + float: left; + padding-right: 10px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} + +.carte .carte-item .carte-ukf { + padding: 0 10px; + background: #ffdbc7; +} + +.carte-inverted .carte-list, +.carte-inverted .carte-item .carte-label { + background: #ffdbc7; +} + +.carte-inverted .carte-item .carte-ukf { + background: white; +} diff --git a/kfet/cms/static/kfetcms/css/team.css b/kfet/cms/static/kfetcms/css/team.css new file mode 100644 index 00000000..e663fc66 --- /dev/null +++ b/kfet/cms/static/kfetcms/css/team.css @@ -0,0 +1,47 @@ +.team-group { + margin-bottom: 20px; +} + +.team-group .col-btn { + margin-bottom: 20px; +} + +.team-group .member-more { + display: none; +} + +.team-member { + padding: 0; + margin-bottom: 20px; + min-height: 190px; + background-color: inherit; + border: 0; +} + +.team-member img { + max-width: 100%; + max-height: 125px; + width: auto; + height: auto; + display: block; +} + +.team-member .infos { + height: 50px; + margin-top: 15px; +} + +@media (min-width: 768px) { + .team-group { + margin-left: 20px; + margin-right: 20px; + } + + .team-member { + min-height: 215px; + } + + .team-member img { + max-height: 150px; + } +} diff --git a/kfet/cms/templates/kfetcms/base.html b/kfet/cms/templates/kfetcms/base.html new file mode 100644 index 00000000..3b9f40d6 --- /dev/null +++ b/kfet/cms/templates/kfetcms/base.html @@ -0,0 +1,41 @@ +{% extends page.layout %} +{% load static wagtailcore_tags wagtailuserbar %} + +{# CSS/JS #} + +{% block extra_head %} +{{ block.super }} + +{% endblock %} + +{# Titles #} + +{% block title %}{{ page.seo_title }}{% endblock %} +{% block header-title %}{{ page.title }}{% endblock %} + +{# Layout #} + +{% block main-size %}{{ page.main_size|default:block.super }}{% endblock %} +{% block mult-count %}{{ page.col_count|default:block.super }}{% endblock %} + +{% block main-class %}cms main-bg{% endblock %} + +{# Content #} + +{% block main %} + +{% for block in page.content %} +
- L'h\\u00e9bergement est fourni \\u00e0 titre gracieux par le CRI:
\\u00c9cole Normale Sup\\u00e9rieure
Centre de Ressources Informatiques
45 rue d'Ulm
75005 Paris- Le d\\u00e9veloppement est assur\\u00e9 par COF-Geek.
+ {% include_block block %} ++{% endfor %} + +{% wagtailuserbar %} + +{% endblock %} + +{# Footer #} + +{% block footer %} +{% include "kfet/base_footer.html" %} +{% endblock %} diff --git a/kfet/cms/templates/kfetcms/block_menu.html b/kfet/cms/templates/kfetcms/block_menu.html new file mode 100644 index 00000000..382a7770 --- /dev/null +++ b/kfet/cms/templates/kfetcms/block_menu.html @@ -0,0 +1,11 @@ +{% load static %} + +{% if pressions %} + {% include "kfetcms/block_menu_category.html" with title="Pressions du moment" articles=pressions class="carte-inverted" %} +{% endif %} + +{% regroup articles by category as categories %} + +{% for category in categories %} + {% include "kfetcms/block_menu_category.html" with title=category.grouper.name articles=category.list %} +{% endfor %} diff --git a/kfet/cms/templates/kfetcms/block_menu_category.html b/kfet/cms/templates/kfetcms/block_menu_category.html new file mode 100644 index 00000000..ef7d4ce0 --- /dev/null +++ b/kfet/cms/templates/kfetcms/block_menu_category.html @@ -0,0 +1,12 @@ ++diff --git a/kfet/cms/templates/kfetcms/block_teamgroup.html b/kfet/cms/templates/kfetcms/block_teamgroup.html new file mode 100644 index 00000000..fab43d68 --- /dev/null +++ b/kfet/cms/templates/kfetcms/block_teamgroup.html @@ -0,0 +1,66 @@ +{% load wagtailcore_tags wagtailimages_tags %} + + +{% with groupteam=value len=value.members|length %} + +{{ title }}
++ {% for article in articles %} +
+- + + {{ article.name }} + {{ article.price_ukf }} UKF +
+ {% endfor %} ++ + {% if len == 2 %} + + {% endif %} + + {% for member in groupteam.members %} ++ +{% endwith %} + + diff --git a/kfet/consumers.py b/kfet/consumers.py index ee096368..0f447d2d 100644 --- a/kfet/consumers.py +++ b/kfet/consumers.py @@ -1,39 +1,6 @@ # -*- coding: utf-8 -*- -from django.core.serializers.json import json, DjangoJSONEncoder - -from channels.generic.websockets import JsonWebsocketConsumer - - -class DjangoJsonWebsocketConsumer(JsonWebsocketConsumer): - """Custom Json Websocket Consumer. - - Encode to JSON with DjangoJSONEncoder. - - """ - - @classmethod - def encode_json(cls, content): - return json.dumps(content, cls=DjangoJSONEncoder) - - -class PermConsumerMixin(object): - """Add support to check permissions on Consumers. - - Attributes: - perms_connect (list): Required permissions to connect to this - consumer. - - """ - http_user = True # Enable message.user - perms_connect = [] - - def connect(self, message, **kwargs): - """Check permissions on connection.""" - if message.user.has_perms(self.perms_connect): - super().connect(message, **kwargs) - else: - self.close() +from .utils import DjangoJsonWebsocketConsumer, PermConsumerMixin class KPsul(PermConsumerMixin, DjangoJsonWebsocketConsumer): diff --git a/kfet/forms.py b/kfet/forms.py index 09c3a4d0..6ef3aefb 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -5,10 +5,9 @@ from decimal import Decimal from django import forms from django.core.exceptions import ValidationError -from django.core.validators import MinLengthValidator from django.contrib.auth.models import User, Group, Permission from django.contrib.contenttypes.models import ContentType -from django.forms import modelformset_factory +from django.forms import modelformset_factory, widgets from django.utils import timezone from djconfig.forms import ConfigForm @@ -25,18 +24,17 @@ from gestioncof.models import CofProfile # ----- class DateTimeWidget(forms.DateTimeInput): - def __init__(self, attrs = None): - super(DateTimeWidget, self).__init__(attrs) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) self.attrs['format'] = '%Y-%m-%d %H:%M' + class Media: css = { - 'all': ('kfet/css/bootstrap-datetimepicker.min.css',) - } - js = ( - 'kfet/js/moment.js', - 'kfet/js/moment-fr.js', - 'kfet/js/bootstrap-datetimepicker.min.js', - ) + 'all': ('kfet/css/bootstrap-datetimepicker.min.css',) + } + js = ('kfet/js/bootstrap-datetimepicker.min.js',) + + # ----- # Account forms # ----- @@ -111,21 +109,16 @@ class CofRestrictForm(CofForm): class Meta(CofForm.Meta): fields = ['departement'] -class UserForm(forms.ModelForm): - def __init__(self, *args, **kwargs): - from_clipper = kwargs.pop('from_clipper', False) - new_user = kwargs.get('instance') is None and not from_clipper - super(UserForm, self).__init__(*args, **kwargs) - if new_user: - self.fields['username'].validators = [MinLengthValidator(9)] +class UserForm(forms.ModelForm): class Meta: - model = User + model = User fields = ['username', 'first_name', 'last_name', 'email'] help_texts = { 'username': '' } + class UserRestrictForm(UserForm): class Meta(UserForm.Meta): fields = ['first_name', 'last_name'] @@ -151,19 +144,45 @@ class UserGroupForm(forms.ModelForm): fields = ['groups'] +class KFetPermissionsField(forms.ModelMultipleChoiceField): + + def __init__(self, *args, **kwargs): + queryset = Permission.objects.filter( + content_type__in=ContentType.objects.filter(app_label="kfet"), + ) + super().__init__( + queryset=queryset, + widget=widgets.CheckboxSelectMultiple, + *args, **kwargs + ) + + def label_from_instance(self, obj): + return obj.name + + class GroupForm(forms.ModelForm): - permissions = forms.ModelMultipleChoiceField( - queryset= Permission.objects.filter(content_type__in= - ContentType.objects.filter(app_label='kfet'))) + permissions = KFetPermissionsField() def clean_name(self): name = self.cleaned_data['name'] return 'K-Fêt %s' % name + def clean_permissions(self): + kfet_perms = self.cleaned_data['permissions'] + # TODO: With Django >=1.11, the QuerySet method 'difference' can be used. + # other_groups = self.instance.permissions.difference( + # self.fields['permissions'].queryset + # ) + other_perms = self.instance.permissions.exclude( + pk__in=[p.pk for p in self.fields['permissions'].queryset], + ) + return list(kfet_perms) + list(other_perms) + class Meta: - model = Group + model = Group fields = ['name', 'permissions'] + class AccountNegativeForm(forms.ModelForm): class Meta: model = AccountNegative @@ -445,8 +464,11 @@ class KFetConfigForm(ConfigForm): class FilterHistoryForm(forms.Form): - checkouts = forms.ModelMultipleChoiceField(queryset = Checkout.objects.all()) - accounts = forms.ModelMultipleChoiceField(queryset = Account.objects.all()) + checkouts = forms.ModelMultipleChoiceField(queryset=Checkout.objects.all()) + accounts = forms.ModelMultipleChoiceField(queryset=Account.objects.all()) + from_date = forms.DateTimeField(widget=DateTimeWidget) + to_date = forms.DateTimeField(widget=DateTimeWidget) + # ----- # Transfer forms @@ -525,11 +547,7 @@ class OrderArticleForm(forms.Form): self.category = kwargs['initial']['category'] self.category_name = kwargs['initial']['category__name'] self.box_capacity = kwargs['initial']['box_capacity'] - self.v_s1 = kwargs['initial']['v_s1'] - self.v_s2 = kwargs['initial']['v_s2'] - self.v_s3 = kwargs['initial']['v_s3'] - self.v_s4 = kwargs['initial']['v_s4'] - self.v_s5 = kwargs['initial']['v_s5'] + self.v_all = kwargs['initial']['v_all'] self.v_moy = kwargs['initial']['v_moy'] self.v_et = kwargs['initial']['v_et'] self.v_prev = kwargs['initial']['v_prev'] diff --git a/kfet/management/commands/loadkfetdevdata.py b/kfet/management/commands/loadkfetdevdata.py index 7f2ec9a3..6dd25f29 100644 --- a/kfet/management/commands/loadkfetdevdata.py +++ b/kfet/management/commands/loadkfetdevdata.py @@ -147,3 +147,9 @@ class Command(MyBaseCommand): # --- call_command('createopes', '100', '7', '--transfers=20') + + # --- + # Wagtail CMS + # --- + + call_command('kfet_loadwagtail') diff --git a/kfet/migrations/0054_update_promos.py b/kfet/migrations/0054_update_promos.py new file mode 100644 index 00000000..2691e903 --- /dev/null +++ b/kfet/migrations/0054_update_promos.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('kfet', '0053_created_at'), + ] + + operations = [ + migrations.AlterField( + model_name='account', + name='promo', + field=models.IntegerField(blank=True, choices=[(1980, 1980), (1981, 1981), (1982, 1982), (1983, 1983), (1984, 1984), (1985, 1985), (1986, 1986), (1987, 1987), (1988, 1988), (1989, 1989), (1990, 1990), (1991, 1991), (1992, 1992), (1993, 1993), (1994, 1994), (1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017)], default=2017, null=True), + ), + ] diff --git a/kfet/migrations/0055_move_permissions.py b/kfet/migrations/0055_move_permissions.py new file mode 100644 index 00000000..a418124c --- /dev/null +++ b/kfet/migrations/0055_move_permissions.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +def forwards_perms(apps, schema_editor): + """Safely delete content type for old kfet.GlobalPermissions model. + + Any permissions (except defaults) linked to this content type are updated + to link at its new content type. + Then, delete the content type. This will delete the three defaults + permissions which are assumed unused. + + """ + ContentType = apps.get_model('contenttypes', 'contenttype') + try: + ctype_global = ContentType.objects.get( + app_label="kfet", model="globalpermissions", + ) + except ContentType.DoesNotExist: + # We are not migrating from existing data, nothing to do. + return + + perms = { + 'account': ( + 'is_team', 'manage_perms', 'manage_addcosts', + 'edit_balance_account', 'change_account_password', + 'special_add_account', + ), + 'accountnegative': ('view_negs',), + 'inventory': ('order_to_inventory',), + 'operation': ( + 'perform_deposit', 'perform_negative_operations', + 'override_frozen_protection', 'cancel_old_operations', + 'perform_commented_operations', + ), + } + + Permission = apps.get_model('auth', 'permission') + global_perms = Permission.objects.filter(content_type=ctype_global) + + for modelname, codenames in perms.items(): + model = apps.get_model('kfet', modelname) + ctype = ContentType.objects.get_for_model(model) + ( + global_perms + .filter(codename__in=codenames) + .update(content_type=ctype) + ) + + ctype_global.delete() + + +class Migration(migrations.Migration): + + dependencies = [ + ('kfet', '0054_delete_settings'), + ('contenttypes', '__latest__'), + ('auth', '__latest__'), + ] + + operations = [ + migrations.AlterModelOptions( + name='account', + options={'permissions': (('is_team', 'Is part of the team'), ('manage_perms', 'Gérer les permissions K-Fêt'), ('manage_addcosts', 'Gérer les majorations'), ('edit_balance_account', "Modifier la balance d'un compte"), ('change_account_password', "Modifier le mot de passe d'une personne de l'équipe"), ('special_add_account', 'Créer un compte avec une balance initiale'))}, + ), + migrations.AlterModelOptions( + name='accountnegative', + options={'permissions': (('view_negs', 'Voir la liste des négatifs'),)}, + ), + migrations.AlterModelOptions( + name='inventory', + options={'ordering': ['-at'], 'permissions': (('order_to_inventory', "Générer un inventaire à partir d'une commande"),)}, + ), + migrations.AlterModelOptions( + name='operation', + options={'permissions': (('perform_deposit', 'Effectuer une charge'), ('perform_negative_operations', 'Enregistrer des commandes en négatif'), ('override_frozen_protection', "Forcer le gel d'un compte"), ('cancel_old_operations', 'Annuler des commandes non récentes'), ('perform_commented_operations', 'Enregistrer des commandes avec commentaires'))}, + ), + migrations.RunPython(forwards_perms), + ] diff --git a/kfet/migrations/0056_change_account_meta.py b/kfet/migrations/0056_change_account_meta.py new file mode 100644 index 00000000..3992bf3c --- /dev/null +++ b/kfet/migrations/0056_change_account_meta.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('kfet', '0055_move_permissions'), + ] + + operations = [ + migrations.AlterModelOptions( + name='account', + options={'permissions': (('is_team', 'Is part of the team'), ('manage_perms', 'Gérer les permissions K-Fêt'), ('manage_addcosts', 'Gérer les majorations'), ('edit_balance_account', "Modifier la balance d'un compte"), ('change_account_password', "Modifier le mot de passe d'une personne de l'équipe"), ('special_add_account', 'Créer un compte avec une balance initiale'), ('can_force_close', 'Fermer manuellement la K-Fêt'))}, + ), + ] diff --git a/kfet/migrations/0057_merge.py b/kfet/migrations/0057_merge.py new file mode 100644 index 00000000..48f63399 --- /dev/null +++ b/kfet/migrations/0057_merge.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('kfet', '0056_change_account_meta'), + ('kfet', '0054_update_promos'), + ] + + operations = [ + ] diff --git a/kfet/models.py b/kfet/models.py index cc35df18..ec146ad9 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -14,7 +14,8 @@ from datetime import date import re import hashlib -from kfet.config import kfet_config +from .config import kfet_config +from .utils import to_ukf def choices_length(choices): return reduce(lambda m, choice: max(m, len(choice[0])), choices, 0) @@ -63,10 +64,23 @@ class Account(models.Model): unique = True, blank = True, null = True, default = None) + class Meta: + permissions = ( + ('is_team', 'Is part of the team'), + ('manage_perms', 'Gérer les permissions K-Fêt'), + ('manage_addcosts', 'Gérer les majorations'), + ('edit_balance_account', "Modifier la balance d'un compte"), + ('change_account_password', + "Modifier le mot de passe d'une personne de l'équipe"), + ('special_add_account', + "Créer un compte avec une balance initiale"), + ('can_force_close', "Fermer manuellement la K-Fêt"), + ) + def __str__(self): return '%s (%s)' % (self.trigramme, self.name) - # Propriétés pour accéder aux attributs de user et cofprofile et user + # Propriétés pour accéder aux attributs de cofprofile et user @property def user(self): return self.cofprofile.user @@ -90,6 +104,10 @@ class Account(models.Model): return self.cofprofile.is_cof # Propriétés supplémentaires + @property + def balance_ukf(self): + return to_ukf(self.balance, is_cof=self.is_cof) + @property def real_balance(self): if hasattr(self, 'negative') and self.negative.balance_offset: @@ -108,6 +126,14 @@ class Account(models.Model): def need_comment(self): return self.trigramme == '#13' + @property + def readable(self): + return self.trigramme != 'GNR' + + @property + def is_team(self): + return self.has_perm('kfet.is_team') + @staticmethod def is_validandfree(trigramme): data = { 'is_valid' : False, 'is_free' : False } @@ -284,6 +310,15 @@ class AccountNegative(models.Model): ) comment = models.CharField("commentaire", max_length=255, blank=True) + class Meta: + permissions = ( + ('view_negs', 'Voir la liste des négatifs'), + ) + + @property + def until_default(self): + return self.start + kfet_config.overdraft_duration + class Checkout(models.Model): created_by = models.ForeignKey( @@ -436,6 +471,10 @@ class Article(models.Model): def get_absolute_url(self): return reverse('kfet.article.read', kwargs={'pk': self.pk}) + def price_ukf(self): + return to_ukf(self.price) + + class ArticleRule(models.Model): article_on = models.OneToOneField( Article, on_delete = models.PROTECT, @@ -462,6 +501,10 @@ class Inventory(models.Model): class Meta: ordering = ['-at'] + permissions = ( + ('order_to_inventory', "Générer un inventaire à partir d'une commande"), + ) + class InventoryArticle(models.Model): inventory = models.ForeignKey( @@ -638,6 +681,17 @@ class Operation(models.Model): max_digits=6, decimal_places=2, blank=True, null=True, default=None) + class Meta: + permissions = ( + ('perform_deposit', 'Effectuer une charge'), + ('perform_negative_operations', + 'Enregistrer des commandes en négatif'), + ('override_frozen_protection', "Forcer le gel d'un compte"), + ('cancel_old_operations', 'Annuler des commandes non récentes'), + ('perform_commented_operations', + 'Enregistrer des commandes avec commentaires'), + ) + @property def is_checkout(self): return (self.type == Operation.DEPOSIT or @@ -658,26 +712,5 @@ class Operation(models.Model): amount=self.amount) -class GlobalPermissions(models.Model): - class Meta: - managed = False - permissions = ( - ('is_team', 'Is part of the team'), - ('perform_deposit', 'Effectuer une charge'), - ('perform_negative_operations', - 'Enregistrer des commandes en négatif'), - ('override_frozen_protection', "Forcer le gel d'un compte"), - ('cancel_old_operations', 'Annuler des commandes non récentes'), - ('manage_perms', 'Gérer les permissions K-Fêt'), - ('manage_addcosts', 'Gérer les majorations'), - ('perform_commented_operations', 'Enregistrer des commandes avec commentaires'), - ('view_negs', 'Voir la liste des négatifs'), - ('order_to_inventory', "Générer un inventaire à partir d'une commande"), - ('edit_balance_account', "Modifier la balance d'un compte"), - ('change_account_password', "Modifier le mot de passe d'une personne de l'équipe"), - ('special_add_account', "Créer un compte avec une balance initiale") - ) - - class GenericTeamToken(models.Model): token = models.CharField(max_length = 50, unique = True) diff --git a/kfet/open/__init__.py b/kfet/open/__init__.py new file mode 100644 index 00000000..fb88af65 --- /dev/null +++ b/kfet/open/__init__.py @@ -0,0 +1 @@ +from .open import OpenKfet, kfet_open # noqa diff --git a/kfet/open/consumers.py b/kfet/open/consumers.py new file mode 100644 index 00000000..b28a4664 --- /dev/null +++ b/kfet/open/consumers.py @@ -0,0 +1,25 @@ +from ..decorators import kfet_is_team +from ..utils import DjangoJsonWebsocketConsumer, PermConsumerMixin + +from .open import kfet_open + + +class OpenKfetConsumer(PermConsumerMixin, DjangoJsonWebsocketConsumer): + """Consumer for K-Fêt Open. + + WS groups: + kfet.open.base: Only carries the values visible for all users. + kfet.open.team: Carries all values (raw status...). + + """ + + def connection_groups(self, user, **kwargs): + """Select which group the user should be connected.""" + if kfet_is_team(user): + return ['kfet.open.team'] + return ['kfet.open.base'] + + def connect(self, message, *args, **kwargs): + """Send current status on connect.""" + super().connect(message, *args, **kwargs) + self.send(kfet_open.export(message.user)) diff --git a/kfet/open/open.py b/kfet/open/open.py new file mode 100644 index 00000000..7fd90c21 --- /dev/null +++ b/kfet/open/open.py @@ -0,0 +1,109 @@ +from datetime import timedelta + +from django.utils import timezone + +from ..decorators import kfet_is_team +from ..utils import CachedMixin + + +class OpenKfet(CachedMixin, object): + """Manage "open" status of a place. + + Stores raw data (e.g. sent by raspberry), and user-set values + (as force_close). + Setting differents `cache_prefix` allows different places management. + Current state persists through cache. + + """ + # status is unknown after this duration + time_unknown = timedelta(minutes=15) + + # status + OPENED = 'opened' + CLOSED = 'closed' + UNKNOWN = 'unknown' + # admin status + FAKE_CLOSED = 'fake_closed' + + # cached attributes config + cached = { + '_raw_open': False, + '_last_update': None, + 'force_close': False, + } + cache_prefix = 'kfetopen' + + @property + def raw_open(self): + """Defined as property to update `last_update` on `raw_open` update.""" + return self._raw_open + + @raw_open.setter + def raw_open(self, value): + self._last_update = timezone.now() + self._raw_open = value + + @property + def last_update(self): + """Prevent `last_update` to be set.""" + return self._last_update + + @property + def is_open(self): + """Take into account force_close.""" + return False if self.force_close else self.raw_open + + def status(self): + if (self.last_update is None or + timezone.now() - self.last_update >= self.time_unknown): + return self.UNKNOWN + return self.OPENED if self.is_open else self.CLOSED + + def admin_status(self, status=None): + if status is None: + status = self.status() + if status == self.CLOSED and self.raw_open: + return self.FAKE_CLOSED + return status + + def _export(self): + """Export internal state. + + Used by WS initialization and updates. + + Returns: + (tuple): (base, team) + - team for team users. + - base for others. + + """ + status = self.status() + base = { + 'status': status, + } + restrict = { + 'admin_status': self.admin_status(status), + 'force_close': self.force_close, + } + return base, {**base, **restrict} + + def export(self, user): + """Export internal state for a given user. + + Returns: + (dict): Internal state. Only variables visible for the user are + exported, according to its permissions. + + """ + base, team = self._export() + return team if kfet_is_team(user) else base + + def send_ws(self): + """Send internal state to websocket channels.""" + from .consumers import OpenKfetConsumer + base, team = self._export() + OpenKfetConsumer.group_send('kfet.open.base', base) + OpenKfetConsumer.group_send('kfet.open.team', team) + + +kfet_open = OpenKfet() diff --git a/kfet/open/routing.py b/kfet/open/routing.py new file mode 100644 index 00000000..681bfab2 --- /dev/null +++ b/kfet/open/routing.py @@ -0,0 +1,8 @@ +from channels.routing import route_class + +from . import consumers + + +routing = [ + route_class(consumers.OpenKfetConsumer) +] diff --git a/kfet/open/static/kfetopen/kfet-open.css b/kfet/open/static/kfetopen/kfet-open.css new file mode 100644 index 00000000..a7068626 --- /dev/null +++ b/kfet/open/static/kfetopen/kfet-open.css @@ -0,0 +1,69 @@ +.kfetopen-st-opened .bullet { background: #73C252; } +.kfetopen-st-closed .bullet { background: #B42B26; } +.kfetopen-st-unknown .bullet { background: #D4BE4C; } +.kfetopen-st-fake_closed .bullet { + background: repeating-linear-gradient( + 45deg, + #73C252, #73C252 5px, #B42B26 5px, #B42B26 10px + ); +} + +.kfetopen { + float: left; +} + +.kfetopen .base { + height: 50px; + max-width: 16px; + + margin-left: 5px; + margin-right: 5px; + + display: flex; + flex-wrap: wrap; + align-content: center; + align-items: center; + justify-content: center; +} + +.kfetopen .details { + margin: 0; + padding: 10px !important; + min-width: 200px; + font-family: "Roboto Slab"; + font-size: 16px; + color: black; +} + +.kfetopen .bullet { + width: 10px; + height: 10px; + border-radius: 50%; + transition: background 0.15s; + margin: 3px; +} + +.kfetopen .warning { + display: none; +} + +@media (min-width: 576px) { + .kfetopen .base { + max-width: none; + margin-left: 15px; + margin-right: 15px; + } + + .kfetopen .warning { + margin-left: 15px; + } +} + +.kfetopen .status-text { + text-transform: uppercase; +} + +.kfetopen .force-close-btn { + width: 100%; + margin-top: 5px; +} diff --git a/kfet/open/static/kfetopen/kfet-open.js b/kfet/open/static/kfetopen/kfet-open.js new file mode 100644 index 00000000..74f18d8a --- /dev/null +++ b/kfet/open/static/kfetopen/kfet-open.js @@ -0,0 +1,113 @@ +var OpenWS = new KfetWebsocket({ + relative_url: "open/" +}); + +var OpenKfet = function(force_close_url, admin) { + this.force_close_url = force_close_url; + this.admin = admin; + + this.status = this.UNKNOWN; + this.dom = { + status_text: $('.kfetopen .status-text'), + force_close_btn: $('.kfetopen .force-close-btn'), + warning: $('.kfetopen .warning') + }, + + this.dom.force_close_btn.click( () => this.toggle_force_close() ); + setInterval( () => this.refresh(), this.refresh_interval * 1000); + OpenWS.add_handler( data => this.refresh(data) ); + +}; + +OpenKfet.prototype = { + // Status is unknown after . minutes without update. + time_unknown: 15, + // Maximum interval (seconds) between two UI refresh. + refresh_interval: 20, + + // Prefix for classes describing place status. + class_prefix: 'kfetopen-st-', + // Set status-classes on this dom element. + target: 'body', + + // Status + OPENED: "opened", + CLOSED: "closed", + UNKNOWN: "unknown", + + // Admin status + FAKE_CLOSED: "fake_closed", + + // Display values + status_text: { + opened: "ouverte", + closed: "fermée", + unknown: "_____" + }, + force_text: { + activate: "Fermer manuellement", + deactivate: "Réouvrir la K-Fêt" + }, + + get is_recent() { + return this.last_update && moment().diff(this.last_update, 'minute') <= this.time_unknown; + }, + + refresh: function(data) { + if (data) { + $.extend(this, data); + this.last_update = moment(); + } + if (!this.is_recent) + this.status = this.UNKNOWN; + this.refresh_dom(); + }, + + refresh_dom: function() { + let status = this.status; + this.clear_class(); + + this.add_class(status); + this.dom.status_text.html(this.status_text[status]); + + // admin specific + if (this.admin) { + this.add_class(this.admin_status); + if (this.force_close) { + this.dom.warning.show().addClass('in'); + this.dom.force_close_btn.html(this.force_text['deactivate']); + } else { + this.dom.warning.removeClass('in').hide(); + this.dom.force_close_btn.html(this.force_text['activate']); + } + } + }, + + toggle_force_close: function(password) { + $.post({ + url: this.force_close_url, + data: {force_close: !this.force_close}, + beforeSend: function ($xhr) { + $xhr.setRequestHeader("X-CSRFToken", csrftoken); + if (password !== undefined) + $xhr.setRequestHeader("KFetPassword", password); + } + }) + .fail(function($xhr) { + switch ($xhr.status) { + case 403: + requestAuth({'errors': {}}, this.toggle_force_close); + break; + } + }); + }, + + clear_class: function() { + let re = new RegExp('(^|\\s)' + this.class_prefix + '\\S+', 'g'); + $(this.target).attr('class', (i, c) => c ? c.replace(re, '') : ''); + }, + + add_class: function(status) { + $(this.target).addClass(this.class_prefix + status); + } +}; diff --git a/kfet/open/templates/kfetopen/init.html b/kfet/open/templates/kfetopen/init.html new file mode 100644 index 00000000..3834b32a --- /dev/null +++ b/kfet/open/templates/kfetopen/init.html @@ -0,0 +1,13 @@ +{% load static %} + + + + + diff --git a/kfet/open/tests.py b/kfet/open/tests.py new file mode 100644 index 00000000..1d6d5529 --- /dev/null +++ b/kfet/open/tests.py @@ -0,0 +1,322 @@ +import json +from datetime import timedelta + +from django.contrib.auth.models import AnonymousUser, Permission, User +from django.test import Client +from django.utils import timezone + +from channels.channel import Group +from channels.test import ChannelTestCase, WSClient + +from . import kfet_open, OpenKfet +from .consumers import OpenKfetConsumer + + +class OpenKfetTest(ChannelTestCase): + """OpenKfet object unit-tests suite.""" + + def setUp(self): + self.kfet_open = OpenKfet() + + def tearDown(self): + self.kfet_open.clear_cache() + + def test_defaults(self): + """Default values.""" + self.assertFalse(self.kfet_open.raw_open) + self.assertIsNone(self.kfet_open.last_update) + self.assertFalse(self.kfet_open.force_close) + self.assertFalse(self.kfet_open.is_open) + + def test_raw_open(self): + """Get and set raw_open; last_update is renewed.""" + for raw_open in [True, False]: + prev_update = self.kfet_open.last_update + self.kfet_open.raw_open = raw_open + self.assertEqual(raw_open, self.kfet_open.raw_open) + self.assertNotEqual(prev_update, self.kfet_open.last_update) + + def test_force_close(self): + """Get and set force_close.""" + for force_close in [True, False]: + self.kfet_open.force_close = force_close + self.assertEqual(force_close, self.kfet_open.force_close) + + def test_is_open(self): + """If force_close is disabled, is_open is raw_open.""" + self.kfet_open.force_close = False + for raw_open in [True, False]: + self.kfet_open.raw_open = raw_open + self.assertEqual(raw_open, self.kfet_open.is_open) + + def test_is_open_force_close(self): + """If force_close is enabled, is_open is False.""" + self.kfet_open.force_close = True + for raw_open in [True, False]: + self.kfet_open.raw_open = raw_open + self.assertFalse(self.kfet_open.is_open) + + def test_status(self): + # (raw_open, force_close, expected status, expected admin) + cases = [ + (False, False, OpenKfet.CLOSED, OpenKfet.CLOSED), + (False, True, OpenKfet.CLOSED, OpenKfet.CLOSED), + (True, False, OpenKfet.OPENED, OpenKfet.OPENED), + (True, True, OpenKfet.CLOSED, OpenKfet.FAKE_CLOSED), + ] + for raw_open, force_close, exp_stat, exp_adm_stat in cases: + self.kfet_open.raw_open = raw_open + self.kfet_open.force_close = force_close + self.assertEqual(exp_stat, self.kfet_open.status()) + self.assertEqual(exp_adm_stat, self.kfet_open.admin_status()) + + def test_status_unknown(self): + self.kfet_open.raw_open = True + self.kfet_open._last_update = timezone.now() - timedelta(days=30) + self.assertEqual(OpenKfet.UNKNOWN, self.kfet_open.status()) + + def test_export_user(self): + """Export is limited for an anonymous user.""" + export = self.kfet_open.export(AnonymousUser()) + self.assertSetEqual( + set(['status']), + set(export), + ) + + def test_export_team(self): + """Export all values for a team member.""" + user = User.objects.create_user('team', '', 'team') + user.user_permissions.add(Permission.objects.get(codename='is_team')) + export = self.kfet_open.export(user) + self.assertSetEqual( + set(['status', 'admin_status', 'force_close']), + set(export), + ) + + def test_send_ws(self): + Group('kfet.open.base').add('test.open.base') + Group('kfet.open.team').add('test.open.team') + + self.kfet_open.send_ws() + + recv_base = self.get_next_message('test.open.base', require=True) + base = json.loads(recv_base['text']) + self.assertSetEqual( + set(['status']), + set(base), + ) + + recv_admin = self.get_next_message('test.open.team', require=True) + admin = json.loads(recv_admin['text']) + self.assertSetEqual( + set(['status', 'admin_status', 'force_close']), + set(admin), + ) + + +class OpenKfetViewsTest(ChannelTestCase): + """OpenKfet views unit-tests suite.""" + + def setUp(self): + # get some permissions + perms = { + 'kfet.is_team': Permission.objects.get(codename='is_team'), + 'kfet.can_force_close': Permission.objects.get(codename='can_force_close'), + } + + # authenticated user and its client + self.u = User.objects.create_user('user', '', 'user') + self.c = Client() + self.c.login(username='user', password='user') + + # team user and its clients + self.t = User.objects.create_user('team', '', 'team') + self.t.user_permissions.add(perms['kfet.is_team']) + self.c_t = Client() + self.c_t.login(username='team', password='team') + + # admin user and its client + self.a = User.objects.create_user('admin', '', 'admin') + self.a.user_permissions.add( + perms['kfet.is_team'], perms['kfet.can_force_close'], + ) + self.c_a = Client() + self.c_a.login(username='admin', password='admin') + + def tearDown(self): + kfet_open.clear_cache() + + def test_door(self): + """Edit raw_status.""" + for sent, expected in [(1, True), (0, False)]: + resp = Client().post('/k-fet/open/raw_open', { + 'raw_open': sent, + 'token': 'plop', + }) + self.assertEqual(200, resp.status_code) + self.assertEqual(expected, kfet_open.raw_open) + + def test_force_close(self): + """Edit force_close.""" + for sent, expected in [(1, True), (0, False)]: + resp = self.c_a.post('/k-fet/open/force_close', {'force_close': sent}) + self.assertEqual(200, resp.status_code) + self.assertEqual(expected, kfet_open.force_close) + + def test_force_close_forbidden(self): + """Can't edit force_close without kfet.can_force_close permission.""" + clients = [Client(), self.c, self.c_t] + for client in clients: + resp = client.post('/k-fet/open/force_close', {'force_close': 0}) + self.assertEqual(403, resp.status_code) + + +class OpenKfetConsumerTest(ChannelTestCase): + """OpenKfet consumer unit-tests suite.""" + + def test_standard_user(self): + """Lambda user is added to kfet.open.base group.""" + # setup anonymous client + c = WSClient() + + # connect + c.send_and_consume('websocket.connect', path='/ws/k-fet/open', + fail_on_none=True) + + # initialization data is replied on connection + self.assertIsNotNone(c.receive()) + + # client belongs to the 'kfet.open' group... + OpenKfetConsumer.group_send('kfet.open.base', {'test': 'plop'}) + self.assertEqual(c.receive(), {'test': 'plop'}) + + # ...but not to the 'kfet.open.admin' one + OpenKfetConsumer.group_send('kfet.open.team', {'test': 'plop'}) + self.assertIsNone(c.receive()) + + def test_team_user(self): + """Team user is added to kfet.open.team group.""" + # setup team user and its client + t = User.objects.create_user('team', '', 'team') + t.user_permissions.add( + Permission.objects.get(codename='is_team') + ) + c = WSClient() + c.force_login(t) + + # connect + c.send_and_consume('websocket.connect', path='/ws/k-fet/open', + fail_on_none=True) + + # initialization data is replied on connection + self.assertIsNotNone(c.receive()) + + # client belongs to the 'kfet.open.admin' group... + OpenKfetConsumer.group_send('kfet.open.team', {'test': 'plop'}) + self.assertEqual(c.receive(), {'test': 'plop'}) + + # ... but not to the 'kfet.open' one + OpenKfetConsumer.group_send('kfet.open.base', {'test': 'plop'}) + self.assertIsNone(c.receive()) + + +class OpenKfetScenarioTest(ChannelTestCase): + """OpenKfet functionnal tests suite.""" + + def setUp(self): + # anonymous client (for views) + self.c = Client() + # anonymous client (for websockets) + self.c_ws = WSClient() + + # root user + self.r = User.objects.create_superuser('root', '', 'root') + # its client (for views) + self.r_c = Client() + self.r_c.login(username='root', password='root') + # its client (for websockets) + self.r_c_ws = WSClient() + self.r_c_ws.force_login(self.r) + + def tearDown(self): + kfet_open.clear_cache() + + def ws_connect(self, ws_client): + ws_client.send_and_consume( + 'websocket.connect', path='/ws/k-fet/open', + fail_on_none=True, + ) + return ws_client.receive(json=True) + + def test_scenario_0(self): + """Clients connect.""" + # test for anonymous user + msg = self.ws_connect(self.c_ws) + self.assertSetEqual( + set(['status']), + set(msg), + ) + + # test for root user + msg = self.ws_connect(self.r_c_ws) + self.assertSetEqual( + set(['status', 'admin_status', 'force_close']), + set(msg), + ) + + def test_scenario_1(self): + """Clients connect, door opens, enable force close.""" + self.ws_connect(self.c_ws) + self.ws_connect(self.r_c_ws) + + # door sent "I'm open!" + self.c.post('/k-fet/open/raw_open', { + 'raw_open': True, + 'token': 'plop', + }) + + # anonymous user agree + msg = self.c_ws.receive(json=True) + self.assertEqual(OpenKfet.OPENED, msg['status']) + + # root user too + msg = self.r_c_ws.receive(json=True) + self.assertEqual(OpenKfet.OPENED, msg['status']) + self.assertEqual(OpenKfet.OPENED, msg['admin_status']) + + # admin says "no it's closed" + self.r_c.post('/k-fet/open/force_close', {'force_close': True}) + + # so anonymous user see it's closed + msg = self.c_ws.receive(json=True) + self.assertEqual(OpenKfet.CLOSED, msg['status']) + + # root user too + msg = self.r_c_ws.receive(json=True) + self.assertEqual(OpenKfet.CLOSED, msg['status']) + # but root knows things + self.assertEqual(OpenKfet.FAKE_CLOSED, msg['admin_status']) + self.assertTrue(msg['force_close']) + + def test_scenario_2(self): + """Starting falsely closed, clients connect, disable force close.""" + kfet_open.raw_open = True + kfet_open.force_close = True + + msg = self.ws_connect(self.c_ws) + self.assertEqual(OpenKfet.CLOSED, msg['status']) + + msg = self.ws_connect(self.r_c_ws) + self.assertEqual(OpenKfet.CLOSED, msg['status']) + self.assertEqual(OpenKfet.FAKE_CLOSED, msg['admin_status']) + self.assertTrue(msg['force_close']) + + self.r_c.post('/k-fet/open/force_close', {'force_close': False}) + + msg = self.c_ws.receive(json=True) + self.assertEqual(OpenKfet.OPENED, msg['status']) + + msg = self.r_c_ws.receive(json=True) + self.assertEqual(OpenKfet.OPENED, msg['status']) + self.assertEqual(OpenKfet.OPENED, msg['admin_status']) + self.assertFalse(msg['force_close']) diff --git a/kfet/open/urls.py b/kfet/open/urls.py new file mode 100644 index 00000000..bd227b96 --- /dev/null +++ b/kfet/open/urls.py @@ -0,0 +1,11 @@ +from django.conf.urls import url + +from . import views + + +urlpatterns = [ + url(r'^raw_open$', views.raw_open, + name='kfet.open.edit_raw_open'), + url(r'^force_close$', views.force_close, + name='kfet.open.edit_force_close'), +] diff --git a/kfet/open/views.py b/kfet/open/views.py new file mode 100644 index 00000000..4f1efa5f --- /dev/null +++ b/kfet/open/views.py @@ -0,0 +1,32 @@ +from django.conf import settings +from django.core.exceptions import PermissionDenied +from django.contrib.auth.decorators import permission_required +from django.http import HttpResponse +from django.views.decorators.csrf import csrf_exempt +from django.views.decorators.http import require_POST + +from .open import kfet_open + + +TRUE_STR = ['1', 'True', 'true'] + + +@csrf_exempt +@require_POST +def raw_open(request): + token = request.POST.get('token') + if token != settings.KFETOPEN_TOKEN: + raise PermissionDenied + raw_open = request.POST.get('raw_open') in TRUE_STR + kfet_open.raw_open = raw_open + kfet_open.send_ws() + return HttpResponse() + + +@permission_required('kfet.can_force_close', raise_exception=True) +@require_POST +def force_close(request): + force_close = request.POST.get('force_close') in TRUE_STR + kfet_open.force_close = force_close + kfet_open.send_ws() + return HttpResponse() diff --git a/kfet/routing.py b/kfet/routing.py index 5ea343cb..54de69ae 100644 --- a/kfet/routing.py +++ b/kfet/routing.py @@ -1,12 +1,11 @@ # -*- coding: utf-8 -*- -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * +from channels.routing import include, route_class -from channels.routing import route, route_class -from kfet import consumers +from . import consumers -channel_routing = [ - route_class(consumers.KPsul, path=r"^/ws/k-fet/k-psul/$"), + +routing = [ + route_class(consumers.KPsul, path=r'^/k-psul/$'), + include('kfet.open.routing.routing', path=r'^/open'), ] diff --git a/kfet/signals.py b/kfet/signals.py index 3dd4d677..c677ac9c 100644 --- a/kfet/signals.py +++ b/kfet/signals.py @@ -1,16 +1,21 @@ # -*- coding: utf-8 -*- -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * - from django.contrib import messages from django.contrib.auth.signals import user_logged_in from django.core.urlresolvers import reverse from django.dispatch import receiver +from django.utils.safestring import mark_safe + @receiver(user_logged_in) def messages_on_login(sender, request, user, **kwargs): - if (not user.username == 'kfet_genericteam' - and user.has_perm('kfet.is_team')): - messages.info(request, 'Connexion en utilisateur partagé ?' % reverse('kfet.login.genericteam'), extra_tags='safe') + if (not user.username == 'kfet_genericteam' and + user.has_perm('kfet.is_team') and + hasattr(request, 'GET') and + 'k-fet' in request.GET.get('next', '')): + messages.info(request, mark_safe( + '' + ' Connexion en utilisateur partagé ?' + '' + .format(reverse('kfet.login.genericteam')) + )) diff --git a/kfet/static/kfet/css/base/buttons.css b/kfet/static/kfet/css/base/buttons.css new file mode 100644 index 00000000..e7498022 --- /dev/null +++ b/kfet/static/kfet/css/base/buttons.css @@ -0,0 +1,88 @@ +/* General ------------------------- */ + +.btn { + border: 0; + outline: none !important; + + transition: background-color, border, color, opacity; + transition-duration: 0.15s; + + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + + font-family: "Roboto Slab"; +} + +.btn, .btn-lg, .btn-group-lg>.btn { + border-radius:0; +} + + +/* Default ------------------------- */ + +.btn-default { + background-color: transparent !important; + color: #555; +} + +.btn-default:hover, +.btn-default.focus, .btn-default:focus { + color: #c8102e; +} + +.btn-default[disabled]:hover, .btn-default.disabled:hover { + color: inherit !important; +} + + +/* Primary ------------------------- */ + +.btn-primary { + background-color:#c63b52; + color:#FFF; +} + +.btn-primary:hover, +.btn-primary.focus, .btn-primary:focus, +.btn-primary.active.focus, .btn-primary.active:focus, .btn-primary.active:hover, +.btn-primary:active.focus, .btn-primary:active:focus, .btn-primary:active:hover { + background-color:#c8102e; + color:#FFF; +} + + +/* Primary + White background ------ */ + +.btn-primary-w { + background: white; + color: black; +} + +.btn-primary-w:hover { + background: #c63b52; + color: white; +} + +.btn-primary-w.focus, .btn-primary-w:focus, +.btn-primary-w.active.focus, .btn-primary-w.active:focus, .btn-primary-w.active:hover, +.btn-primary-w:active.focus, .btn-primary-w:active:focus, .btn-primary-w:active:hover { + background: #c8102e; + color: white; +} + + +/* Nav ----------------------------- */ + +.btn-nav { + background-color: transparent !important; + color: inherit; + border-bottom: 1px solid #ddd; +} + +.btn-nav:hover, +.btn-nav.focus, .btn-nav:focus, +.btn-nav.active.focus, .btn-nav.active:focus, .btn-nav.active:hover, +.btn-nav:active.focus, .btn-nav:active:focus, .btn-nav:active:hover { + border-bottom: 1px solid #c8102e; +} diff --git a/kfet/static/kfet/css/base/fixed.css b/kfet/static/kfet/css/base/fixed.css new file mode 100644 index 00000000..d198c50f --- /dev/null +++ b/kfet/static/kfet/css/base/fixed.css @@ -0,0 +1,151 @@ +.fixed > * + * { + margin-top: 15px; +} + + +/* Aside --------------------------- */ + +/* Aside - Block */ + +aside { + background: white; + padding: 15px; +} + +aside > * + * { + margin-top: 15px; +} + +/* Aside - Misc */ + +aside .glyphicon-question-sign { + font-size: 0.8; +} + +aside h4 { + font-weight: bold; +} + +/* Aside - Heading */ + +aside .heading { + font-family: "Roboto Slab"; + font-size: 25px; + font-weight: bold; + line-height: 1.1; + text-align: center; +} + +aside .heading .big { + font-size: 2em; +} + +aside .heading .sub { + font-size: 0.7em; + font-weight: normal; +} + +@media (min-width: 992px) { + aside .heading { + font-size: 32px; + line-height: 1.3; + } +} + +/* Aside - Buttons */ + +aside .buttons { + margin-left: -15px; + margin-right: -15px; +} + +aside .buttons > * { + flex: 0 1 auto !important; +} + + +/* Aside - Text */ + +aside .text { + line-height: 1.3; + font-size: 14px; +} + +@media (min-width: 992px) { + aside .text { + line-height: 1.6; + font-size: 16px; + } +} + +aside .text ul { + margin-bottom: 0; +} + + +/* Buttons ------------------------- */ + +.fixed .buttons { + display: flex; + flex-flow: row wrap; + justify-content: center; + + text-align: center; +} + +.fixed .buttons > * { + flex: 0 1 auto; + overflow: hidden; +} + +.fixed .buttons > .solo { + flex: 1 100%; +} + +@media (min-width: 768px) { + .fixed .buttons > * { + flex: 1 auto; + } + + .fixed .buttons > .full > * { + width: 100%; + } +} + +.fixed .buttons .btn { + padding: 8px 12px; +} + +@media (min-width: 992px) { + .fixed .buttons .btn { + font-size: 16px; + } +} + + +/* Tabs ---------------------------- */ + +.fixed .tabs-buttons { + margin-bottom: -5px; +} + +.fixed .tabs-buttons > * { + margin-bottom: 5px; +} + +.fixed .tabs-buttons .glyphicon-chevron-right { + margin-left: 5px; + line-height: 1.4; + color: white; +} + +@media (min-width: 768px) { + .fixed .tabs-buttons { + text-align: right; + justify-content: flex-end; + } + + .fixed .tabs-buttons > * { + flex: 1 100%; + } +} diff --git a/kfet/static/kfet/css/base/footer.css b/kfet/static/kfet/css/base/footer.css new file mode 100644 index 00000000..abdf98ed --- /dev/null +++ b/kfet/static/kfet/css/base/footer.css @@ -0,0 +1,18 @@ +.footer { + line-height: 40px; + + background: #c63b52; + color: white; + + text-align: center; + font-size: 14px; + font-family: Roboto; +} + +.footer a { + color: inherit !important; +} + +.footer a:hover, .footer a:focus { + text-decoration: underline; +} diff --git a/kfet/static/kfet/css/base/main.css b/kfet/static/kfet/css/base/main.css new file mode 100644 index 00000000..2ebc90d8 --- /dev/null +++ b/kfet/static/kfet/css/base/main.css @@ -0,0 +1,138 @@ +/* Global layout ------------------- */ + +.main-col, .fixed-col { + padding: 0 0 15px; +} + +@media (min-width: 768px) { + .fixed-col { + position: sticky; + top: 35px; + padding-top: 15px; + } + + .fixed-col + .main-col { + padding: 15px 0 15px 15px; + } +} + +@media (min-width: 992px) { + .main-col { + padding: 15px; + } +} + +.main-col-mult { + column-gap: 45px; +} + +.main-bg { + background: white; +} + +.main-padding { + padding: 15px; +} + +@media (min-width: 768px) { + .main-padding { + padding: 30px; + } +} + + +/* Section ------------------------- */ + +section { + margin-bottom: 15px; + position:relative; +} + +section:last-child { + margin-bottom: 0; +} + + +/* Section - Elements -------------- */ + +section > * { + background: white; + padding: 15px; +} + +section > .full, +section > table, +section > .table-responsive { + padding: 0 !important; + margin-left: 0 !important; + margin-right: 0 !important; +} + +section .full { + margin-left: -15px; + margin-right: -15px; +} + +@media (min-width: 992px) { + section > * { + padding: 30px; + } + + section .full { + margin-left: -30px; + margin-right: -30px; + } +} + +section .row > div:last-child { + margin-bottom: 0 !important; +} + +@media (max-width: 768px) { + section .row > div { + margin-bottom: 10px; + } +} + +@media (max-width: 1200px) { + section .row > div { + margin-bottom: 20px; + } +} + +section ul ul { + padding-left: 30px; +} + +/* Titles & Heading */ + +section h2, +section .heading { + background: transparent; + margin: 20px 15px 15px; + padding: 0; + border-bottom: 3px solid #c8102e; + font-family: "Roboto Slab"; + font-size: 40px; + line-height: 1.1; +} + +section h3 { + border-bottom: 2px solid #c8102e; + margin: 0 0 10px; + padding: 10px 0 10px; + font-size: 25px; + font-weight: bold; +} + +section .heading .buttons { + opacity: 0.7; + top: 10px; + float: right; +} + +section h2:first-child, +section h3:first-child { + padding-top: 0; + margin-top: 0; +} diff --git a/kfet/static/kfet/css/base/messages.css b/kfet/static/kfet/css/base/messages.css new file mode 100644 index 00000000..268f514d --- /dev/null +++ b/kfet/static/kfet/css/base/messages.css @@ -0,0 +1,36 @@ +.messages .alert { + padding:10px 15px; + margin:0; + border:0; + border-radius:0; +} + +.messages .alert:last-child { + margin-bottom: 15px; +} + +.messages .alert .close { + top:0; + right:0; +} + +.messages .alert-info { + color:inherit; + background-color:#ccc; +} + +.messages .alert-error { + color: white; + background-color: #c63b52; +} + +.messages .alert-success { + color: white; + background: #3d9947; +} + +.messages a { + font-weight: bold; + text-decoration: none; +} + diff --git a/kfet/static/kfet/css/base/misc.css b/kfet/static/kfet/css/base/misc.css new file mode 100644 index 00000000..680fb1ee --- /dev/null +++ b/kfet/static/kfet/css/base/misc.css @@ -0,0 +1,118 @@ +/* General ------------------------- */ + +body { + margin-top:50px; + font-family:Roboto; + background:#ddd; +} + +.glyphicon + span, span + .glyphicon { + margin-left: 10px; +} + +/* Titles */ + +h1,h2,h3,h4,h5,h6 { + font-family:"Roboto Slab"; +} + +/* Links */ + +a { + color:#C8202E; +} + +a:focus, a:hover { + color:#C8102E; +} + +/* Inputs */ + +:focus { + outline:none; +} + +textarea { + font-family:'Roboto Mono'; + border-radius:0 !important; +} + +/* Lists */ + +ul, ol { + padding-left: 30px; +} + +ul { + list-style-type: square; +} + +/* Tables */ + +.table { + margin-bottom:0; + border-bottom:1px solid #ddd; + width:100%; + background-color: #FFF; +} + +.table td { + vertical-align:middle !important; +} + +.table td.no-padding { + padding:0; +} + +.table thead { + background:#c8102e; + color:#fff; + font-weight:bold; + font-size:16px; +} + +.table thead td { + padding:8px !important; +} + +.table tr.section { + background: #c63b52 !important; + color:#fff; + font-weight:bold; +} + +.table tr.section td { + border-top:0; + font-size:16px; + padding:8px 30px; +} + +.table tr.more td { + padding: 0; +} + +.table-responsive { + border: 0; + margin-bottom: 0; +} + +/* Toggle on hover ----------------- */ + +.toggle:not(:hover) .hover { + display: none; +} + +.toggle:hover .base { + display: none; +} + +/* Spinning animation -------------- */ + +.glyphicon.spinning { + animation: spin 1s infinite linear; +} + +@keyframes spin { + from { transform: scale(1) rotate(0deg); } + to { transform: scale(1) rotate(360deg); } +} diff --git a/kfet/static/kfet/css/base/nav.css b/kfet/static/kfet/css/base/nav.css new file mode 100644 index 00000000..0efc2873 --- /dev/null +++ b/kfet/static/kfet/css/base/nav.css @@ -0,0 +1,151 @@ +.navbar { + background: #000; + color: #DDD; + border: 0; + font-family: Roboto; +} + +.navbar .navbar-header { + float: left; + display: none; + margin-left: -15px; + margin-right: 0; +} + +.navbar .navbar-brand { + padding: 3px 0; + margin: 0 15px !important; +} + +.navbar .navbar-brand img { + height: 44px; +} + +.navbar .navbar-toggle { + border: 0; + border-radius: 0; + padding: 18px 15px; + margin: 0; + min-width: auto; +} + +.navbar .navbar-toggle .icon-bar { + background: #fff; +} + +.navbar-nav { + font-size: 14px; + margin: 0 0 0 -15px; + float: left; +} + +@media (min-width: 460px) { + .navbar .navbar-header { + display: block; + } + + .navbar-nav { + margin-left: 0; + } + + .navbar-nav .nav-pages.dropdown .dropdown-menu > li:first-child { + display: none; + } +} + +.navbar-right { + float: right !important; + margin: 0 -15px 0 0; +} + +.navbar-nav a { + transition: background-color, box-shadow, color; + transition-duration: 0.15s; +} + +.navbar-nav > li { + float: left; + text-align: center; +} + +.navbar-nav > li > a { + min-width: 50px; + padding: 15px 10px; + color: #FFF; +} + +.navbar-nav > .divider { + height: 1px; + background: rgba(255, 255, 255, 0.1); +} + +@media (min-width: 1200px) { + .navbar-nav > li > a { + padding-left: 15px; + padding-right: 15px; + } +} + +.navbar-nav > li > a:hover, .navbar-nav > li > a:focus, +.nav .open > a:hover, .nav .open > a:focus, +.navbar-nav > li.active > a, +.navbar-nav .dropdown:hover > a, .navbar-nav .dropdown:focus > a { + background-color: #C8102E; + color: #FFF; + box-shadow: inset 0 3px 3px -4px #000; +} + +.navbar-nav .dropdown .dropdown-menu { + padding: 0; + border: 0; + border-radius: 0; + background-color: #FFF; + font-size: 14px; + + /* override max-width: 767px of bs */ + position: absolute; + float: left; + box-shadow: 0 6px 12px rgba(0,0,0,.175); +} + +.navbar-nav .dropdown .dropdown-menu > li > a { + padding: 8px 10px; + line-height: inherit; + color: #000; +} + +.navbar-nav .dropdown .dropdown-menu > li > a:hover, +.navbar-nav .dropdown .dropdown-menu > li > a:focus { + color: #c8102e; + background-color: transparent; +} + +.navbar-nav .dropdown .dropdown-menu .divider { + margin: 0; +} + +.navbar-nav .dropdown .dropdown-menu { + display: block; + visibility: hidden; + opacity: 0; + transition: opacity 0.15s; +} + +.navbar-nav .dropdown:hover > .dropdown-menu, +.navbar-nav .dropdown:focus > .dropdown-menu, +.navbar-nav .dropdown.open > .dropdown-menu { + visibility: visible; + opacity: 1; +} + +@media (min-width: 992px) { + .navbar-nav .dropdown .dropdown-menu > li > a { + padding-left: 20px; + padding-right: 20px; + } +} + +.nav-app .dropdown-menu { + right: 0; + left: auto; +} diff --git a/kfet/static/kfet/css/history.css b/kfet/static/kfet/css/history.css index 0e75741a..401aa94d 100644 --- a/kfet/static/kfet/css/history.css +++ b/kfet/static/kfet/css/history.css @@ -9,17 +9,21 @@ #history .day { height:40px; line-height:40px; - background-color:#c8102e; + background-color:rgba(200,16,46,1); color:#fff; padding-left:20px; + font-family:"Roboto Slab"; font-size:16px; font-weight:bold; + position:sticky; + top:50px; + z-index:10; } #history .opegroup { height:30px; line-height:30px; - background-color:rgba(200,16,46,0.85); + background-color: #c63b52; color:#fff; font-weight:bold; padding-left:20px; diff --git a/kfet/static/kfet/css/home.css b/kfet/static/kfet/css/home.css deleted file mode 100644 index 718159c3..00000000 --- a/kfet/static/kfet/css/home.css +++ /dev/null @@ -1,54 +0,0 @@ -ul.carte { - width: 100%; - list-style-type: none; - padding-left: 15px; - padding-right: 15px; - display: inline-block; - *display: inline; - zoom: 1; - position: relative; - clip: auto; - overflow: hidden; -} -/* -ul.carte > li { - border-style: none none solid none; - border-width: 1px; - border-color: #DDD; -} -*/ -li.carte-line { - position: relative; - text-align: right; - white-space: nowrap; -} -.filler { - position: absolute; - left: 0; - right: 0; - border-bottom: 3px dotted #333; - height: 70%; -} -.carte-label { - background: white; - float: left; - padding-right: 4px; - position: relative; - max-width: calc(100% - 40px); - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.carte-ukf { - background: white; - padding-left: 4px; - position: relative; -} - - -.unbreakable.carte-inverted .carte-ukf, -.unbreakable.carte-inverted .carte-label, -.unbreakable.carte-inverted { - background: #FFDBC7; -} diff --git a/kfet/static/kfet/css/index.css b/kfet/static/kfet/css/index.css index 0244a57b..8e28cce0 100644 --- a/kfet/static/kfet/css/index.css +++ b/kfet/static/kfet/css/index.css @@ -1,264 +1,116 @@ -@import url("nav.css"); +/* Libs */ +@import url("libs/columns.css"); + +/* Libs customizations */ +@import url("libs/jconfirm-kfet.css"); +@import url("libs/multiple-select-kfet.css"); + +/* Base */ +@import url("base/misc.css"); +@import url("base/buttons.css"); + +/* Blocks */ +@import url("base/main.css"); +@import url("base/nav.css"); +@import url("base/messages.css"); +@import url("base/fixed.css"); +@import url("base/footer.css"); + +/* Components */ @import url("kpsul.css"); -@import url("jconfirm-kfet.css"); @import url("history.css"); -body { - margin-top:50px; - font-family:Roboto; - background:#ddd; + + +.header { + padding: 15px 20px; + + background-color: rgba(200,16,46,1); + color: #FFF; } -h1,h2,h3,h4,h5,h6 { - font-family:Oswald; -} - -a { - color:#333; -} - -a:focus, a:hover { - color:#C8102E; -} - -:focus { - outline:none; -} - -textarea { - font-family:'Roboto Mono'; - border-radius:0 !important; -} - -.table { - margin-bottom:0; - border-bottom:1px solid #ddd; -} - -.table { - width:100%; -} - -.table td { - vertical-align:middle !important; -} - -.table td.no-padding { - padding:0; -} - -.table thead { - background:#c8102e; - color:#fff; - font-weight:bold; - font-size:16px; -} - -.table thead td { - padding:8px !important; -} - -.table tr.section { - background:rgba(200,16,46,0.9); - color:#fff; - font-weight:bold; -} - -.table tr.section td { - border-top:0; - font-size:16px; - padding:8px 30px; -} - -.btn, .btn-lg, .btn-group-lg>.btn { - border-radius:0; -} - -.btn-primary { - font-family:Oswald; - background-color:rgba(200,16,46,0.9); - color:#FFF; - border:0; -} - -.btn-primary:hover, .btn-primary.focus, .btn-primary:focus { - background-color:#000; - color:#FFF; -} - -.buttons .nav-pills > li > a { - border-radius:0; - border:1px solid rgba(200,16,46,0.9); -} - -.buttons .nav-pills > li.active > a { - background-color:rgba(200,16,46,0.9); - background-clip:padding-box; -} - -.row-page-header { - background-color:rgba(200,16,46,1); - color:#FFF; - border-bottom:3px solid #000; -} - -.page-header { - border:0; - padding:0; - margin:15px 20px; - text-transform:uppercase; - font-weight:bold; +.header h1 { + padding: 0; + margin: 0; + font-weight: bold; } .nopadding { padding: 0 !important; } -.panel-md-margin{ - background-color: white; - overflow:hidden; - padding-left: 15px; - padding-right: 15px; - padding-bottom: 15px; - padding-top: 1px; -} - -@media (min-width: 992px) { - .panel-md-margin{ - margin:8px; - background-color: white; - } -} - -.col-content-left, .col-content-right { - padding:0; -} - -.content-left-top { - background:#fff; - padding:10px 30px; -} - -.content-left .buttons { - background:#fff; -} - -.content-left .buttons .btn { - display:block; -} - -.content-left-top.frozen-account { - background:#000FBA; +.frozen-account { + background:#5072e0; color:#fff; } -.content-left .block { - padding-top:25px; + +.main .table a:not(.btn) { + color: inherit; } -.content-left .block .line { - font-size:16px; - line-height:30px; +.main .table a:not(.btn):focus , +.main .table a:not(.btn):hover { + color: #C81022; } -.content-left .line.line-big { - font-family:Oswald; - font-size:60px; - font-weight:bold; - text-align:center; -} - -.content-left .line.line-bigsub { - font-size:25px; - font-weight:bold; - text-align:center; -} - -.content-left .line.balance { - font-size:45px; - text-align:center; -} - -.content-right { - margin:0 15px; -} - -.content-right-block { - padding-bottom:5px; - position:relative; -} - -.content-right-block:last-child { - padding-bottom:15px; -} - -.content-right-block > div:not(.buttons-title) { - background:#fff; -} - -.content-right-block-transparent > div:not(.buttons-title) { - background-color: transparent; -} - -.content-right-block .buttons-title { - position:absolute; - top:8px; - right:20px; -} - -.content-right-block > div.row { - margin:0; -} - -.content-right-block h2 { - margin:20px 20px 15px; - padding-bottom:5px; - border-bottom:3px solid #c8102e; - font-size:40px; -} - -.content-right-block h3 { - border-bottom: 1px solid #c8102e; - margin: 20px 15px 15px; - padding-bottom: 10px; - padding-left: 20px; - font-size:25px; -} /* * Pages tableaux seuls */ -.content-center > div { - background:#fff; -} -.content-center tbody tr:not(.section) td { - padding:0px 5px !important; -} - -.content-center .table .form-control { +.table .form-control { padding: 1px 12px ; height:28px; margin:3px 0px; + background: transparent; } - .content-center .auth-form { - margin:15px; + +.table .form-control[disabled], .table .form-control[readonly] { + background: #f5f5f5; +} + +.table-condensed-input tbody tr:not(.section) td { + padding:0px 5px; +} + +.table-condensed input.form-control { + margin: 0 !important; + border-top: 0; + border-bottom: 0; + border-radius: 0; +} + +.auth-form { + padding: 15px 0; + background: #d86c7e; + color: white; +} + +.auth-form.form-horizontal { + padding: 0; + margin: 0; +} + +.auth-form .form-group { + margin-bottom: 0; +} + +.auth-form input { + box-shadow: none !important; + background: transparent; + color: white; + border: 0 !important; + border-radius: 0; + border-bottom: 1px solid white !important; } /* * Pages formulaires seuls */ -.form-only .content-form { - margin:15px; - - background:#fff; - - padding:15px; -} - -.form-only .account_create #id_trigramme { +.account_create #id_trigramme { display:block; width:200px; height:80px; @@ -320,38 +172,48 @@ textarea { padding:5px 20px; } -/* - * Messages +/* Account autocomplete window */ + +#account_results ul { + list-style-type:none; + background:rgba(255,255,255,0.9); + padding:0; +} + +#account_results li { + display:block; + padding:5px 20px; + height:100%; + width:100%; +} + +#account_results .hilight { + background:rgba(200,16,46,0.9); + color:#fff; + text-decoration:none; +} + +/** + * Stats (graphs) */ -.messages .alert { - padding:10px 15px; - margin:0; - border:0; - border-radius:0; +.stat-nav { + margin-bottom: 10px; + font-family: Roboto; } -.messages .alert-dismissible { - padding-right:35px; +.stat-nav li { + float: left; } -.messages .alert .close { - top:0; - right:0; +.stat-nav a { + opacity: 0.6; + font-family: Roboto; } -.messages .alert-info { - color:inherit; - background-color:#ccc; -} - -.messages .alert-error { - color:inherit; - background-color:rgba(200,16,46,0.2); -} - -.messages .alert-success { - color:#333; +.stat-nav a:hover, +.stat-nav a.focus, .stat-nav a:focus { + opacity: 1; } /* @@ -374,7 +236,7 @@ textarea { margin-top:30px; padding-top:1px; padding-bottom:15px; - background:rgba(51,51,51,0.7); + background:rgba(51,51,51,0.9); color:#fff; } @@ -411,171 +273,56 @@ thead .tooltip { height: 100px; } -/* - * Responsive Columns - */ - -.unbreakable { - display:inline-block; - width: 100%; -} - - -.column-row { - padding: 15px 20px; -} - -.column-xs-1, -.column-sm-1, -.column-md-1, -.column-lg-1, -.column-xs-2, -.column-sm-2, -.column-md-2, -.column-lg-2, -.column-xs-3, -.column-sm-3, -.column-md-3, -.column-lg-3, -.column-xs-4, -.column-sm-4, -.column-md-4, -.column-lg-4, -.column-xs-5, -.column-sm-5, -.column-md-5, -.column-lg-5 { - -webkit-column-count: 1; /* Chrome, Safari, Opera */ - -moz-column-count: 1; /* Firefox */ - column-count: 1; -} - - -.column-xs-1 { - -webkit-column-count: 1; /* Chrome, Safari, Opera */ - -moz-column-count: 1; /* Firefox */ - column-count: 1; -} -.column-xs-2 { - -webkit-column-count: 2; /* Chrome, Safari, Opera */ - -moz-column-count: 2; /* Firefox */ - column-count: 2; -} -.column-xs-3 { - -webkit-column-count: 3; /* Chrome, Safari, Opera */ - -moz-column-count: 3; /* Firefox */ - column-count: 3; -} -.column-xs-4 { - -webkit-column-count: 4; /* Chrome, Safari, Opera */ - -moz-column-count: 4; /* Firefox */ - column-count: 4; -} -.column-xs-5 { - -webkit-column-count: 5; /* Chrome, Safari, Opera */ - -moz-column-count: 5; /* Firefox */ - column-count: 5; -} - -@media (min-width: 576px) { - .column-sm-1 { - -webkit-column-count: 1; /* Chrome, Safari, Opera */ - -moz-column-count: 1; /* Firefox */ - column-count: 1; - } - .column-sm-2 { - -webkit-column-count: 2; /* Chrome, Safari, Opera */ - -moz-column-count: 2; /* Firefox */ - column-count: 2; - } - .column-sm-3 { - -webkit-column-count: 3; /* Chrome, Safari, Opera */ - -moz-column-count: 3; /* Firefox */ - column-count: 3; - } - .column-sm-4 { - -webkit-column-count: 4; /* Chrome, Safari, Opera */ - -moz-column-count: 4; /* Firefox */ - column-count: 4; - } - .column-sm-5 { - -webkit-column-count: 5; /* Chrome, Safari, Opera */ - -moz-column-count: 5; /* Firefox */ - column-count: 5; - } -} - -@media (min-width: 768px) { - .column-md-1 { - -webkit-column-count: 1; /* Chrome, Safari, Opera */ - -moz-column-count: 1; /* Firefox */ - column-count: 1; - } - .column-md-2 { - -webkit-column-count: 2; /* Chrome, Safari, Opera */ - -moz-column-count: 2; /* Firefox */ - column-count: 2; - } - .column-md-3 { - -webkit-column-count: 3; /* Chrome, Safari, Opera */ - -moz-column-count: 3; /* Firefox */ - column-count: 3; - } - .column-md-4 { - -webkit-column-count: 4; /* Chrome, Safari, Opera */ - -moz-column-count: 4; /* Firefox */ - column-count: 4; - } - .column-md-5 { - -webkit-column-count: 5; /* Chrome, Safari, Opera */ - -moz-column-count: 5; /* Firefox */ - column-count: 5; - } -} - -@media (min-width: 992px) { - .column-lg-1 { - -webkit-column-count: 1; /* Chrome, Safari, Opera */ - -moz-column-count: 1; /* Firefox */ - column-count: 1; - } - .column-lg-2 { - -webkit-column-count: 2; /* Chrome, Safari, Opera */ - -moz-column-count: 2; /* Firefox */ - column-count: 2; - } - .column-lg-3 { - -webkit-column-count: 3; /* Chrome, Safari, Opera */ - -moz-column-count: 3; /* Firefox */ - column-count: 3; - } - .column-lg-4 { - -webkit-column-count: 4; /* Chrome, Safari, Opera */ - -moz-column-count: 4; /* Firefox */ - column-count: 4; - } - .column-lg-5 { - -webkit-column-count: 5; /* Chrome, Safari, Opera */ - -moz-column-count: 5; /* Firefox */ - column-count: 5; - } -} - -.help-block { - padding-top: 15px; -} /* Inventaires */ +.table-condensed-input input[type=number] { + text-align: center; +} + .inventory_modified { background:rgba(236,100,0,0.15); } .stock_diff { padding-left: 5px; - color:#C8102E; + color:#C8102E; } .inventory_update { - display:none; + display: none; + width: 50px; + margin: 0 auto; +} + + +/* Checkbox select multiple */ + +.checkbox-select-multiple label { + font-weight: normal; + margin-bottom: 0; +} + +/* Statement creation */ + +.statement-create-summary table { + margin: 0 auto; +} + +.statement-create-summary tr td { + text-align: right; +} + +.statement-create-summary tr td:first-child { + padding-right: 15px; + font-weight: bold; +} + +.statement-create-summary tr td:last-child { + width: 80px; +} + +#detail_taken table td, +#detail_balance table td { + padding: 0; } diff --git a/kfet/static/kfet/css/kpsul.css b/kfet/static/kfet/css/kpsul.css index d592ec3f..b972969a 100644 --- a/kfet/static/kfet/css/kpsul.css +++ b/kfet/static/kfet/css/kpsul.css @@ -18,6 +18,17 @@ input[type=number]::-webkit-outer-spin-button { 100% { background: yellow; } } +/* Announcements banner */ + +#banner { + background-color: #d86b01; + width: 100%; + text-align: center; + padding: 10px; + color: white; + font-size: larger; +} + /* * Top row */ @@ -147,9 +158,10 @@ input[type=number]::-webkit-outer-spin-button { height:50px; padding:0 15px; - background:#c8102e; + background:rgba(200,16,46,1); color:#fff; + font-family:"Roboto Slab"; font-weight:bold; font-size:18px; } @@ -230,24 +242,17 @@ input[type=number]::-webkit-outer-spin-button { height:40px; } -#special_operations button { - height:100%; - width:25%; +#special_operations .btn { + height:40px; - float:left; - - background:#c8102e; - color:#FFF; - - font-size:18px; + font-size:15px; font-weight:bold; + + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; } -#special_operations button:focus, #special_operations button:hover { - outline:none; - background:#000; - color:#fff; -} /* Article autocomplete */ @@ -260,15 +265,14 @@ input[type=number]::-webkit-outer-spin-button { height:100%; float:left; border:0; - border-right:1px solid #c8102e; - border-bottom:1px solid #c8102e; border-radius:0; + border-bottom: 1px solid rgba(200,16,46,0.9); font-size:16px; font-weight:bold; } -#article_selection input+input #article_selection input+span { - border-right:0; +#article_selection input:first-child { + border-right: 1px dashed rgba(200,16,46,0.9); } #article_autocomplete { @@ -337,14 +341,14 @@ input[type=number]::-webkit-outer-spin-button { width:14%; } - #articles_data div.category { height:35px; line-height:35px; background-color:#c8102e; + font-family:"Roboto Slab"; font-size:16px; - color:#FFF; font-weight:bold; + color:#FFF; } #articles_data div.category>span:first-child { @@ -445,3 +449,7 @@ input[type=number]::-webkit-outer-spin-button { .kpsul_middle_right_col { overflow:auto; } + +.kpsul_middle_right_col #history .day { + top: 0; +} diff --git a/kfet/static/kfet/css/libs/columns.css b/kfet/static/kfet/css/libs/columns.css new file mode 100644 index 00000000..34591061 --- /dev/null +++ b/kfet/static/kfet/css/libs/columns.css @@ -0,0 +1,43 @@ +.unbreakable { + display:inline-block; + width: 100%; +} + +.column-xs-1, .column-sm-1, .column-md-1, .column-lg-1, +.column-xs-2, .column-sm-2, .column-md-2, .column-lg-2, +.column-xs-3, .column-sm-3, .column-md-3, .column-lg-3, +.column-xs-4, .column-sm-4, .column-md-4, .column-lg-4, +.column-xs-5, .column-sm-5, .column-md-5, .column-lg-5 { + column-count: 1; +} + +.column-xs-1 { column-count: 1; } +.column-xs-2 { column-count: 2; } +.column-xs-3 { column-count: 3; } +.column-xs-4 { column-count: 4; } +.column-xs-5 { column-count: 5; } + +@media (min-width: 768px) { + .column-sm-1 { column-count: 1; } + .column-sm-2 { column-count: 2; } + .column-sm-3 { column-count: 3; } + .column-sm-4 { column-count: 4; } + .column-sm-5 { column-count: 5; } +} + +@media (min-width: 992px) { + .column-md-1 { column-count: 1; } + .column-md-2 { column-count: 2; } + .column-md-3 { column-count: 3; } + .column-md-4 { column-count: 4; } + .column-md-5 { column-count: 5; } +} + +@media (min-width: 1200px) { + .column-lg-1 { column-count: 1; } + .column-lg-2 { column-count: 2; } + .column-lg-3 { column-count: 3; } + .column-lg-4 { column-count: 4; } + .column-lg-5 { column-count: 5; } +} + diff --git a/kfet/static/kfet/css/jconfirm-kfet.css b/kfet/static/kfet/css/libs/jconfirm-kfet.css similarity index 81% rename from kfet/static/kfet/css/jconfirm-kfet.css rename to kfet/static/kfet/css/libs/jconfirm-kfet.css index bb8ba849..74f9c857 100644 --- a/kfet/static/kfet/css/jconfirm-kfet.css +++ b/kfet/static/kfet/css/libs/jconfirm-kfet.css @@ -5,7 +5,7 @@ .jconfirm .jconfirm-box { padding:0; border-radius:0 !important; - font-family:"Roboto Mono"; + font-family:Roboto; } .jconfirm .jconfirm-box div.title-c .title { @@ -28,7 +28,6 @@ .jconfirm .jconfirm-box .content { border-bottom:1px solid #ddd; - padding:5px 10px; } .jconfirm .jconfirm-box input { @@ -37,6 +36,7 @@ border:0; + font-family:"Roboto Mono"; font-size:40px; text-align:center; @@ -49,6 +49,7 @@ } .jconfirm .jconfirm-box .buttons button { + min-width:40px; height:100%; margin:0; margin:0 !important; @@ -89,24 +90,3 @@ padding-right: 50px; padding-left: 50px; } - -/* Account autocomplete window */ - -#account_results ul { - list-style-type:none; - background:rgba(255,255,255,0.9); - padding:0; -} - -#account_results li { - display:block; - padding:5px 20px; - height:100%; - width:100%; -} - -#account_results .hilight { - background:rgba(200,16,46,0.9); - color:#fff; - text-decoration:none; -} diff --git a/kfet/static/kfet/css/libs/multiple-select-kfet.css b/kfet/static/kfet/css/libs/multiple-select-kfet.css new file mode 100644 index 00000000..145968d3 --- /dev/null +++ b/kfet/static/kfet/css/libs/multiple-select-kfet.css @@ -0,0 +1,14 @@ +/** + * Multiple Select plugin customizations + */ + +.ms-choice { + height: 34px !important; + line-height: 34px !important; + border: 1px solid #ccc !important; + box-shadow: inset 0 1px 1px rgba(0,0,0,.075) !important; +} + +.ms-choice > div { + top: 4px !important; +} diff --git a/kfet/static/kfet/css/nav.css b/kfet/static/kfet/css/nav.css index 5ffc7b24..bec05ccf 100644 --- a/kfet/static/kfet/css/nav.css +++ b/kfet/static/kfet/css/nav.css @@ -1,67 +1,88 @@ -nav { - background:#000; - color:#DDD; - font-family:Oswald; +.navbar { + background: #000; + color: #DDD; + font-family: Oswald; + border: 0; } -.navbar-nav > li > .dropdown-menu { - border:0; - border-radius:0; +.navbar .navbar-brand { + padding: 3px 25px; } -.navbar-fixed-top { - border:0; +.navbar .navbar-brand img { + height: 44px; } -nav .navbar-brand { - padding:3px 25px; -} - -nav .navbar-brand img { - height:44px; -} - -nav .navbar-toggle .icon-bar { - background-color:#FFF; -} - -nav a { - color:#DDD; +.navbar .navbar-toggle .icon-bar { + background-color: #FFF; } .navbar-nav { - font-weight:bold; - font-size:14px; - text-transform:uppercase; + font-weight: bold; + font-size: 14px; + text-transform: uppercase; + margin: 0 -15px; } -.nav>li>a:focus, .nav>li>a:hover { - background-color:#C8102E; - color:#FFF; -} - -.nav .open>a, .nav .open>a:focus, .nav .open>a:hover { - background-color:#C8102E; -} - -.dropdown-menu { - padding:0; -} - -.dropdown-menu>li>a { - padding:8px 20px; -} - -.dropdown-menu .divider { - margin:0; -} - -@media (max-width: 767px) { - .navbar-nav .open .dropdown-menu { - background-color:#FFF; - } - +@media (min-width: 768px) { .navbar-nav { - margin:0 -15px; + margin: 0px; + } + .navbar-right { + margin-right: -15px; + } +} + +.navbar-nav a { + transition: background-color, box-shadow, color; + transition-duration: 0.15s; +} + +.navbar-nav > li > a { + color: #FFF; +} + +.navbar-nav > li:hover > a, +.navbar-nav > li > a:focus, +.nav .open > a:hover, +.nav .open > a:focus { + background-color: #C8102E; + color: #FFF; + box-shadow: inset 0 5px 5px -5px #000; +} + +.navbar .dropdown .dropdown-menu { + padding: 0; + border: 0; + border-radius: 0; + background-color: #FFF; +} + +.navbar .dropdown .dropdown-menu > li > a { + padding: 8px 20px; + color: #000; +} + +.navbar .dropdown .dropdown-menu > li > a:hover, +.navbar .dropdown .dropdown-meny > li > a:focus { + color: #c8102e; + background-color: transparent; +} + +.navbar .dropdown .dropdown-menu .divider { + margin: 0; +} + +@media (min-width: 768px) { + .navbar .dropdown .dropdown-menu { + display: block; + visibility: hidden; + opacity: 0; + transition: opacity 0.15s; + } + + .navbar .dropdown:hover .dropdown-menu { + visibility: visible; + opacity: 1; } } diff --git a/kfet/static/kfet/img/favicon.png b/kfet/static/kfet/img/favicon.png new file mode 100644 index 00000000..56fb4299 Binary files /dev/null and b/kfet/static/kfet/img/favicon.png differ diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index a7e893b6..8ddfb838 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -135,16 +135,6 @@ class Config { $(document).ready(function() { - $(window).scroll(function() { - if ($(window).width() >= 768 && $(this).scrollTop() > 72.6) { - $('.col-content-left').css({'position':'fixed', 'top':'50px'}); - $('.col-content-right').addClass('col-sm-offset-4 col-md-offset-3'); - } else { - $('.col-content-left').css({'position':'relative', 'top':'0'}); - $('.col-content-right').removeClass('col-sm-offset-4 col-md-offset-3'); - } - }); - if (typeof Cookies !== 'undefined') { // Retrieving csrf token csrftoken = Cookies.get('csrftoken'); @@ -194,19 +184,24 @@ $(document).on('keydown', function(e) { class KfetWebsocket { static get defaults() { - return {"relative_url": "", "default_msg": {}, "handlers": []}; + return { + relative_url: '', + default_msg: {}, + handlers: [], + base_path: '/ws/k-fet/' + }; } constructor(data) { $.extend(this, this.constructor.defaults, data); + if (window.location.pathname.startsWith('/gestion/')) + this.base_path = '/gestion' + this.base_path; } get url() { - var websocket_protocol = window.location.protocol == 'https:' ? 'wss' : 'ws'; - var location_host = window.location.host; - var location_url = window.location.pathname.startsWith('/gestion/') ? location_host + '/gestion' : location_host; - - return websocket_protocol+"://" + location_url + this.relative_url ; + var protocol = window.location.protocol == 'https:' ? 'wss' : 'ws'; + var host = window.location.host; + return protocol + "://" + host + this.base_path + this.relative_url; } add_handler(handler) { @@ -230,7 +225,7 @@ class KfetWebsocket { } var OperationWebSocket = new KfetWebsocket({ - 'relative_url': '/ws/k-fet/k-psul/', + 'relative_url': 'k-psul/', 'default_msg': {'opegroups':[],'opes':[],'checkouts':[],'articles':[]}, }); @@ -425,3 +420,12 @@ String.prototype.pluralize = function(count, irreg_plural) { return irreg_plural ? irreg_plural : this+'s' ; return this ; } + +/** + * Setup jquery-confirm + */ + +jconfirm.defaults = { + confirmButton: '', + cancelButton: '' +}; diff --git a/kfet/static/kfet/js/statistic.js b/kfet/static/kfet/js/statistic.js index db31e0e8..9baa08c4 100644 --- a/kfet/static/kfet/js/statistic.js +++ b/kfet/static/kfet/js/statistic.js @@ -7,7 +7,7 @@ var self = this; var element = $(target); - var content = $("++ {% endfor %} + + {% if groupteam.show_only != None and len > groupteam.show_only %} ++ {% image member.photo max-200x500 %} +++ {{ member.get_full_name }} ++
+ {% if member.nick_name %} + alias {{ member.nick_name }} + {% endif %} ++ ++ {% endif %} + +"); + var content = $(""); var buttons; function dictToArray (dict, start) { @@ -67,7 +67,6 @@ { label: chart.label, borderColor: chart.color, - backgroundColor: chart.color, fill: is_time_chart, lineTension: 0, data: chart_data, @@ -154,9 +153,8 @@ // initialize the interface function initialize (data) { // creates the bar with the buttons - buttons = $("", - {class: "btn-group btn-group-justified", - role: "group", + buttons = $("", + {class: "nav stat-nav", "aria-label": "select-period"}); var to_click; @@ -164,11 +162,9 @@ for (var i = 0; i < context.length; i++) { // creates the button - var btn_wrapper = $("
", - {class: "btn-group", - role:"group"}); - var btn = $("