コード例 #1
0
    def restore_object(self, attrs, instance=None):
        assert instance
        if self.context['kwargs'].get('uplink_user', False):
            uplink_wallet = Wallet.objects.get(
                owner=self.context['kwargs']['uplink_user'])
            uplink_wallet = UserBehaviour.subtract_from_wallet(
                uplink_wallet, attrs['amount'])
            uplink_wallet.save()

            instance = UserBehaviour.add_to_wallet(instance, attrs['amount'])
            return instance

        elif self.context['kwargs'].get('master_user', False):
            master_wallet = Wallet.objects.get(
                owner=self.context['kwargs']['master_user'])
            master_wallet = UserBehaviour.subtract_from_wallet(
                master_wallet, attrs['amount'])
            master_wallet.save()

            instance = UserBehaviour.add_to_wallet(instance, attrs['amount'])
            return instance

        instance = UserBehaviour.subtract_from_wallet(instance,
                                                      attrs['amount'])
        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
ファイル: utils.py プロジェクト: henyhollar/kibati-arooko
    def wrapper(req, data):
        if 'stop' in data:
            return f(req, data)

        #user = User.objects.get(username=data['phone'])
        user_behaviour = UserBehaviour(username=data['phone'])

        if data['request'] == 'beep':
            data.update({
                'amount': user_behaviour.default_amt,
                'status': 'master'
            })

        if user_behaviour.get_hierarchy == 'slave':
            data.update({'master': user_behaviour.glue_to, 'status': 'slave'})

        if user_behaviour.get_permission == 'downlink':
            data.update({
                'uplink': user_behaviour.plug_into,
                'status': 'downlink'
            })

        data.update({'user': user_behaviour._obj})

        return f(req, data)
コード例 #4
0
    def restore_object(self, attrs, instance=None):
        assert instance
        if self.context['kwargs'].get('uplink_user', False):
            uplink_wallet = Wallet.objects.get(owner=self.context['kwargs']['uplink_user'])
            uplink_wallet = UserBehaviour.subtract_from_wallet(uplink_wallet, attrs['amount'])
            uplink_wallet.save()

            instance = UserBehaviour.add_to_wallet(instance, attrs['amount'])
            return instance

        elif self.context['kwargs'].get('master_user', False):
            master_wallet = Wallet.objects.get(owner=self.context['kwargs']['master_user'])
            master_wallet = UserBehaviour.subtract_from_wallet(master_wallet, attrs['amount'])
            master_wallet.save()

            instance = UserBehaviour.add_to_wallet(instance, attrs['amount'])
            return instance

        instance = UserBehaviour.subtract_from_wallet(instance, attrs['amount'])
        return instance
コード例 #5
0
ファイル: views.py プロジェクト: Chitrank-Dixit/kibati-arooko
    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
コード例 #6
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
コード例 #7
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