Compare commits
2 Commits
34f520aa81
...
796f0d6ad1
Author | SHA1 | Date | |
---|---|---|---|
796f0d6ad1 | |||
40ac6ef97f |
@ -415,13 +415,7 @@ class EventInstructor(models.Model):
|
||||
|
||||
class EventExtManager(models.Manager["EventExt"]):
|
||||
def get_queryset(self) -> models.QuerySet["EventExt"]:
|
||||
return (
|
||||
super()
|
||||
.get_queryset()
|
||||
.annotate(duration=Sum(F("meeting_times__end") - F("meeting_times__start")))
|
||||
)
|
||||
# TODO: use simpler expression when GeneratedField fixed
|
||||
# return super().get_queryset().annotate(duration=Sum("meeting_times__duration"))
|
||||
return super().get_queryset().annotate(duration=Sum("meeting_times__duration"))
|
||||
|
||||
|
||||
class EventExt(Event):
|
||||
@ -446,29 +440,18 @@ class EventExt(Event):
|
||||
verbose_name = "event"
|
||||
|
||||
|
||||
class EventMeetingTimeManager(models.Manager["EventMeetingTime"]):
|
||||
def get_queryset(self) -> models.QuerySet["EventMeetingTime"]:
|
||||
return super().get_queryset().annotate(duration=F("end") - F("start"))
|
||||
|
||||
|
||||
class EventMeetingTime(models.Model):
|
||||
objects = EventMeetingTimeManager()
|
||||
|
||||
event = models.ForeignKey(
|
||||
EventExt, on_delete=models.CASCADE, related_name="meeting_times"
|
||||
)
|
||||
start = models.DateTimeField()
|
||||
end = models.DateTimeField()
|
||||
|
||||
# TODO: Should use generated field instead of manager, but this is
|
||||
# broken due to current Django bug, pending next release (> 5.0)
|
||||
# ref: https://code.djangoproject.com/ticket/35019
|
||||
|
||||
# duration = models.GeneratedField(
|
||||
# expression=F("end") - F("start"),
|
||||
# output_field=models.DurationField(),
|
||||
# db_persist=False,
|
||||
# )
|
||||
duration = models.GeneratedField(
|
||||
expression=F("end") - F("start"),
|
||||
output_field=models.DurationField(),
|
||||
db_persist=False,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
|
18
pdm.lock
18
pdm.lock
@ -4,7 +4,7 @@
|
||||
[metadata]
|
||||
groups = ["default", "debug", "lint", "server", "typing", "dev"]
|
||||
strategy = ["cross_platform"]
|
||||
lock_version = "4.4"
|
||||
lock_version = "4.4.1"
|
||||
content_hash = "sha256:91f554bae127245b4082d069629400706b8b43daf3bf1fb8fd963eee120ff449"
|
||||
|
||||
[[package]]
|
||||
@ -395,17 +395,17 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "django"
|
||||
version = "5.0"
|
||||
version = "5.0.1"
|
||||
requires_python = ">=3.10"
|
||||
summary = "A high-level Python web framework that encourages rapid development and clean, pragmatic design."
|
||||
dependencies = [
|
||||
"asgiref>=3.7.0",
|
||||
"asgiref<4,>=3.7.0",
|
||||
"sqlparse>=0.3.1",
|
||||
"tzdata; sys_platform == \"win32\"",
|
||||
]
|
||||
files = [
|
||||
{file = "Django-5.0-py3-none-any.whl", hash = "sha256:3a9fd52b8dbeae335ddf4a9dfa6c6a0853a1122f1fb071a8d5eca979f73a05c8"},
|
||||
{file = "Django-5.0.tar.gz", hash = "sha256:7d29e14dfbc19cb6a95a4bd669edbde11f5d4c6a71fdaa42c2d40b6846e807f7"},
|
||||
{file = "Django-5.0.1-py3-none-any.whl", hash = "sha256:f47a37a90b9bbe2c8ec360235192c7fddfdc832206fcf618bb849b39256affc1"},
|
||||
{file = "Django-5.0.1.tar.gz", hash = "sha256:8c8659665bc6e3a44fefe1ab0a291e5a3fb3979f9a8230be29de975e57e8f854"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1694,15 +1694,15 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "types-requests"
|
||||
version = "2.31.0.10"
|
||||
version = "2.31.0.20231231"
|
||||
requires_python = ">=3.7"
|
||||
summary = "Typing stubs for requests"
|
||||
dependencies = [
|
||||
"urllib3>=2",
|
||||
]
|
||||
files = [
|
||||
{file = "types-requests-2.31.0.10.tar.gz", hash = "sha256:dc5852a76f1eaf60eafa81a2e50aefa3d1f015c34cf0cba130930866b1b22a92"},
|
||||
{file = "types_requests-2.31.0.10-py3-none-any.whl", hash = "sha256:b32b9a86beffa876c0c3ac99a4cd3b8b51e973fb8e3bd4e0a6bb32c7efad80fc"},
|
||||
{file = "types-requests-2.31.0.20231231.tar.gz", hash = "sha256:0f8c0c9764773384122813548d9eea92a5c4e1f33ed54556b508968ec5065cee"},
|
||||
{file = "types_requests-2.31.0.20231231-py3-none-any.whl", hash = "sha256:2e2230c7bc8dd63fa3153c1c0ae335f8a368447f0582fc332f17d54f88e69027"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1787,7 +1787,7 @@ dependencies = [
|
||||
"python-dotenv>=0.13",
|
||||
"pyyaml>=5.1",
|
||||
"uvicorn==0.25.0",
|
||||
"uvloop!=0.15.0,!=0.15.1,>=0.14.0; sys_platform != \"win32\" and (sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\")",
|
||||
"uvloop!=0.15.0,!=0.15.1,>=0.14.0; (sys_platform != \"cygwin\" and sys_platform != \"win32\") and platform_python_implementation != \"PyPy\"",
|
||||
"watchfiles>=0.13",
|
||||
"websockets>=10.4",
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user