From 7fdabbfc0f94d5da66e79f19f35ea8c8fc8195d9 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 31 Dec 2021 14:42:45 -0600 Subject: [PATCH] add a csv format string matches the title used in TeamSnap csv export. --- teamsnap/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/teamsnap/models.py b/teamsnap/models.py index e00027d..9cdeed2 100644 --- a/teamsnap/models.py +++ b/teamsnap/models.py @@ -2,6 +2,7 @@ from django.db import models import benchcoach.models import teamsnap.teamsnap.api +from django.utils.timezone import localtime class TeamsnapBaseModel(models.Model): type = None @@ -132,6 +133,16 @@ class Event(TeamsnapManagedObjectModel): game_type = models.CharField(max_length = 50, null=True) ApiObject = teamsnap.teamsnap.api.Event + @property + def csv_event_title(self)->str: + ''' + TeamSnap has a title format that it uses for the csv export which includes the date and time + :return: formatted string + ''' + # activate(zone) + start_date = localtime(self.start_date) + return f"{self.formatted_title} {start_date:%m/%d/%Y}" + f"{start_date:%-I:%M %p}".rjust(9) + def __str__(self): return f"{self.formatted_title} ({self.id})"