Mr-Help commited on
Commit
85306f9
·
verified ·
1 Parent(s): ac6026c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py CHANGED
@@ -75,6 +75,49 @@ async def create_task(request: Request):
75
  print(f"Start Date: {start_date}")
76
  print(f"End Date: {end_date}")
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  # WhatsApp notification part is commented out for now
79
  # We'll handle WhatsApp notification later
80
 
 
75
  print(f"Start Date: {start_date}")
76
  print(f"End Date: {end_date}")
77
 
78
+ # Strategy task logic
79
+ if task_type.lower() == "strategy":
80
+ web_app_url = "https://script.google.com/macros/s/AKfycbzpshAMkjxBTFa4eGowsQIrpbcUOXa9GpB7i5Fzsaiz6BH2FZmUMY1k1DRhFg90CUp-/exec"
81
+ params = {
82
+ "mode": "extended",
83
+ "taskType": task_type,
84
+ "company": team,
85
+ "assignees": ','.join(assignees)
86
+ }
87
+
88
+ response = requests.get(web_app_url, params=params)
89
+ response_data = response.json()
90
+ print(f"Web App Response: {response_data}")
91
+
92
+ list_id = response_data.get("listId")
93
+ print(f"List ID: {list_id}")
94
+
95
+ assignee_ids = response_data.get("assigneeIds", [])
96
+ print(f"Assignee IDs: {assignee_ids}")
97
+
98
+ # Prepare ClickUp task payload
99
+ payload = {
100
+ "name": task_title,
101
+ "description": description,
102
+ "assignees": assignee_ids,
103
+ "priority": 2, # Normal priority
104
+ "status": "backlog"
105
+ }
106
+
107
+ if deadline:
108
+ try:
109
+ due_timestamp = int(datetime.strptime(deadline, "%Y-%m-%d").timestamp() * 1000)
110
+ payload["due_date"] = due_timestamp
111
+ print(f"Due Date (timestamp): {due_timestamp}")
112
+ except ValueError:
113
+ print("Invalid deadline format. Skipping due_date.")
114
+
115
+ # Send request to ClickUp
116
+ create_url = f"{CLICKUP_URL_BASE}/list/{list_id}/task"
117
+ clickup_response = requests.post(create_url, headers=headers, json=payload)
118
+ clickup_data = clickup_response.json()
119
+ print(f"ClickUp Response: {clickup_response.status_code}, {clickup_data}")
120
+
121
  # WhatsApp notification part is commented out for now
122
  # We'll handle WhatsApp notification later
123