Skip to content

Commit

Permalink
fix: compatibility with python<3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Mar 27, 2024
1 parent e965577 commit 5149a45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion web/b3desk/models/meetings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions web/b3desk/models/roles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import StrEnum
from enum import Enum


class Role(StrEnum):
class Role(Enum):
attendee = "attendee"
moderator = "moderator"
authenticated = "authenticated"
8 changes: 4 additions & 4 deletions web/b3desk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5149a45

Please sign in to comment.