Bläddra i källkod

Fix pytz import issue (#679)

I didn't do a complete thorough test of Wagtail 6.4 compatibility, but
confirmed this particular issue is solved and most general functionality
works on Wagtail 6.4.
Vince Salvino 1 månad sedan
förälder
incheckning
02813849ae
4 ändrade filer med 16 tillägg och 12 borttagningar
  1. 6 4
      azure-pipelines.yml
  2. 7 7
      coderedcms/models/page_models.py
  3. 2 0
      coderedcms/views.py
  4. 1 1
      pyproject.toml

+ 6 - 4
azure-pipelines.yml

@@ -27,6 +27,8 @@ stages:
       vmImage: 'ubuntu-latest'
     strategy:
       matrix:
+        # Oldest versions of python should use the oldest versions of
+        # wagtail we support, for testing purposes.
         py3.9:
           PYTHON_VERSION: '3.9'
           WAGTAIL_VERSION: '6.3.*'
@@ -37,19 +39,19 @@ stages:
           TEMPLATE: 'basic'
         py3.11:
           PYTHON_VERSION: '3.11'
-          WAGTAIL_VERSION: '6.3.*'
+          WAGTAIL_VERSION: '6.4.*'
           TEMPLATE: 'basic'
         py3.12:
           PYTHON_VERSION: '3.12'
-          WAGTAIL_VERSION: '6.3.*'
+          WAGTAIL_VERSION: '6.*'
           TEMPLATE: 'basic'
         py3.13_basic:
           PYTHON_VERSION: '3.13'
-          WAGTAIL_VERSION: '6.3.*'
+          WAGTAIL_VERSION: '6.*'
           TEMPLATE: 'basic'
         py3.13_pro:
           PYTHON_VERSION: '3.13'
-          WAGTAIL_VERSION: '6.3.*'
+          WAGTAIL_VERSION: '6.*'
           TEMPLATE: 'pro'
 
     steps:

+ 7 - 7
coderedcms/models/page_models.py

@@ -8,6 +8,7 @@ import os
 import warnings
 from datetime import date
 from datetime import datetime
+from datetime import timezone as dttimezone
 from pathlib import Path
 from typing import TYPE_CHECKING
 from typing import Dict
@@ -17,9 +18,6 @@ from typing import Tuple
 from typing import Union
 
 import geocoder
-
-# This is a requirement for icalendar, even if django doesn't require it
-import pytz
 from django import forms
 from django.conf import settings
 from django.contrib import messages
@@ -1027,13 +1025,15 @@ class CoderedEventPage(CoderedWebPage, BaseEvent):
             ical_event.add("location", self.address)
 
         if dt_start:
-            # Convert to utc to remove timezone confusion
-            dt_start = dt_start.astimezone(pytz.utc)
+            # Convert to UTC to remove timezone confusion in ical
+            # clients (i.e. Outlook).
+            dt_start = dt_start.astimezone(dttimezone.utc)
             ical_event.add("dtstart", dt_start)
 
             if dt_end:
-                # Convert to utc to remove timezone confusion
-                dt_end = dt_end.astimezone(pytz.utc)
+                # Convert to UTC to remove timezone confusion in ical
+                # clients (i.e. Outlook).
+                dt_end = dt_end.astimezone(dttimezone.utc)
                 ical_event.add("dtend", dt_end)
 
             # Add a reminder alarm

+ 2 - 0
coderedcms/views.py

@@ -186,7 +186,9 @@ def event_generate_single_ical_for_event(request):
 
     # Generate the ical file.
     ical = Calendar()
+    # Our product name that is generating this file.
     ical.add("prodid", "-//Wagtail CRX//")
+    # Version of the ical standard.
     ical.add("version", "2.0")
     ical.add_component(
         event.create_single_ical(dt_start=dt_start, dt_end=dt_end)

+ 1 - 1
pyproject.toml

@@ -37,7 +37,7 @@ dependencies = [
     "django-bootstrap5==24.3",
     "Django>=4.2,<6.0",  # should be the same as wagtail
     "geocoder==1.38.*",
-    "icalendar==6.0.*",
+    "icalendar==6.1.*",
     "wagtail>=6.3,<7.0",
     "wagtail-cache>=2.4,<3",
     "wagtail-flexible-forms==2.*",