mirror of
https://github.com/ae-utbm/sith.git
synced 2025-01-08 16:11:17 +00:00
Use a newer ical library
This commit is contained in:
parent
1887a2790f
commit
ba76015c71
@ -3,10 +3,13 @@ from pathlib import Path
|
|||||||
from typing import final
|
from typing import final
|
||||||
|
|
||||||
import urllib3
|
import urllib3
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from ics import Calendar, Event
|
from ical.calendar import Calendar
|
||||||
|
from ical.calendar_stream import IcsCalendarStream
|
||||||
|
from ical.event import Event
|
||||||
|
|
||||||
from com.models import NewsDate
|
from com.models import NewsDate
|
||||||
|
|
||||||
@ -56,19 +59,18 @@ class IcsCalendar:
|
|||||||
calendar = Calendar()
|
calendar = Calendar()
|
||||||
for news_date in NewsDate.objects.filter(
|
for news_date in NewsDate.objects.filter(
|
||||||
news__is_moderated=True,
|
news__is_moderated=True,
|
||||||
end_date__gte=timezone.now()
|
end_date__gte=timezone.now() - (relativedelta(months=6)),
|
||||||
- (timedelta(days=30) * 60), # Roughly get the last 6 months
|
|
||||||
).prefetch_related("news"):
|
).prefetch_related("news"):
|
||||||
event = Event(
|
event = Event(
|
||||||
name=news_date.news.title,
|
summary=news_date.news.title,
|
||||||
begin=news_date.start_date,
|
start=news_date.start_date,
|
||||||
end=news_date.end_date,
|
end=news_date.end_date,
|
||||||
url=reverse("com:news_detail", kwargs={"news_id": news_date.news.id}),
|
url=reverse("com:news_detail", kwargs={"news_id": news_date.news.id}),
|
||||||
)
|
)
|
||||||
calendar.events.add(event)
|
calendar.events.append(event)
|
||||||
|
|
||||||
# Create a file so we can offload the download to the reverse proxy if available
|
# Create a file so we can offload the download to the reverse proxy if available
|
||||||
cls._CACHE_FOLDER.mkdir(parents=True, exist_ok=True)
|
cls._CACHE_FOLDER.mkdir(parents=True, exist_ok=True)
|
||||||
with open(cls._INTERNAL_CALENDAR, "wb") as f:
|
with open(cls._INTERNAL_CALENDAR, "wb") as f:
|
||||||
_ = f.write(calendar.serialize().encode("utf-8"))
|
_ = f.write(IcsCalendarStream.calendar_to_ics(calendar).encode("utf-8"))
|
||||||
return cls._INTERNAL_CALENDAR
|
return cls._INTERNAL_CALENDAR
|
||||||
|
101
poetry.lock
generated
101
poetry.lock
generated
@ -22,25 +22,6 @@ files = [
|
|||||||
{file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"},
|
{file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "arrow"
|
|
||||||
version = "1.3.0"
|
|
||||||
description = "Better dates & times for Python"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=3.8"
|
|
||||||
files = [
|
|
||||||
{file = "arrow-1.3.0-py3-none-any.whl", hash = "sha256:c728b120ebc00eb84e01882a6f5e7927a53960aa990ce7dd2b10f39005a67f80"},
|
|
||||||
{file = "arrow-1.3.0.tar.gz", hash = "sha256:d4540617648cb5f895730f1ad8c82a65f2dad0166f57b75f3ca54759c4d67a85"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[package.dependencies]
|
|
||||||
python-dateutil = ">=2.7.0"
|
|
||||||
types-python-dateutil = ">=2.8.10"
|
|
||||||
|
|
||||||
[package.extras]
|
|
||||||
doc = ["doc8", "sphinx (>=7.0.0)", "sphinx-autobuild", "sphinx-autodoc-typehints", "sphinx_rtd_theme (>=1.3.0)"]
|
|
||||||
test = ["dateparser (==1.*)", "pre-commit", "pytest", "pytest-cov", "pytest-mock", "pytz (==2021.1)", "simplejson (==3.*)"]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asgiref"
|
name = "asgiref"
|
||||||
version = "3.8.1"
|
version = "3.8.1"
|
||||||
@ -70,25 +51,6 @@ files = [
|
|||||||
astroid = ["astroid (>=2,<4)"]
|
astroid = ["astroid (>=2,<4)"]
|
||||||
test = ["astroid (>=2,<4)", "pytest", "pytest-cov", "pytest-xdist"]
|
test = ["astroid (>=2,<4)", "pytest", "pytest-cov", "pytest-xdist"]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "attrs"
|
|
||||||
version = "24.3.0"
|
|
||||||
description = "Classes Without Boilerplate"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=3.8"
|
|
||||||
files = [
|
|
||||||
{file = "attrs-24.3.0-py3-none-any.whl", hash = "sha256:ac96cd038792094f438ad1f6ff80837353805ac950cd2aa0e0625ef19850c308"},
|
|
||||||
{file = "attrs-24.3.0.tar.gz", hash = "sha256:8f5c07333d543103541ba7be0e2ce16eeee8130cb0b3f9238ab904ce1e85baff"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[package.extras]
|
|
||||||
benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
|
|
||||||
cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
|
|
||||||
dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
|
|
||||||
docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier (<24.7)"]
|
|
||||||
tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
|
|
||||||
tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "babel"
|
name = "babel"
|
||||||
version = "2.16.0"
|
version = "2.16.0"
|
||||||
@ -970,22 +932,21 @@ files = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ics"
|
name = "ical"
|
||||||
version = "0.7.2"
|
version = "8.3.0"
|
||||||
description = "Python icalendar (rfc5545) parser"
|
description = "Python iCalendar implementation (rfc 2445)"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = "*"
|
python-versions = ">=3.10"
|
||||||
files = [
|
files = [
|
||||||
{file = "ics-0.7.2-py2.py3-none-any.whl", hash = "sha256:5fcf4d29ec6e7dfcb84120abd617bbba632eb77b097722b7df70e48dbcf26103"},
|
{file = "ical-8.3.0-py3-none-any.whl", hash = "sha256:606f2f561bd8b75cb726710dddbb20f3f84dfa1d6323550947dba97359423850"},
|
||||||
{file = "ics-0.7.2.tar.gz", hash = "sha256:6743539bca10391635249b87d74fcd1094af20b82098bebf7c7521df91209f05"},
|
{file = "ical-8.3.0.tar.gz", hash = "sha256:e277cc518cbb0132e6827c318c8ec3b379b125ebf0a2a44337f08795d5530937"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
arrow = ">=0.11"
|
pydantic = ">=1.9.1"
|
||||||
attrs = ">=19.1.0"
|
pyparsing = ">=3.0.9"
|
||||||
python-dateutil = "*"
|
python-dateutil = ">=2.8.2"
|
||||||
six = ">1.5"
|
tzdata = ">=2023.3"
|
||||||
tatsu = ">4.2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "identify"
|
name = "identify"
|
||||||
@ -1939,6 +1900,20 @@ pyyaml = "*"
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
extra = ["pygments (>=2.12)"]
|
extra = ["pygments (>=2.12)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pyparsing"
|
||||||
|
version = "3.2.1"
|
||||||
|
description = "pyparsing module - Classes and methods to define and execute parsing grammars"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.9"
|
||||||
|
files = [
|
||||||
|
{file = "pyparsing-3.2.1-py3-none-any.whl", hash = "sha256:506ff4f4386c4cec0590ec19e6302d3aedb992fdc02c761e90416f158dacf8e1"},
|
||||||
|
{file = "pyparsing-3.2.1.tar.gz", hash = "sha256:61980854fd66de3a90028d679a954d5f2623e83144b5afe5ee86f43d762e5f0a"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
diagrams = ["jinja2", "railroad-diagrams"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest"
|
name = "pytest"
|
||||||
version = "8.3.4"
|
version = "8.3.4"
|
||||||
@ -2580,21 +2555,6 @@ pure-eval = "*"
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
tests = ["cython", "littleutils", "pygments", "pytest", "typeguard"]
|
tests = ["cython", "littleutils", "pygments", "pytest", "typeguard"]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tatsu"
|
|
||||||
version = "5.12.2"
|
|
||||||
description = "TatSu takes a grammar in a variation of EBNF as input, and outputs a memoizing PEG/Packrat parser in Python."
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=3.11"
|
|
||||||
files = [
|
|
||||||
{file = "TatSu-5.12.2-py3-none-any.whl", hash = "sha256:9c313186ae5262662cb3fbec52c9a12db1ef752e615f46cac3eb568cb91eacf9"},
|
|
||||||
{file = "tatsu-5.12.2.tar.gz", hash = "sha256:5894dc7ddba9a1886a95ff2f06cef1be2b3d3a37c776eba8177ef4dcd80ccb03"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[package.extras]
|
|
||||||
colorization = ["colorama"]
|
|
||||||
parproc = ["rich"]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tomli"
|
name = "tomli"
|
||||||
version = "2.2.1"
|
version = "2.2.1"
|
||||||
@ -2651,17 +2611,6 @@ files = [
|
|||||||
docs = ["myst-parser", "pydata-sphinx-theme", "sphinx"]
|
docs = ["myst-parser", "pydata-sphinx-theme", "sphinx"]
|
||||||
test = ["argcomplete (>=3.0.3)", "mypy (>=1.7.0)", "pre-commit", "pytest (>=7.0,<8.2)", "pytest-mock", "pytest-mypy-testing"]
|
test = ["argcomplete (>=3.0.3)", "mypy (>=1.7.0)", "pre-commit", "pytest (>=7.0,<8.2)", "pytest-mock", "pytest-mypy-testing"]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "types-python-dateutil"
|
|
||||||
version = "2.9.0.20241206"
|
|
||||||
description = "Typing stubs for python-dateutil"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=3.8"
|
|
||||||
files = [
|
|
||||||
{file = "types_python_dateutil-2.9.0.20241206-py3-none-any.whl", hash = "sha256:e248a4bc70a486d3e3ec84d0dc30eec3a5f979d6e7ee4123ae043eedbb987f53"},
|
|
||||||
{file = "types_python_dateutil-2.9.0.20241206.tar.gz", hash = "sha256:18f493414c26ffba692a72369fea7a154c502646301ebfe3d56a04b3767284cb"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typing-extensions"
|
name = "typing-extensions"
|
||||||
version = "4.12.2"
|
version = "4.12.2"
|
||||||
@ -2806,4 +2755,4 @@ filelock = ">=3.4"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.12"
|
python-versions = "^3.12"
|
||||||
content-hash = "f0acbbe66fd99ac04891bcc8a5f28167a927e0b1f3677ebd8ab302a0e2fb9be2"
|
content-hash = "7f348f74a05c27e29aaaf25a5584bba9b416f42c3f370db234dd69e5e10dc8df"
|
||||||
|
@ -45,7 +45,7 @@ Sphinx = "^5" # Needed for building xapian
|
|||||||
tomli = "^2.2.1"
|
tomli = "^2.2.1"
|
||||||
django-honeypot = "^1.2.1"
|
django-honeypot = "^1.2.1"
|
||||||
pydantic-extra-types = "^2.10.1"
|
pydantic-extra-types = "^2.10.1"
|
||||||
ics = "^0.7.2"
|
ical = "^8.3.0"
|
||||||
|
|
||||||
[tool.poetry.group.prod.dependencies]
|
[tool.poetry.group.prod.dependencies]
|
||||||
# deps used in prod, but unnecessary for development
|
# deps used in prod, but unnecessary for development
|
||||||
|
Loading…
Reference in New Issue
Block a user