mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
serialisation des alias mail des users ayant activé l'adresse interne
This commit is contained in:
parent
68615c01ea
commit
1e823ad75b
4 changed files with 33 additions and 0 deletions
14
api/serializers.py
Normal file → Executable file
14
api/serializers.py
Normal file → Executable file
|
@ -631,6 +631,9 @@ class MailAliasSerializer(NamespacedHMSerializer):
|
||||||
fields = ('user', 'valeur', 'complete_mail')
|
fields = ('user', 'valeur', 'complete_mail')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# SERVICE REGEN
|
# SERVICE REGEN
|
||||||
|
|
||||||
|
|
||||||
|
@ -647,6 +650,17 @@ class ServiceRegenSerializer(NamespacedHMSerializer):
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
'api_url': {'view_name': 'serviceregen-detail'}
|
'api_url': {'view_name': 'serviceregen-detail'}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Configuration mail
|
||||||
|
|
||||||
|
|
||||||
|
class UserMailAliasSerializer(NamespacedHMSerializer):
|
||||||
|
get_mail_aliases = MailAliasSerializer(read_only=True, many=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = users.User
|
||||||
|
fields = ('pseudo', 'get_mail_aliases')
|
||||||
|
|
||||||
|
|
||||||
# Switches et ports
|
# Switches et ports
|
||||||
|
|
||||||
|
|
2
api/urls.py
Normal file → Executable file
2
api/urls.py
Normal file → Executable file
|
@ -102,6 +102,8 @@ router.register_view(r'dhcp/hostmacip', views.HostMacIpView),
|
||||||
# Switches config
|
# Switches config
|
||||||
router.register_view(r'switchs/ports-config', views.SwitchPortView),
|
router.register_view(r'switchs/ports-config', views.SwitchPortView),
|
||||||
router.register_view(r'switchs/role', views.RoleView),
|
router.register_view(r'switchs/role', views.RoleView),
|
||||||
|
# Mail config
|
||||||
|
router.register_view(r'mail/alias', views.UserMailAliasView),
|
||||||
# Reminder
|
# Reminder
|
||||||
router.register_view(r'reminder/get-users', views.ReminderView),
|
router.register_view(r'reminder/get-users', views.ReminderView),
|
||||||
# DNS
|
# DNS
|
||||||
|
|
11
api/views.py
Normal file → Executable file
11
api/views.py
Normal file → Executable file
|
@ -521,6 +521,17 @@ class RoleView(generics.ListAPIView):
|
||||||
serializer_class = serializers.RoleSerializer
|
serializer_class = serializers.RoleSerializer
|
||||||
|
|
||||||
|
|
||||||
|
# Server mail config
|
||||||
|
|
||||||
|
|
||||||
|
class UserMailAliasView(generics.ListAPIView):
|
||||||
|
"""Expose all the aliases of the users that activated the internal address
|
||||||
|
"""
|
||||||
|
|
||||||
|
queryset = users.User.objects.filter(internal_address=True)
|
||||||
|
serializer_class = serializers.UserMailAliasSerializer
|
||||||
|
|
||||||
|
|
||||||
# Rappel fin adhésion
|
# Rappel fin adhésion
|
||||||
|
|
||||||
class ReminderView(generics.ListAPIView):
|
class ReminderView(generics.ListAPIView):
|
||||||
|
|
6
users/models.py
Normal file → Executable file
6
users/models.py
Normal file → Executable file
|
@ -682,6 +682,12 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
else:
|
else:
|
||||||
return str(self.mailalias_set.get(valeur=self.pseudo))
|
return str(self.mailalias_set.get(valeur=self.pseudo))
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def get_mail_aliases(self):
|
||||||
|
if self.internal_address:
|
||||||
|
return self.mailalias_set.all()
|
||||||
|
return None
|
||||||
|
|
||||||
def get_next_domain_name(self):
|
def get_next_domain_name(self):
|
||||||
"""Look for an available name for a new interface for
|
"""Look for an available name for a new interface for
|
||||||
this user by trying "pseudo0", "pseudo1", "pseudo2", ...
|
this user by trying "pseudo0", "pseudo1", "pseudo2", ...
|
||||||
|
|
Loading…
Reference in a new issue