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})"