예제 #1
0
 def post(self, request, *args, **kwargs):
     """ Método para cambiar la contraseña del usuario
     """
     try:
         body = QueryDict(request.body)
         user = User.objects.get(pk=request.user.id)
         new_password1 = body.get('new_password1')
         new_password2 = body.get('new_password2')
         if user.date_joined is None:
             user.date_joined = get_date_from_timezone()
             user.save()
         if user.last_login is None:
             user.last_login = get_date_from_timezone()
             user.save()
         if new_password1 and new_password2 is not None:
             user.set_password(new_password1)
             user.save()
             return HttpResponse(json.dumps('Contraseña cambiada exitosamente, por favor inicie sesión nuevamente.'),
                                 content_type='application/json')
         else:
             return HttpResponse(json.dumps('No se pudo cambiar la contraseña.'),
                                 content_type='application/json')
     except Exception, e:
         logger.error(e)
         return HttpResponse(e)
예제 #2
0
파일: views.py 프로젝트: roofcat/dtracking
 def post(self, request, *args, **kwargs):
     """ Método para cambiar la contraseña del usuario
     """
     try:
         body = QueryDict(request.body)
         user = User.objects.get(pk=request.user.id)
         new_password1 = body.get('new_password1')
         new_password2 = body.get('new_password2')
         if user.date_joined is None:
             user.date_joined = get_date_from_timezone()
             user.save()
         if user.last_login is None:
             user.last_login = get_date_from_timezone()
             user.save()
         if new_password1 and new_password2 is not None:
             user.set_password(new_password1)
             user.save()
             return HttpResponse(json.dumps('Contraseña cambiada exitosamente, por favor inicie sesión nuevamente.'),
                                 content_type='application/json')
         else:
             return HttpResponse(json.dumps('No se pudo cambiar la contraseña.'),
                                 content_type='application/json')
     except Exception, e:
         logging.error(e)
         return HttpResponse(e)
예제 #3
0
 def patch(self, request, *args, **kwargs):
     """ Método para cambiar datos del usuario
     """
     try:
         body = QueryDict(request.body)
         user = User.objects.get(pk=request.user.id)
         first_name = body.get('first_name')
         last_name = body.get('last_name')
         if user.date_joined is None:
             user.date_joined = get_date_from_timezone()
             user.save()
         if user.last_login is None:
             user.last_login = get_date_from_timezone()
             user.save()
         user.first_name = first_name
         user.last_name = last_name
         user.save()
         return HttpResponse(json.dumps('Registro actualizado exitosamente.'),
                             content_type='application/json')
     except Exception, e:
         logger.error(e)
         return HttpResponse(e)
예제 #4
0
파일: views.py 프로젝트: roofcat/dtracking
 def patch(self, request, *args, **kwargs):
     """ Método para cambiar datos del usuario
     """
     try:
         body = QueryDict(request.body)
         user = User.objects.get(pk=request.user.id)
         first_name = body.get('first_name')
         last_name = body.get('last_name')
         if user.date_joined is None:
             user.date_joined = get_date_from_timezone()
             user.save()
         if user.last_login is None:
             user.last_login = get_date_from_timezone()
             user.save()
         user.first_name = first_name
         user.last_name = last_name
         user.save()
         return HttpResponse(json.dumps('Registro actualizado exitosamente.'),
                             content_type='application/json')
     except Exception, e:
         logging.error(e)
         return HttpResponse(e)