Pamudu13 commited on
Commit
9960112
Β·
verified Β·
1 Parent(s): 92cee8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -10
app.py CHANGED
@@ -160,7 +160,7 @@ Please provide:
160
  except Exception as e:
161
  raise Exception(f"Error improving task description: {str(e)}")
162
 
163
- def create_trello_card(task_description, selected_members):
164
  """Create a Trello card with the improved task description"""
165
  try:
166
  boards = trello_client.list_boards()
@@ -168,30 +168,70 @@ def create_trello_card(task_description, selected_members):
168
  raise Exception("No Trello boards found")
169
 
170
  board = boards[0]
171
- print(f"Using board: {board.name}") # Debug print
172
 
173
  lists = board.list_lists()
174
  if not lists:
175
  raise Exception("No lists found in the board")
176
 
177
  todo_list = lists[0]
178
- print(f"Using list: {todo_list.name}") # Debug print
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
 
180
- # Create card with improved description
181
  card = todo_list.add_card(
182
- name=task_description.split('\n')[0], # First line as title
183
- desc=task_description
184
  )
185
 
186
- # Debug prints
187
- print(f"Selected members: {selected_members}")
188
- print(f"Member types: {[type(m) for m in selected_members]}")
 
 
 
 
 
189
 
190
  # Assign members to card
191
  if selected_members:
192
  for member_id in selected_members:
193
  try:
194
- # Get the member object from the board before adding
195
  member = next((m for m in board.get_members() if m.id == member_id), None)
196
  if member:
197
  card.add_member(member)
 
160
  except Exception as e:
161
  raise Exception(f"Error improving task description: {str(e)}")
162
 
163
+ def create_trello_card(task_description, selected_members, location=None):
164
  """Create a Trello card with the improved task description"""
165
  try:
166
  boards = trello_client.list_boards()
 
168
  raise Exception("No Trello boards found")
169
 
170
  board = boards[0]
171
+ print(f"Using board: {board.name}")
172
 
173
  lists = board.list_lists()
174
  if not lists:
175
  raise Exception("No lists found in the board")
176
 
177
  todo_list = lists[0]
178
+ print(f"Using list: {todo_list.name}")
179
+
180
+ # Extract title and add timestamp
181
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M")
182
+ title = task_description.split('\n')[0]
183
+ formatted_title = f"[{timestamp}] {title}"
184
+
185
+ location_text = "Remote/Virtual"
186
+ location_coords = None
187
+
188
+ if location:
189
+ location_text = location
190
+ # If you want to add coordinates, you could use a geocoding service here
191
+ # Example: coordinates = geocode_location(location)
192
+ # location_coords = f"{coordinates['lat']},{coordinates['lng']}"
193
+
194
+ formatted_description = f"""🎯 TASK DETAILS
195
+ ------------------------
196
+ {task_description}
197
+
198
+ πŸ“‹ METADATA
199
+ ------------------------
200
+ πŸ•’ Created: {timestamp}
201
+ 🏷️ Source: TaskWhisper AI
202
+ πŸ”„ Status: New
203
+ πŸ“ Location: {location_text}
204
+
205
+ βœ… CHECKLIST
206
+ ------------------------
207
+ - [ ] Task reviewed
208
+ - [ ] Requirements clear
209
+ - [ ] Timeline confirmed
210
+ - [ ] Resources identified
211
+
212
+ πŸ“ NOTES
213
+ ------------------------
214
+ Add your progress notes here...
215
+ """
216
 
 
217
  card = todo_list.add_card(
218
+ name=formatted_title,
219
+ desc=formatted_description
220
  )
221
 
222
+ if location_coords:
223
+ card.set_pos(location_coords)
224
+
225
+ # Add a yellow label if available
226
+ available_labels = board.get_labels()
227
+ yellow_label = next((label for label in available_labels if label.color == 'yellow'), None)
228
+ if yellow_label:
229
+ card.add_label(yellow_label)
230
 
231
  # Assign members to card
232
  if selected_members:
233
  for member_id in selected_members:
234
  try:
 
235
  member = next((m for m in board.get_members() if m.id == member_id), None)
236
  if member:
237
  card.add_member(member)