Mr-Help commited on
Commit
aefcfc7
·
verified ·
1 Parent(s): ffed1e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -43
app.py CHANGED
@@ -177,52 +177,52 @@ async def create_task(request: Request):
177
  print("❌ Failed to create task from template")
178
  return {"error": "Template task creation failed"}
179
 
180
- # If not using template, fallback to normal creation
181
- elif task_type_lower in ["strategy", "posting", "ads report"]:
182
- if task_type_lower == "strategy":
183
- status = "to do"
184
- description_text = description
185
-
186
- elif task_type_lower == "posting":
187
- status = "ready for posting"
188
- parts = []
189
- if posting_content:
190
- parts.append(posting_content.strip())
191
- if platforms:
192
- parts.append("Platforms: " + ", ".join(platforms))
193
- if attachment_link:
194
- parts.append(f"Attachment: {attachment_link.strip()}")
195
- description_text = "\n\n".join(parts)
196
-
197
- elif task_type_lower == "ads report":
198
- status = "ready"
199
- platforms_text = ", ".join(platforms) if platforms else ""
200
- description_text = f"Prepare an ads report for {platforms_text}"
201
- if start_date and end_date:
202
- description_text += f" from {start_date} to {end_date}"
203
-
204
- payload = {
205
- "name": task_title,
206
- "description": description_text,
207
- "assignees": [int(uid) for uid in assignee_ids],
208
- "status": status
209
- }
210
 
211
- # Handle due date
212
- if deadline:
213
- try:
214
- due_timestamp = int(datetime.strptime(deadline, "%Y-%m-%d").timestamp() * 1000)
215
- payload["due_date"] = due_timestamp
216
- print(f"Due Date (timestamp): {due_timestamp}")
217
- except ValueError:
218
- print("Invalid deadline format. Skipping due_date.")
 
 
219
 
220
- create_url = f"{CLICKUP_URL_BASE}/list/{list_id}/task"
221
- clickup_response = requests.post(create_url, headers=headers, json=payload)
222
- clickup_data = clickup_response.json()
223
- print(f"ClickUp Response: {clickup_response.status_code}, {clickup_data}")
 
 
224
 
225
- return {"status": "Standard task created", "clickup": clickup_data}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  # After task creation and response
227
  new_task_id = clickup_data.get("id")
228
  space_id = clickup_data.get("space", {}).get("id")
 
177
  print("❌ Failed to create task from template")
178
  return {"error": "Template task creation failed"}
179
 
180
+ # If not using template, fallback to normal creation
181
+ elif task_type_lower in ["strategy", "posting", "ads report"]:
182
+ if task_type_lower == "strategy":
183
+ status = "to do"
184
+ description_text = description
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
+ elif task_type_lower == "posting":
187
+ status = "ready for posting"
188
+ parts = []
189
+ if posting_content:
190
+ parts.append(posting_content.strip())
191
+ if platforms:
192
+ parts.append("Platforms: " + ", ".join(platforms))
193
+ if attachment_link:
194
+ parts.append(f"Attachment: {attachment_link.strip()}")
195
+ description_text = "\n\n".join(parts)
196
 
197
+ elif task_type_lower == "ads report":
198
+ status = "ready"
199
+ platforms_text = ", ".join(platforms) if platforms else ""
200
+ description_text = f"Prepare an ads report for {platforms_text}"
201
+ if start_date and end_date:
202
+ description_text += f" from {start_date} to {end_date}"
203
 
204
+ payload = {
205
+ "name": task_title,
206
+ "description": description_text,
207
+ "assignees": [int(uid) for uid in assignee_ids],
208
+ "status": status
209
+ }
210
+
211
+ # Handle due date
212
+ if deadline:
213
+ try:
214
+ due_timestamp = int(datetime.strptime(deadline, "%Y-%m-%d").timestamp() * 1000)
215
+ payload["due_date"] = due_timestamp
216
+ print(f"Due Date (timestamp): {due_timestamp}")
217
+ except ValueError:
218
+ print("Invalid deadline format. Skipping due_date.")
219
+
220
+ create_url = f"{CLICKUP_URL_BASE}/list/{list_id}/task"
221
+ clickup_response = requests.post(create_url, headers=headers, json=payload)
222
+ clickup_data = clickup_response.json()
223
+ print(f"ClickUp Response: {clickup_response.status_code}, {clickup_data}")
224
+
225
+ return {"status": "Standard task created", "clickup": clickup_data}
226
  # After task creation and response
227
  new_task_id = clickup_data.get("id")
228
  space_id = clickup_data.get("space", {}).get("id")