예제 #1
0
파일: forms.py 프로젝트: Retenodus/Maiznet
    def save(self, user):
        # La chambre de l'utilisateur
        room = Room.objects.get(ticket=self.cleaned_data["ticket"])

        # En cas d'occupant précédent, on l'enlève de la chambre
        try:
            prev = Presence.objects.get(room=room)
            prev.room = None
            prev.save()
        except Presence.DoesNotExist:
            pass

            # On modifie son profil
        try:
            p = user.get_profile()
        except Presence.DoesNotExist:
            p = Presence(user=user)
        p.room = room
        p.save()
예제 #2
0
파일: forms.py 프로젝트: Retenodus/Maiznet
    def save(self):
        user = super(UserRegistrationForm, self).save()

        # La chambre de l'utilisateur
        room = Room.objects.get(ticket=self.cleaned_data["ticket"])

        # En cas d'occupant précédent, on l'enlève de la chambre
        try:
            prev = Presence.objects.get(room=room)
            prev.room = None
            prev.save()
        except Presence.DoesNotExist:
            pass

            # On créé son profil
        p = Presence(user=user, room=room, netif=self.cleaned_data["netif"])
        p.save()

        # On l'ajoute à sa promo
        if self.cleaned_data["promo"] != None:
            user.groups.add(self.cleaned_data["promo"])

        return user