def post(self, key, value): user = User.objects.get(id=get_user_id()) if key == "costOfPaper": user.update(costOfPaper=value) return Response({"Success": "200"}, mimetype="application/json", status=200) else: return "Not Permitted", 401
def get(self): forms = Form.objects() if 'excel' in request.args: return send_from_directory(directory=UPLOAD_FOLDER, filename=export_to_excel( forms, get_user_id())) return Response(forms.to_json(), mimetype="application/json", status=200)
def get(self): application_templates = ApplicationTemplate.objects().order_by( '-timestamp') if 'excel' in request.args: return send_from_directory(directory=UPLOAD_FOLDER, filename=export_to_excel( application_templates, get_user_id())) return Response(application_templates.to_json(), mimetype="application/json", status=200)
def get(self): u = User.objects(role__nin=['user']).\ exclude('private_key', 'public_key', 'password') if 'unapproved' in request.args: u = User.objects(Q(role=get_jwt_identity()['role']) & Q(approved=False)).\ exclude('private_key', 'public_key', 'password') if 'excel' in request.args: return send_from_directory(directory=UPLOAD_FOLDER, filename=export_to_excel( u, get_user_id())) return Response(u.to_json(), mimetype="application/json", status=200)
def get(self): filter_q = None limit_q = None if 'filter' in request.args: if request.args['filter'] == 'signed': filter_q = Q(status=1) elif request.args['filter'] == 'rejected': filter_q = Q(status=-1) elif request.args['filter'] == 'pending': filter_q = Q(status=0) if 'limit' in request.args: limit_q = int(request.args['limit']) if get_jwt_identity()['role'] != 'user': if filter_q is not None: q = Application.objects(filter_q & ( Q(assignedId=get_jwt_identity()['_id']['$oid']) | Q(creatorId=get_jwt_identity()['_id']['$oid']))) else: q = Application.objects( Q(assignedId=get_jwt_identity()['_id']['$oid']) | Q(creatorId=get_jwt_identity()['_id']['$oid'])) else: if filter_q is not None: q = Application.objects(filter_q & (Q( creatorId=get_jwt_identity()['_id']['$oid']))) else: q = Application.objects( Q(creatorId=get_jwt_identity()['_id']['$oid'])) q = q.order_by('-timestamp') if 'excel' in request.args: return send_from_directory(directory=UPLOAD_FOLDER, filename=export_to_excel( q, get_user_id())) if limit_q is not None: return Response(q[:limit_q].to_json(), mimetype="application/json", status=200) else: return Response(q.to_json(), mimetype="application/json", status=200)
def get(self): user = User.objects().get(id=get_user_id()) return Response(user.to_json(), mimetype="application/json", status=200)
def get(self, key): user = User.objects.get(id=get_user_id()) return {"result": getattr(user, key)}, 200
def get(self): q = Storage.objects(Q(creator=get_jwt_identity()['_id']['$oid']) | Q(visibility='public') | Q(visibility=get_user_role())).order_by('-timestamp') if 'limit' in request.args: limit = int(request.args['limit']) return Response(q[:limit].to_json(), mimetype="application/json", status=200) elif 'excel' in request.args: return send_from_directory(directory=UPLOAD_FOLDER, filename=export_to_excel(q, get_user_id())) return Response(q.to_json(), mimetype="application/json", status=200)