1 Commits

Author SHA1 Message Date
dependabot[bot]
af11cbdc96 [UPDATE] Update mkdocstrings requirement
Updates the requirements on [mkdocstrings](https://github.com/mkdocstrings/mkdocstrings) to permit the latest version.
- [Release notes](https://github.com/mkdocstrings/mkdocstrings/releases)
- [Changelog](https://github.com/mkdocstrings/mkdocstrings/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mkdocstrings/mkdocstrings/compare/0.30.1...1.0.0)

---
updated-dependencies:
- dependency-name: mkdocstrings
  dependency-version: 1.0.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-08 08:04:18 +00:00
2 changed files with 16 additions and 28 deletions

View File

@@ -4,16 +4,15 @@ from dateutil.relativedelta import relativedelta
from django.conf import settings from django.conf import settings
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.contrib.syndication.views import add_domain from django.contrib.syndication.views import add_domain
from django.db.models import Count, OuterRef, QuerySet, Subquery from django.db.models import F, QuerySet
from django.http import HttpRequest from django.http import HttpRequest
from django.urls import reverse from django.urls import reverse
from django.utils import timezone from django.utils import timezone
from ical.calendar import Calendar from ical.calendar import Calendar
from ical.calendar_stream import IcsCalendarStream from ical.calendar_stream import IcsCalendarStream
from ical.event import Event from ical.event import Event
from ical.types import Frequency, Recur
from com.models import News, NewsDate from com.models import NewsDate
from core.models import User from core.models import User
@@ -43,9 +42,9 @@ class IcsCalendar:
with open(cls._INTERNAL_CALENDAR, "wb") as f: with open(cls._INTERNAL_CALENDAR, "wb") as f:
_ = f.write( _ = f.write(
cls.ics_from_queryset( cls.ics_from_queryset(
News.objects.filter( NewsDate.objects.filter(
is_published=True, news__is_published=True,
dates__end_date__gte=timezone.now() - relativedelta(months=6), end_date__gte=timezone.now() - (relativedelta(months=6)),
) )
) )
) )
@@ -54,35 +53,24 @@ class IcsCalendar:
@classmethod @classmethod
def get_unpublished(cls, user: User) -> bytes: def get_unpublished(cls, user: User) -> bytes:
return cls.ics_from_queryset( return cls.ics_from_queryset(
News.objects.viewable_by(user).filter( NewsDate.objects.viewable_by(user).filter(
is_published=False, news__is_published=False,
dates__end_date__gte=timezone.now() - relativedelta(months=6), end_date__gte=timezone.now() - (relativedelta(months=6)),
) ),
) )
@classmethod @classmethod
def ics_from_queryset(cls, queryset: QuerySet[News]) -> bytes: def ics_from_queryset(cls, queryset: QuerySet[NewsDate]) -> bytes:
calendar = Calendar() calendar = Calendar()
date_subquery = NewsDate.objects.filter(news=OuterRef("pk")).order_by( for news_date in queryset.annotate(news_title=F("news__title")):
"start_date"
)
queryset = queryset.annotate(
start=Subquery(date_subquery.values("start_date")[:1]),
end=Subquery(date_subquery.values("end_date")[:1]),
nb_dates=Count("dates"),
)
for news in queryset:
event = Event( event = Event(
summary=news.title, summary=news_date.news_title,
description=news.summary, start=news_date.start_date,
dtstart=news.start, end=news_date.end_date,
dtend=news.end,
url=as_absolute_url( url=as_absolute_url(
reverse("com:news_detail", kwargs={"news_id": news.id}) reverse("com:news_detail", kwargs={"news_id": news_date.news_id})
), ),
) )
if news.nb_dates > 1:
event.rrule = Recur(freq=Frequency.WEEKLY, count=news.nb_dates)
calendar.events.append(event) calendar.events.append(event)
return IcsCalendarStream.calendar_to_ics(calendar).encode("utf-8") return IcsCalendarStream.calendar_to_ics(calendar).encode("utf-8")

View File

@@ -83,7 +83,7 @@ tests = [
docs = [ docs = [
"mkdocs<2.0.0,>=1.6.1", "mkdocs<2.0.0,>=1.6.1",
"mkdocs-material>=9.6.23,<10.0.0", "mkdocs-material>=9.6.23,<10.0.0",
"mkdocstrings>=0.30.1,<1.0.0", "mkdocstrings>=0.30.1,<2.0.0",
"mkdocstrings-python>=1.18.2,<2.0.0", "mkdocstrings-python>=1.18.2,<2.0.0",
"mkdocs-include-markdown-plugin>=7.2.0,<8.0.0", "mkdocs-include-markdown-plugin>=7.2.0,<8.0.0",
] ]