Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@use_kwargs({'id': fields.Integer(missing=None)})
@validate_db(db)
def delete(self, id):
try:
if id is None:
DataModel.query.delete()
db.session.commit()
else:
db.session.delete(DataModel.query.get_or_404(id))
db.session.commit()
except:
return {'status': 'failed'}
else:
return {'status': 'successful'}
@flaskparser.use_kwargs(OPTIONS)
def get(font, image):
html = render_template(
'custom.html',
fonts=sorted(current_app.font_service.all()),
font=font,
image=image,
config=current_app.config,
)
response = make_response(html)
response.headers['Cache-Control'] = f'max-age={60*60*24*7}'
return response
@use_kwargs({"limit": fields.Int(missing=10, location="query")})
@use_schema(UserSchema, list_view=True)
def user_list(reqargs, limit):
users = db["users"].values()
if request.method == "POST":
User.insert(db=db, **reqargs)
return list(users)[:limit]
@use_kwargs(modify_schema, location='json') # type: ignore
def delete(
self,
eth_tokens: List[EthereumToken],
async_query: bool,
) -> Response:
return self.rest_api.remove_owned_eth_tokens(tokens=eth_tokens, async_query=async_query)
@use_kwargs(delete_schema, location='json') # type: ignore
def delete(self, labels: List[str]) -> Response:
return self.rest_api.remove_manually_tracked_balances(labels=labels)
@use_kwargs({'id': fields.Integer(missing=None)})
@validate_db(db)
def get(self, id):
if id is None:
return [query_to_dict(q) for q in DataModel.query.all()]
else:
return query_to_dict(DataModel.query.get_or_404(id))
@use_kwargs(edit_schema, location='json') # type: ignore
def patch(self, balances: List[ManuallyTrackedBalance]) -> Response:
return self.rest_api.edit_manually_tracked_balances(data=balances)
@use_kwargs({'submission_id': webargs_fields.Int(required=True)})
def submission_warning_reports(submission_id):
file_manager = FileHandler(request, is_local=is_local, server_path=server_path)
return file_manager.get_error_report_urls_for_submission(submission_id, is_warning=True)
@use_kwargs({
'file_type': webargs_fields.String(required=True, validate=webargs_validate.OneOf(('A', 'D1', 'D2'))),
'cgac_code': webargs_fields.String(),
'frec_code': webargs_fields.String(),
'start': webargs_fields.String(),
'end': webargs_fields.String(),
'year': webargs_fields.Int(),
'period': webargs_fields.Int(validate=webargs_validate.OneOf(list(range(2, 13)),
error="Period must be an integer 2-12.")),
'agency_type': webargs_fields.String(
missing='awarding',
validate=webargs_validate.OneOf(('awarding', 'funding'),
error="Must be either awarding or funding if provided")
),
'file_format': webargs_fields.String(
missing='csv',
validate=webargs_validate.OneOf(('csv', 'txt'),