From 5149a459977ca34a19d45af052efb9f811851b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Wed, 27 Mar 2024 11:03:34 +0100 Subject: [PATCH] fix: compatibility with python<3.10 --- web/b3desk/models/meetings.py | 3 ++- web/b3desk/models/roles.py | 4 ++-- web/b3desk/utils.py | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/web/b3desk/models/meetings.py b/web/b3desk/models/meetings.py index 0e8946cc..46b13a89 100644 --- a/web/b3desk/models/meetings.py +++ b/web/b3desk/models/meetings.py @@ -11,6 +11,7 @@ import hashlib from datetime import datetime from datetime import timedelta +from typing import Optional from flask import current_app from flask import url_for @@ -250,7 +251,7 @@ def get_mail_signin_url(self): _external=True, ) - def get_role(self, hashed_role, user_id=None) -> Role | None: + def get_role(self, hashed_role, user_id=None) -> Optional[Role]: if user_id and self.user.id == user_id: return Role.moderator elif self.get_hash(Role.attendee) == hashed_role: diff --git a/web/b3desk/models/roles.py b/web/b3desk/models/roles.py index b2af0b2d..20ac977f 100644 --- a/web/b3desk/models/roles.py +++ b/web/b3desk/models/roles.py @@ -1,7 +1,7 @@ -from enum import StrEnum +from enum import Enum -class Role(StrEnum): +class Role(Enum): attendee = "attendee" moderator = "moderator" authenticated = "authenticated" diff --git a/web/b3desk/utils.py b/web/b3desk/utils.py index cd7b58bc..7b51e180 100644 --- a/web/b3desk/utils.py +++ b/web/b3desk/utils.py @@ -116,12 +116,12 @@ def __init__(self, *args, required=True, **kwargs): super().__init__(self, *args, **kwargs) def to_url(self, instance): - return slugify(instance) + return slugify(instance.value) def to_python(self, identifier): - for value in enum: - if identifier == slugify(value): - return value + for item in enum: + if identifier == slugify(item.value): + return item abort(404) return EnumConverter