Browse Source

implement erase existing data for import

tripeur 2 years ago
parent
commit
1e9ea57e46
2 changed files with 5 additions and 0 deletions
  1. 4 0
      app/api/endpoints/project.py
  2. 1 0
      app/schemas/requests.py

+ 4 - 0
app/api/endpoints/project.py

@@ -111,6 +111,10 @@ async def update_project_from_gsheet(
     if p is None:
         raise HTTPException(status_code=404, detail="Project not found")
     doc_id = extract_doc_uid(gsheet.sheet_url)
+    if gsheet.erase_data:
+        p.slots = []
+        p.sms = []
+        p.volunteers = []
     df_contact, df_creneau, df_planning = parseGsheet(doc_id, gsheet.satursday_date)
     # Create the volunteer list
     volunteer_map: dict[str, Volunteer] = {}

+ 1 - 0
app/schemas/requests.py

@@ -47,6 +47,7 @@ class ProjectRequest(BaseRequest):
 class ProjectImportGsheetRequest(BaseRequest):
     sheet_url: str
     satursday_date: datetime.datetime
+    erase_data: Optional[bool] = Field(default=False)
 
 
 class ProjectSMSBatchRequest(BaseRequest):