Exemplo n.º 1
0
 def update(cls, username, metadata):
     user = User.objects.get(username=username)
     fields = metadata.keys()
     for field in fields:
         setattr(user, field, metadata[field])
     user.save()
     response = instance_to_dict(user, UserApi.base_field)
     return Response(asjson.dumps(response), mimetype='application/json')
Exemplo n.º 2
0
 def get(cls, username):
     user = User.objects.get(username=username)
     response = instance_to_dict(user, UserApi.base_field)
     return Response(asjson.dumps(response), mimetype='application/json')
Exemplo n.º 3
0
 def create(cls, metadata):
     user = User(**metadata).save()
     response = instance_to_dict(user, UserApi.base_field)
     return Response(asjson.dumps(response), mimetype='application/json')
Exemplo n.º 4
0
 def index(cls):
     users = User.objects.all()
     # we used wrapper "instance_to_dict" for select by based field model
     response = [instance_to_dict(user, UserApi.base_field) for user in users]
     return Response(asjson.dumps(response), mimetype='application/json')