예제 #1
0
    def restore_object(self, attrs, instance=None):
        """
        toggle effect for de-plugging.
        """
        assert instance

        if self.context['kwargs'].get('uplink_user', False):
            user_behaviour = UserBehaviour(instance)
            user_behaviour.plug_into = self.context['kwargs']['uplink_user']
        else:
            user_behaviour = UserBehaviour(username=instance.username)
            instance = user_behaviour.unplug()

        return instance
예제 #2
0
    def restore_object(self, attrs, instance=None):
        """
        toggle effect for de-plugging.
        """
        assert instance

        if self.context['kwargs'].get('uplink_user', False):
            user_behaviour = UserBehaviour(instance)
            user_behaviour.plug_into = self.context['kwargs']['uplink_user']
        else:
            user_behaviour = UserBehaviour(username=instance.username)
            instance = user_behaviour.unplug()

        return instance
예제 #3
0
    def pre_save(self, obj):
        reset_password = User.objects.make_random_password(
            length=10, allowed_chars="abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"
        )
        print reset_password
        obj.set_password(reset_password)
        # remeber to send the password to the phone no. of the user. Once the email is set, the user can make choices.
        data = {
            "message": "Dear customer, thanks for signing up. Your password is:"
            + reset_password
            + ". Have the best re-charging experience ever! ",
            "phone": obj.username,
        }
        message_as_sms(data)

        user_behaviour = UserBehaviour(obj)

        # get the instance of the uplink
        uplink_user = User.objects.get(username=self.kwargs["uplink_username"])

        # plug the new user to the uplink
        user_behaviour.plug_into = uplink_user
예제 #4
0
    def pre_save(self, obj):
        reset_password = User.objects.make_random_password(
            length=10,
            allowed_chars=
            'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789')
        print reset_password
        obj.set_password(reset_password)
        #remeber to send the password to the phone no. of the user. Once the email is set, the user can make choices.
        data = {
            'message':
            'Dear customer, thanks for signing up. Your password is:' +
            reset_password + '. Have the best re-charging experience ever! ',
            'phone':
            obj.username
        }
        message_as_sms(data)

        user_behaviour = UserBehaviour(obj)

        #get the instance of the uplink
        uplink_user = User.objects.get(username=self.kwargs['uplink_username'])

        #plug the new user to the uplink
        user_behaviour.plug_into = uplink_user