From 293f2853bbd3d64302f317e8e3557dafb1657759 Mon Sep 17 00:00:00 2001 From: wuaho Date: Fri, 17 Sep 2021 14:25:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E8=AE=BE=E7=BD=AE=E7=94=B1?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E6=94=B9=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/dashboard.py | 3 ++- schemas/dashboard.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/api/api_v1/endpoints/dashboard.py b/api/api_v1/endpoints/dashboard.py index b52656c..2dce755 100644 --- a/api/api_v1/endpoints/dashboard.py +++ b/api/api_v1/endpoints/dashboard.py @@ -34,7 +34,8 @@ async def edit_show_report( ) -> schemas.Msg: report_id = data_in.config.report_id res = await crud.dashboard.update_one(db, {'_id': data_in.dashboard_id, 'reports.report_id': report_id}, - {'$set': {f'reports.$.{k}': v for k, v in data_in.config.dict().items()}}) + {'$set': {f'reports.$.{k}': v for k, v in + data_in.config.dict(skip_defaults=True).items()}}) if res.modified_count == 1: return schemas.Msg(code=0, msg='ok', data=data_in.config) elif res.modified_count == 0: diff --git a/schemas/dashboard.py b/schemas/dashboard.py index ca0f113..96c30a2 100644 --- a/schemas/dashboard.py +++ b/schemas/dashboard.py @@ -29,14 +29,14 @@ class DashboardDelete(BaseModel): class Report(BaseModel): - name: str - report_id: str - graph_type: str - ascending: bool - model: str - graph_size: str - sort: int = 1 - modelswitch: bool = False + name: str = None + report_id: str = None + graph_type: str = None + ascending: bool = None + model: str = None + graph_size: str = None + sort: int = None + modelswitch: bool = None class EditShowReport(BaseModel):