8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-09-12 01:03:09 +00:00

serialization des rappel de fin de connexion

This commit is contained in:
grisel-davy 2018-07-03 18:34:10 +02:00
parent c3cb847ccf
commit 57d6a12aa4
4 changed files with 42 additions and 0 deletions

View file

@ -804,6 +804,26 @@ class DNSZonesSerializer(serializers.ModelSerializer):
'mx_records', 'txt_records', 'srv_records', 'a_records',
'aaaa_records', 'cname_records')
#REMINDER
class ReminderUsersSerializer(UserSerializer):
"""Serialize the data about a mailing member.
"""
class Meta(UserSerializer.Meta):
fields = ('get_full_name', 'email')
class ReminderSerializer(serializers.ModelSerializer):
"""
Serialize the data about a reminder
"""
users_to_remind = ReminderUsersSerializer(many=True)
class Meta:
model = preferences.Reminder
fields = ('days','message','users_to_remind')
# MAILING

View file

@ -100,6 +100,8 @@ router.register_viewset(r'services/regen', views.ServiceRegenViewSet, base_name=
router.register_view(r'dhcp/hostmacip', views.HostMacIpView),
# Switches config
router.register_view(r'switchs/ports-config', views.SwitchPortView),
# Reminder
router.register_view(r'reminder/get-users', views.ReminderView),
# DNS
router.register_view(r'dns/zones', views.DNSZonesView),
# MAILING

View file

@ -504,6 +504,15 @@ class SwitchPortView(generics.ListAPIView):
queryset = topologie.Switch.objects.all().prefetch_related('ports__custom_profile')
serializer_class = serializers.SwitchPortSerializer
# Rappel fin adhésion
class ReminderView(generics.ListAPIView):
"""Exposes the associations between hostname, mac address and IPv4 in
order to build the DHCP lease files.
"""
queryset = preferences.Reminder.objects.all()
serializer_class = serializers.ReminderSerializer
# DHCP

View file

@ -26,6 +26,7 @@ Reglages généraux, machines, utilisateurs, mail, general pour l'application.
from __future__ import unicode_literals
from django.utils.functional import cached_property
from django.utils import timezone
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
@ -36,8 +37,11 @@ import cotisations.models
import machines.models
from re2o.mixins import AclMixin
from .aes_field import AESEncryptedField
from datetime import timedelta
class PreferencesModel(models.Model):
""" Base object for the Preferences objects
@ -283,6 +287,13 @@ class Reminder(AclMixin, models.Model):
("view_reminder", "Peut voir un objet reminder"),
)
def users_to_remind(self):
from re2o.utils import all_has_access
date = timezone.now().replace(minute=0,hour=0)
futur_date = date + timedelta(days=self.days)
users = all_has_access(futur_date).exclude(pk__in = all_has_access(futur_date + timedelta(days=1)))
return users
class GeneralOption(AclMixin, PreferencesModel):
"""Options générales : nombre de resultats par page, nom du site,