mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 22:52:26 +00:00
serialization des finfos pour créer les home
This commit is contained in:
parent
dc8cf8dbcc
commit
27d18e034b
4 changed files with 20 additions and 0 deletions
|
@ -552,6 +552,15 @@ class AdherentSerializer(NamespacedHMSerializer):
|
||||||
'shell': {'view_name': 'shell-detail'}
|
'shell': {'view_name': 'shell-detail'}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class HomeCreationSerializer(NamespacedHMSerializer):
|
||||||
|
"""Serialize 'users.models.User' minimal infos to create home
|
||||||
|
"""
|
||||||
|
uid = serializers.IntegerField(source='uid_number')
|
||||||
|
gid = serializers.IntegerField(source='gid_number')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = users.User
|
||||||
|
fields = ('pseudo', 'uid', 'gid')
|
||||||
|
|
||||||
class ServiceUserSerializer(NamespacedHMSerializer):
|
class ServiceUserSerializer(NamespacedHMSerializer):
|
||||||
"""Serialize `users.models.ServiceUser` objects.
|
"""Serialize `users.models.ServiceUser` objects.
|
||||||
|
|
|
@ -86,6 +86,7 @@ router.register_viewset(r'topologie/room', views.RoomViewSet)
|
||||||
router.register(r'topologie/portprofile', views.PortProfileViewSet)
|
router.register(r'topologie/portprofile', views.PortProfileViewSet)
|
||||||
# USERS
|
# USERS
|
||||||
router.register_viewset(r'users/user', views.UserViewSet)
|
router.register_viewset(r'users/user', views.UserViewSet)
|
||||||
|
router.register_viewset(r'users/homecreation', views.HomeCreationViewSet)
|
||||||
router.register_viewset(r'users/club', views.ClubViewSet)
|
router.register_viewset(r'users/club', views.ClubViewSet)
|
||||||
router.register_viewset(r'users/adherent', views.AdherentViewSet)
|
router.register_viewset(r'users/adherent', views.AdherentViewSet)
|
||||||
router.register_viewset(r'users/serviceuser', views.ServiceUserViewSet)
|
router.register_viewset(r'users/serviceuser', views.ServiceUserViewSet)
|
||||||
|
|
|
@ -418,6 +418,11 @@ class UserViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = users.User.objects.all()
|
queryset = users.User.objects.all()
|
||||||
serializer_class = serializers.UserSerializer
|
serializer_class = serializers.UserSerializer
|
||||||
|
|
||||||
|
class HomeCreationViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
|
"""Exposes infos of `users.models.Users` objects to create homes.
|
||||||
|
"""
|
||||||
|
queryset = users.User.objects.all()
|
||||||
|
serializer_class = serializers.HomeCreationSerializer
|
||||||
|
|
||||||
class ClubViewSet(viewsets.ReadOnlyModelViewSet):
|
class ClubViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
"""Exposes list and details of `users.models.Club` objects.
|
"""Exposes list and details of `users.models.Club` objects.
|
||||||
|
|
|
@ -283,6 +283,11 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("Type inconnu")
|
raise NotImplementedError("Type inconnu")
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def gid_number(self):
|
||||||
|
"""renvoie le gid par défaut des users"""
|
||||||
|
return int(LDAP['user_gid'])
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_class_club(self):
|
def is_class_club(self):
|
||||||
""" Returns True if the object is a Club (subclassing User) """
|
""" Returns True if the object is a Club (subclassing User) """
|
||||||
|
|
Loading…
Reference in a new issue