mirror of
https://github.com/Ladebeze66/projetcbaollm.git
synced 2025-12-16 14:37:49 +01:00
67 lines
2.9 KiB
Python
67 lines
2.9 KiB
Python
class TicketDisplay:
|
|
def display_field(self, ticket, field_path):
|
|
"""Affiche un champ spécifique du ticket"""
|
|
if not ticket:
|
|
print("Aucun ticket à afficher.")
|
|
return
|
|
|
|
parts = field_path.split('.')
|
|
if len(parts) == 1:
|
|
if parts[0] in ticket:
|
|
print(f"{parts[0]}: {ticket[parts[0]]}")
|
|
else:
|
|
print(f"Champ {parts[0]} introuvable.")
|
|
elif len(parts) == 2:
|
|
section, field = parts
|
|
if section in ticket and field in ticket[section]:
|
|
print(f"{section}.{field}: {ticket[section][field]}")
|
|
else:
|
|
print(f"Champ {field} introuvable dans {section}.")
|
|
|
|
def display_ticket(self, ticket):
|
|
"""Affiche tous les détails d'un ticket"""
|
|
if not ticket:
|
|
print("Aucun ticket à afficher.")
|
|
return
|
|
|
|
print("\n======== DÉTAILS DU TICKET ========")
|
|
if 'id' in ticket:
|
|
print(f"ID: {ticket['id']}")
|
|
if 'name' in ticket:
|
|
print(f"Nom: {ticket['name']}")
|
|
|
|
# Afficher les champs simples
|
|
print("\n-- CHAMPS SIMPLES --")
|
|
if 'Champs Simples' in ticket:
|
|
for field, value in ticket['Champs Simples'].items():
|
|
print(f"{field}: {value}")
|
|
else:
|
|
# Format standard si les données ne sont pas structurées
|
|
simple_fields = ['description', 'priority', 'sequence', 'date_deadline', 'create_date', 'write_date']
|
|
for field in simple_fields:
|
|
if field in ticket:
|
|
print(f"{field}: {ticket[field]}")
|
|
|
|
# Afficher les champs relationnels
|
|
print("\n-- CHAMPS RELATIONNELS --")
|
|
if 'Champs Relationnels' in ticket:
|
|
for field, value in ticket['Champs Relationnels'].items():
|
|
print(f"{field}: {value}")
|
|
else:
|
|
# Format standard
|
|
if 'stage_id' in ticket and ticket['stage_id']:
|
|
print(f"stage_id: {ticket['stage_id'][1]} (ID: {ticket['stage_id'][0]})")
|
|
if 'project_id' in ticket and ticket['project_id']:
|
|
print(f"project_id: {ticket['project_id'][1]} (ID: {ticket['project_id'][0]})")
|
|
|
|
# Afficher les discussions si présentes
|
|
if 'Discussions' in ticket and ticket['Discussions']:
|
|
print("\n-- DISCUSSIONS --")
|
|
for i, msg in enumerate(ticket['Discussions'], 1):
|
|
print(f"Message {i}:")
|
|
print(f" Auteur: {msg.get('Auteur', 'Inconnu')}")
|
|
print(f" Date: {msg.get('Date', 'Inconnue')}")
|
|
print(f" Sujet: {msg.get('Sujet', 'Sans sujet')}")
|
|
print(f" Contenu: {msg.get('Contenu', 'Pas de contenu')[:100]}..."
|
|
if len(msg.get('Contenu', '')) > 100 else f" Contenu: {msg.get('Contenu', 'Pas de contenu')}")
|
|
print() |