def glue_to(self, user=None, create=False): if user is None: self._obj.hierarchy = 'master' reset_password = User.objects.make_random_password(length=10, allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789') print reset_password #send to the user data = { 'subject': 'Password Reset', 'message': 'Dear customer, your new password is:' + reset_password + '. Have the best re-charging experience ever! ', 'phone': self._obj.username } if self._obj.email is not None or self._obj.email is not ' ': self._obj.set_password(reset_password) message_as_email(data) else: message_as_sms(data) else: self._obj.hierarchy = 'slave' self._obj.set_unusable_password() #send notification that the user can only log in with the master self._obj.glue = user self._obj.ack = False if create: self._obj.save()
def ResetPassword(request, username): if request.method == 'GET': user = User.objects.get(username=username) reset_password = User.objects.make_random_password( length=10, allowed_chars= 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789') #remeber to send the password to the phone no. of the user. Once the email is set, the user can make choices. data = { 'subject': 'Password Reset', 'message': 'Dear customer, your new password is:' + reset_password + '. Have the best re-charging experience ever! ', 'recipient': request.user.email, 'phone': request.user.username } if request.user.email is not None or request.user.email is not ' ': user.set_password(reset_password) user.save() message_as_email(data) else: message_as_sms(data) return Response({'success': True})
def glue_to(self, user=None, create=False): if user is None: self._obj.hierarchy = 'master' reset_password = User.objects.make_random_password( length=10, allowed_chars= 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789') print reset_password #send to the user data = { 'subject': 'Password Reset', 'message': 'Dear customer, your new password is:' + reset_password + '. Have the best re-charging experience ever! ', 'phone': self._obj.username } if self._obj.email is not None or self._obj.email is not ' ': self._obj.set_password(reset_password) message_as_email(data) else: message_as_sms(data) else: self._obj.hierarchy = 'slave' self._obj.set_unusable_password() #send notification that the user can only log in with the master self._obj.glue = user self._obj.ack = False if create: self._obj.save()
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
def ResetPassword(request, username): if request.method == 'GET': user = User.objects.get(username=username) reset_password = User.objects.make_random_password(length=10, allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789') #remeber to send the password to the phone no. of the user. Once the email is set, the user can make choices. data = { 'subject': 'Password Reset', 'message': 'Dear customer, your new password is:' + reset_password + '. Have the best re-charging experience ever! ', 'recipient': request.user.email, 'phone': request.user.username } if request.user.email is not None or request.user.email is not ' ': user.set_password(reset_password) user.save() message_as_email(data) else: message_as_sms(data) return Response({'success': True})
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
def sendMessage(data): message_as_sms(data) return 'success'