forked from fossasia/open-event-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification.py
More file actions
72 lines (58 loc) · 2.32 KB
/
notification.py
File metadata and controls
72 lines (58 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from app.models import db
from app.models.base import SoftDeletionModel
USER_CHANGE_EMAIL = "User email"
PASSWORD_CHANGE = 'Change Password'
TICKET_PURCHASED = 'Ticket(s) Purchased'
TICKET_PURCHASED_ATTENDEE = 'Ticket Purchased to Attendee'
EVENT_ROLE = 'Event Role Invitation'
NEW_SESSION = 'New Session Proposal'
EVENT_EXPORT_FAIL = 'Event Export Failed'
EVENT_EXPORTED = 'Event Exported'
EVENT_IMPORT_FAIL = 'Event Import Failed'
EVENT_IMPORTED = 'Event Imported'
SESSION_SCHEDULE = 'Session Schedule Change'
NEXT_EVENT = 'Next Event'
SESSION_STATE_CHANGE = 'Session State Change'
INVITE_PAPERS = 'Invitation For Papers'
AFTER_EVENT = 'After Event'
EVENT_PUBLISH = 'Event Published'
TICKET_PURCHASED_ORGANIZER = 'Ticket(s) Purchased to Organizer'
TICKET_RESEND_ORGANIZER = 'Ticket Resend'
TICKET_CANCELLED = 'Ticket(s) cancelled'
TICKET_CANCELLED_ORGANIZER = 'Ticket(s) cancelled organizer'
MONTHLY_PAYMENT_NOTIF = 'Monthly Payment Notification'
MONTHLY_PAYMENT_FOLLOWUP_NOTIF = 'Monthly Payment Follow Up Notification'
class NotificationAction(db.Model):
"""
Model for storing user notification actions.
"""
__tablename__ = 'notification_actions'
id = db.Column(db.Integer, primary_key=True)
action_type = db.Column(db.String)
subject = db.Column(db.String)
subject_id = db.Column(
db.String
) # Contains the ID of the related subject, eg. session_id in case of new session.
link = db.Column(
db.String
) # Contains the link if required to take action. Null in other cases.
notification_id = db.Column(
db.Integer, db.ForeignKey('notifications.id', ondelete='CASCADE')
)
notification = db.relationship(
'Notification', backref='actions', foreign_keys=[notification_id]
)
class Notification(SoftDeletionModel):
"""
Model for storing user notifications.
"""
__tablename__ = 'notifications'
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='CASCADE'))
user = db.relationship('User', backref='notifications', foreign_keys=[user_id])
title = db.Column(db.String)
message = db.Column(db.Text)
received_at = db.Column(db.DateTime(timezone=True))
is_read = db.Column(db.Boolean)
def __repr__(self):
return f'<Notif {self.user}:{self.title}>'