Make the "Finish now?" button on session list work
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
from django.db import models
|
||||
from datetime import timedelta
|
||||
from datetime import datetime
|
||||
from django.conf import settings
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
|
||||
class Game(models.Model):
|
||||
@ -40,6 +42,9 @@ class Session(models.Model):
|
||||
mark = ", manual" if self.duration_manual != None else ""
|
||||
return f"{str(self.purchase)} {str(self.timestamp_start.date())} ({self.duration_any()}{mark})"
|
||||
|
||||
def finish_now(self):
|
||||
self.timestamp_end = datetime.now(ZoneInfo(settings.TIME_ZONE))
|
||||
|
||||
def duration_seconds(self):
|
||||
if self.timestamp_end == None or self.timestamp_start == None:
|
||||
if self.duration_manual == None:
|
||||
|
Reference in New Issue
Block a user