add request to parse_value

This commit is contained in:
long2ice
2021-05-06 20:07:52 +08:00
parent 1e70bd09d2
commit 064eceea57
8 changed files with 33 additions and 32 deletions

View File

@ -28,7 +28,7 @@ async def list_view(
fields_name = model_resource.get_fields_name()
fields_label = model_resource.get_fields_label()
fields = model_resource.get_fields()
params = await model_resource.resolve_query_params(dict(request.query_params))
params = await model_resource.resolve_query_params(request, dict(request.query_params))
filters = await model_resource.get_filters(request, params)
qs = model.filter(**params)
total = await qs.count()
@ -84,7 +84,7 @@ async def update(
model=Depends(get_model),
):
form = await request.form()
data, m2m_data = await model_resource.resolve_data(form)
data, m2m_data = await model_resource.resolve_data(request, form)
async with in_transaction() as conn:
obj = (
await model.filter(pk=pk)
@ -172,7 +172,7 @@ async def create_view(
resources=Depends(get_resources),
model_resource: ModelResource = Depends(get_model_resource),
):
inputs = await model_resource.get_inputs()
inputs = await model_resource.get_inputs(request)
context = {
"request": request,
"resources": resources,
@ -203,9 +203,9 @@ async def create(
model_resource: ModelResource = Depends(get_model_resource),
model=Depends(get_model),
):
inputs = await model_resource.get_inputs()
inputs = await model_resource.get_inputs(request)
form = await request.form()
data, m2m_data = await model_resource.resolve_data(form)
data, m2m_data = await model_resource.resolve_data(request, form)
async with in_transaction() as conn:
obj = await model.create(**data, using_db=conn)
for k, items in m2m_data.items():