Exemplo n.º 1
0
 def get(self, challenge_id):
     files = JudgeCaseFiles.query.filter_by(challenge_id=challenge_id).all()
     schema = FileSchema(many=True)
     response = schema.dump(files)
     if response.errors:
         return {"success": False, "errors": response.errors}, 400
     return {"success": True, "data": response.data}
Exemplo n.º 2
0
    def get(self, file_id):
        f = Files.query.filter_by(id=file_id).first_or_404()
        schema = FileSchema()
        response = schema.dump(f)

        if response.errors:
            return {"success": False, "errors": response.errors}, 400

        return {"success": True, "data": response.data}
Exemplo n.º 3
0
    def get(self):
        file_type = request.args.get("type")
        files = Files.query.filter_by(type=file_type).all()
        schema = FileSchema(many=True)
        response = schema.dump(files)

        if response.errors:
            return {"success": False, "errors": response.errors}, 400

        return {"success": True, "data": response.data}
Exemplo n.º 4
0
    def get(self):
        file_type = request.args.get('type')
        files = Files.query.filter_by(type=file_type).all()
        schema = FileSchema(many=True)
        response = schema.dump(files)

        if response.errors:
            return {'success': False, 'errors': response.errors}, 400

        return {'success': True, 'data': response.data}
Exemplo n.º 5
0
    def get(self, query_args):
        q = query_args.pop("q", None)
        field = str(query_args.pop("field", None))
        filters = build_model_filters(model=Files, query=q, field=field)

        files = Files.query.filter_by(**query_args).filter(*filters).all()
        schema = FileSchema(many=True)
        response = schema.dump(files)

        if response.errors:
            return {"success": False, "errors": response.errors}, 400

        return {"success": True, "data": response.data}
Exemplo n.º 6
0
 def post(self, challenge_id):
     files = request.files.getlist("file")
     objs = []
     for f in files:
         uploader = get_uploader()
         location = uploader.upload(file_obj=f, filename=f.filename)
         file_row = JudgeCaseFiles(
             challenge_id=challenge_id, location=location)
         db.session.add(file_row)
         db.session.commit()
         objs.append(file_row)
     schema = FileSchema(many=True)
     response = schema.dump(objs)
     if response.errors:
         return {"success": False, "errors": response.errorss}, 400
     return {"success": True, "data": response.data}
Exemplo n.º 7
0
    def post(self):
        files = request.files.getlist("file")
        # challenge_id
        # page_id

        objs = []
        for f in files:
            # uploads.upload_file(file=f, chalid=req.get('challenge'))
            obj = uploads.upload_file(file=f, **request.form.to_dict())
            objs.append(obj)

        schema = FileSchema(many=True)
        response = schema.dump(objs)

        if response.errors:
            return {"success": False, "errors": response.errorss}, 400

        return {"success": True, "data": response.data}