Commit ca09dd48 authored by John Red Medrano's avatar John Red Medrano

fix bug on creating user

parent 56f3eb9b
...@@ -11,7 +11,7 @@ from django.contrib.auth import authenticate ...@@ -11,7 +11,7 @@ from django.contrib.auth import authenticate
from django.contrib.auth.hashers import check_password from django.contrib.auth.hashers import check_password
from rest_framework.response import Response from rest_framework.response import Response
from django.forms.models import model_to_dict from django.forms.models import model_to_dict
from app.entities.models import User, EntityLog, PasswordReset from app.entities.models import User, EntityLog, PasswordReset, Application
from app.helper.decorators import rms, error_safe from app.helper.decorators import rms, error_safe
from django_filters import rest_framework as filters from django_filters import rest_framework as filters
from django.contrib.auth.hashers import make_password from django.contrib.auth.hashers import make_password
...@@ -51,10 +51,21 @@ class UserViewSet(viewsets.ModelViewSet): ...@@ -51,10 +51,21 @@ class UserViewSet(viewsets.ModelViewSet):
password = User.objects.make_random_password(length=10) password = User.objects.make_random_password(length=10)
password_hash = make_password(password) password_hash = make_password(password)
app = Application.objects.filter(
id__in=request.data['application']
)
instance = User.objects.get(
id=serializer.data['id']
)
instance.application.set(app)
User.objects.filter( User.objects.filter(
id=serializer.data['id'] id=serializer.data['id']
).update(password=password_hash) ).update(password=password_hash)
message = status_message_response( message = status_message_response(
201, 'success', 201, 'success',
'New Users created', serializer.data 'New Users created', serializer.data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment