Beispiel #1
0
 def post(self):
     try:
         user_id = get_jwt_identity()
         body = request.get_json()
         user = AdminSignUp.objects.get(id=user_id)
         admin = Admin(**body, added_by=user)
         admin.save()
         user.update(push__admin=admin)
         user.save()
         id = admin.id
         return {'id': str(id)}, 200
     except (FieldDoesNotExist, ValidationError):
         raise SchemaValidationError
     except NotUniqueError:
         raise ItemAlreadyExistsError
     except Exception as e:
         raise InternalServerError
Beispiel #2
0
def updateAdminById(id):
    body = request.get_json()
    admin = Admin.objects(id=id).update(**body)
    return response(str(admin), 'PUT')
Beispiel #3
0
def adminByid(id):
    admin = Admin.objects(id=id).delete()
    return response(str(admin), 'DELETE'), 200
Beispiel #4
0
def addAdmin():
    body = request.get_json()
    admin = Admin(**body).save()
    id = admin.id
    return response(str(id), 'POST'), 200
Beispiel #5
0
def getAdminByName(name):
    admins = Admin.objects(name=name)
    return jsonify(response(admins, 'GET')), 200
Beispiel #6
0
def getAllAdmin():
    admins = Admin.objects({})
    return jsonify(response(admins, 'GET')), 200
Beispiel #7
0
 def get(self):
     sign = Admin.objects().to_json()
     return Response(sign, mimetype="application/json", status=200)