Add the Response model
This is to store RSVPs.
This commit is contained in:
parent
0fb0ff8c99
commit
321f31b3c6
@ -74,6 +74,35 @@ NOTIFICATION_ACTION_MESSAGES = {
|
||||
}
|
||||
|
||||
|
||||
class ResponseType(Enum):
|
||||
"""Enumeration of event availabilities
|
||||
"""
|
||||
|
||||
#: The user is about to attend the event
|
||||
going = 0
|
||||
|
||||
#: The user will probably attend the event
|
||||
probably_going = 1
|
||||
|
||||
#: The user is interested in the event, but might not go
|
||||
probably_not_going = 2
|
||||
|
||||
#: The user won’t attend the event
|
||||
not_going = 3
|
||||
|
||||
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
|
||||
"""
|
||||
@ -617,3 +646,31 @@ class Invitation(db.Model): # pylint: disable=too-few-public-methods
|
||||
|
||||
#: The timestamp of the invitation
|
||||
timestamp = db.Column(db.DateTime(), default=datetime.utcnow)
|
||||
|
||||
|
||||
class Response(db.Model): # pylint: disable=too-few-public-methods
|
||||
"""Database model for RSVPs.
|
||||
"""
|
||||
|
||||
__tablename__ = 'responses'
|
||||
|
||||
#: The profile that’s sending the RSVP
|
||||
profile_id = db.Column(db.Integer(), db.ForeignKey('profiles.id'), primary_key=True)
|
||||
|
||||
profile = db.relationship('Profile')
|
||||
|
||||
#: The ID of the event
|
||||
event_id = db.Column(db.Integer(), db.ForeignKey('events.id'), primary_key=True)
|
||||
|
||||
event = db.relationship('Event')
|
||||
|
||||
#: The ID of the invitation, if the user is responding to an invitation
|
||||
invitation_id = db.Column(db.Integer(), db.ForeignKey('invitations.id'), nullable=True)
|
||||
|
||||
invitation = db.relationship('Invitation')
|
||||
|
||||
#: The timestamp of the response
|
||||
timestamp = db.Column(db.DateTime(), default=datetime.utcnow)
|
||||
|
||||
#: The response itself
|
||||
response = db.Column(db.Enum(ResponseType), nullable=False)
|
||||
|
Loading…
Reference in New Issue
Block a user