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
def updateAdminById(id): body = request.get_json() admin = Admin.objects(id=id).update(**body) return response(str(admin), 'PUT')
def adminByid(id): admin = Admin.objects(id=id).delete() return response(str(admin), 'DELETE'), 200
def addAdmin(): body = request.get_json() admin = Admin(**body).save() id = admin.id return response(str(id), 'POST'), 200
def getAdminByName(name): admins = Admin.objects(name=name) return jsonify(response(admins, 'GET')), 200
def getAllAdmin(): admins = Admin.objects({}) return jsonify(response(admins, 'GET')), 200
def get(self): sign = Admin.objects().to_json() return Response(sign, mimetype="application/json", status=200)