[WIP] Calculate response visibility #91

Draft
gergely wants to merge 2 commits from response-visibility into master
1 changed files with 53 additions and 0 deletions
Showing only changes of commit 45eb411eb2 - Show all commits

View File

@ -70,6 +70,18 @@ class NotificationAction(Enum):
#: A user has been invited to an event
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 = {
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:
"""Proxy object to get settings for a user
"""