diff --git a/preferences/admin.py b/preferences/admin.py index 296dc57c..109fb936 100644 --- a/preferences/admin.py +++ b/preferences/admin.py @@ -34,6 +34,7 @@ from .models import ( OptionalTopologie, GeneralOption, Service, + Reminder, AssoOption, MailMessageOption, HomeOption @@ -79,6 +80,9 @@ class HomeOptionAdmin(VersionAdmin): """Class admin options home""" pass +class ReminderAdmin(VersionAdmin): + """Class reminder""" + pass admin.site.register(OptionalUser, OptionalUserAdmin) admin.site.register(OptionalMachine, OptionalMachineAdmin) @@ -86,5 +90,6 @@ admin.site.register(OptionalTopologie, OptionalTopologieAdmin) admin.site.register(GeneralOption, GeneralOptionAdmin) admin.site.register(HomeOption, HomeOptionAdmin) admin.site.register(Service, ServiceAdmin) +admin.site.register(Reminder, ReminderAdmin) admin.site.register(AssoOption, AssoOptionAdmin) admin.site.register(MailMessageOption, MailMessageOptionAdmin) diff --git a/preferences/forms.py b/preferences/forms.py index afe111a2..a95b8ef6 100644 --- a/preferences/forms.py +++ b/preferences/forms.py @@ -24,6 +24,7 @@ Formulaire d'edition des réglages : user, machine, topologie, asso... """ from __future__ import unicode_literals +from re2o.mixins import FormRevMixin from django.forms import ModelForm, Form from django import forms @@ -35,7 +36,8 @@ from .models import ( AssoOption, MailMessageOption, HomeOption, - Service + Service, + Reminder ) class EditOptionalUserForm(ModelForm): @@ -51,18 +53,6 @@ class EditOptionalUserForm(ModelForm): prefix=prefix, **kwargs ) - self.fields['is_tel_mandatory'].label = ( - 'Exiger un numéro de téléphone' - ) - self.fields['user_solde'].label = ( - 'Activation du solde pour les utilisateurs' - ) - self.fields['max_solde'].label = 'Solde maximum' - self.fields['min_online_payment'].label = ( - 'Montant de rechargement minimum en ligne' - ) - self.fields['self_adhesion'].label = 'Auto inscription' - class EditOptionalMachineForm(ModelForm): """Options machines (max de machines, etc)""" @@ -207,7 +197,7 @@ class EditHomeOptionForm(ModelForm): ) -class ServiceForm(ModelForm): +class ServiceForm(FormRevMixin, ModelForm): """Edition, ajout de services sur la page d'accueil""" class Meta: model = Service @@ -217,19 +207,13 @@ class ServiceForm(ModelForm): prefix = kwargs.pop('prefix', self.Meta.model.__name__) super(ServiceForm, self).__init__(*args, prefix=prefix, **kwargs) - -class DelServiceForm(Form): - """Suppression de services sur la page d'accueil""" - services = forms.ModelMultipleChoiceField( - queryset=Service.objects.none(), - label="Enregistrements service actuels", - widget=forms.CheckboxSelectMultiple - ) +class ReminderForm(FormRevMixin, ModelForm): + """Edition, ajout de rappel""" + class Meta: + model = Reminder + fields = '__all__' def __init__(self, *args, **kwargs): - instances = kwargs.pop('instances', None) - super(DelServiceForm, self).__init__(*args, **kwargs) - if instances: - self.fields['services'].queryset = instances - else: - self.fields['services'].queryset = Service.objects.all() + prefix = kwargs.pop('prefix', self.Meta.model.__name__) + super(ReminderForm, self).__init__(*args, prefix=prefix, **kwargs) + diff --git a/preferences/migrations/0035_reminder.py b/preferences/migrations/0035_reminder.py new file mode 100644 index 00000000..eaba7753 --- /dev/null +++ b/preferences/migrations/0035_reminder.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-05-05 10:53 +from __future__ import unicode_literals + +from django.db import migrations, models +import re2o.mixins + + +class Migration(migrations.Migration): + + dependencies = [ + ('preferences', '0034_auto_20180416_1120'), + ] + + operations = [ + migrations.CreateModel( + name='Reminder', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('days', models.IntegerField(default=7, help_text="Délais entre le mail et la fin d'adhésion", unique=True)), + ('message', models.CharField(blank=True, default='', max_length=255, null=True)), + ], + options={ + 'permissions': (('view_reminder', 'Peut voir un objet reminder'),), + }, + bases=(re2o.mixins.AclMixin, models.Model), + ), + ] diff --git a/preferences/models.py b/preferences/models.py index b5031e4d..2fe34932 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -239,6 +239,32 @@ def optionaltopologie_post_save(**kwargs): topologie_pref.set_in_cache() +class Reminder(AclMixin, models.Model): + """Options pour les mails de notification de fin d'adhésion. + Days: liste des nombres de jours pour lesquells un mail est envoyé + optionalMessage: message additionel pour le mail + """ + PRETTY_NAME="Options pour le mail de fin d'adhésion" + + days = models.IntegerField( + default=7, + unique=True, + help_text="Délais entre le mail et la fin d'adhésion" + ) + message = models.CharField( + max_length=255, + default="", + null=True, + blank=True, + help_text="Message affiché spécifiquement pour ce rappel" + ) + + class Meta: + permissions = ( + ("view_reminder", "Peut voir un objet reminder"), + ) + + class GeneralOption(AclMixin, PreferencesModel): """Options générales : nombre de resultats par page, nom du site, temps où les liens sont valides""" diff --git a/preferences/templates/preferences/aff_reminder.html b/preferences/templates/preferences/aff_reminder.html new file mode 100644 index 00000000..4bcaacce --- /dev/null +++ b/preferences/templates/preferences/aff_reminder.html @@ -0,0 +1,47 @@ +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Gabriel Détraz +Copyright © 2017 Goulven Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +{% endcomment %} +{% load acl %} +
Nombre de jours avant le rappel | +Message custom pour ce rappel | ++ | + |
---|---|---|---|
{{ reminder.days }} | +{{ reminder.message }} | ++ {% can_edit reminder %} + {% include 'buttons/edit.html' with href='preferences:edit-reminder' id=reminder.id %} + {% acl_end %} + {% include 'buttons/history.html' with href='preferences:history' name='reminder' id=reminder.id %} + | +
-
Url du compte twitter | -{{ homeoptions.twitter_url }} | -Nom utilisé pour afficher le compte | -{{ homeoptions.twitter_account_name }} | -
---|---|---|---|
Url du compte facebook | -{{ homeoptions.facebook_url }} | -||
{{ field }} | +{{ text }} | + {% endfor %} +