1
0

setup_sprint12_taiga.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import requests
  2. import urllib3
  3. from datetime import datetime, timedelta
  4. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  5. base_url = 'https://192.168.130.161/taiga/api/v1'
  6. auth = requests.post(f'{base_url}/auth', json={'type': 'normal', 'username': 'FrancoisLange', 'password': 'BTSai123'}, verify=False).json()
  7. headers = {'Authorization': f'Bearer {auth["auth_token"]}', 'Content-Type': 'application/json'}
  8. proj_id = 21
  9. print("Fetching Sprints...")
  10. milestones = requests.get(f'{base_url}/milestones?project={proj_id}', headers=headers, verify=False).json()
  11. sprint12 = next((m for m in milestones if m['name'] == 'Sprint 12'), None)
  12. if not sprint12:
  13. print("Sprint 12 not found, creating it...")
  14. payload = {
  15. "project": proj_id,
  16. "name": "Sprint 12",
  17. "estimated_start": datetime.now().strftime('%Y-%m-%d'),
  18. "estimated_finish": (datetime.now() + timedelta(days=7)).strftime('%Y-%m-%d')
  19. }
  20. sprint12 = requests.post(f'{base_url}/milestones', json=payload, headers=headers, verify=False).json()
  21. sprint_id = sprint12['id']
  22. print(f"Sprint 12 ID: {sprint_id}")
  23. stories = [
  24. {"subject": "AI Meal Plan PDF Generation", "description": "Implement FPDF2 script to intercept the Ollama Markdown output, parse the tables, and provide a downloadable PDF artifact for dietitians to hand out."},
  25. {"subject": "Health Profile Input Constraints", "description": "Refactor the EAV profile tab to use specific drop-down menus instead of text-inputs to strictly enforce the clinical backend flags (Kosher, Halal, Diabetes)."}
  26. ]
  27. for s in stories:
  28. payload = {
  29. "project": proj_id,
  30. "subject": s["subject"],
  31. "description": s["description"],
  32. "milestone": sprint_id
  33. }
  34. res = requests.post(f'{base_url}/userstories', json=payload, headers=headers, verify=False)
  35. if res.status_code == 201:
  36. us = res.json()
  37. print(f"Created US: {us['subject']}")
  38. # Create a task for it
  39. t_payload = {
  40. "project": proj_id,
  41. "subject": f"Execute: {us['subject']}",
  42. "user_story": us['id'],
  43. "milestone": sprint_id
  44. }
  45. requests.post(f'{base_url}/tasks', json=t_payload, headers=headers, verify=False)
  46. print("Sprint 12 populated!")