WIP: Event availability, User availability, notification eq str

This commit is contained in:
Gergely Polonkai 2018-07-08 18:52:35 +02:00
parent 69a1efcd93
commit 45eb411eb2

View File

@ -70,6 +70,18 @@ class NotificationAction(Enum):
#: A user has been invited to an event #: A user has been invited to an event
invite = 2 invite = 2
def __hash__(self):
return Enum.__hash__(self)
def __eq__(self, other):
if isinstance(other, str):
return self.name.lower() == other.lower() # pylint: disable=no-member
if isinstance(other, (int, float)):
return self.value == other
return Enum.__eq__(self, other)
NOTIFICATION_ACTION_MESSAGES = { NOTIFICATION_ACTION_MESSAGES = {
NotificationAction.follow: (_('%(actor)s followed you'), _('%(actor)s followed %(item)s')), NotificationAction.follow: (_('%(actor)s followed you'), _('%(actor)s followed %(item)s')),
@ -156,6 +168,47 @@ RESPONSE_VISIBILITY_TRANSLATIONS = {
} }
class EventAvailability(Enum):
"""Enumeration of event availabilities
"""
free = 0
busy = 1
def __hash__(self):
return Enum.__hash__(self)
def __eq__(self, other):
if isinstance(other, str):
return self.name.lower() == other.lower() # pylint: disable=no-member
if isinstance(other, (int, float)):
return self.value == other
return Enum.__eq__(self, other)
class UserAvailability(Enum):
"""Enumeration of user availabilities
"""
free = 0
busy = 1
tentative = 2
def __hash__(self):
return Enum.__hash__(self)
def __eq__(self, other):
if isinstance(other, str):
return self.name.lower() == other.lower() # pylint: disable=no-member
if isinstance(other, (int, float)):
return self.value == other
return Enum.__eq__(self, other)
class SettingsProxy: class SettingsProxy:
"""Proxy object to get settings for a user """Proxy object to get settings for a user
""" """