💄show duration in event list display
This commit is contained in:
parent
14dd63ad72
commit
e3e9ac3c58
|
|
@ -151,7 +151,8 @@ class Calendar(models.Model):
|
||||||
|
|
||||||
@app.admin(ordering=("start", "end", "calendar", "name"),
|
@app.admin(ordering=("start", "end", "calendar", "name"),
|
||||||
list_filter=("cancelled",),
|
list_filter=("cancelled",),
|
||||||
list_display=("name", "calendar", "created", "start", "end"))
|
list_display=("name", "calendar", "created", "duration", "start",
|
||||||
|
"end"))
|
||||||
class Event(models.Model):
|
class Event(models.Model):
|
||||||
"""
|
"""
|
||||||
Event model to store events in a calendar and send them to a CalDAV server.
|
Event model to store events in a calendar and send them to a CalDAV server.
|
||||||
|
|
@ -242,6 +243,14 @@ class Event(models.Model):
|
||||||
def uuid(self) -> UUID:
|
def uuid(self) -> UUID:
|
||||||
return shortuuid.decode(self.id.__str__())
|
return shortuuid.decode(self.id.__str__())
|
||||||
|
|
||||||
|
def duration(self) -> str:
|
||||||
|
"""
|
||||||
|
Calculate the duration of the event.
|
||||||
|
:return: The duration in minutes.
|
||||||
|
"""
|
||||||
|
duration = (self.end - self.start).total_seconds() // 60
|
||||||
|
return f"{duration:.0f}m"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue