add a csv format string
matches the title used in TeamSnap csv export.
This commit is contained in:
@@ -2,6 +2,7 @@ from django.db import models
|
|||||||
|
|
||||||
import benchcoach.models
|
import benchcoach.models
|
||||||
import teamsnap.teamsnap.api
|
import teamsnap.teamsnap.api
|
||||||
|
from django.utils.timezone import localtime
|
||||||
|
|
||||||
class TeamsnapBaseModel(models.Model):
|
class TeamsnapBaseModel(models.Model):
|
||||||
type = None
|
type = None
|
||||||
@@ -132,6 +133,16 @@ class Event(TeamsnapManagedObjectModel):
|
|||||||
game_type = models.CharField(max_length = 50, null=True)
|
game_type = models.CharField(max_length = 50, null=True)
|
||||||
ApiObject = teamsnap.teamsnap.api.Event
|
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):
|
def __str__(self):
|
||||||
return f"{self.formatted_title} ({self.id})"
|
return f"{self.formatted_title} ({self.id})"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user