Add ability to dismiss notifications
This commit is contained in:
parent
34fc279092
commit
32b2ecdfa6
9 changed files with 162 additions and 11 deletions
|
@ -1699,7 +1699,15 @@ def create_unique_notification(kind_name, target, metadata={}):
|
|||
create_notification(kind_name, target, metadata)
|
||||
|
||||
|
||||
def list_notifications(user, kind_name=None):
|
||||
def lookup_notification(user, uuid):
|
||||
results = list(list_notifications(user, id_filter=uuid, include_dismissed=True))
|
||||
if not results:
|
||||
return None
|
||||
|
||||
return results[0]
|
||||
|
||||
|
||||
def list_notifications(user, kind_name=None, id_filter=None, include_dismissed=False):
|
||||
Org = User.alias()
|
||||
AdminTeam = Team.alias()
|
||||
AdminTeamMember = TeamMember.alias()
|
||||
|
@ -1722,6 +1730,9 @@ def list_notifications(user, kind_name=None):
|
|||
((AdminUser.id == user) & (TeamRole.name == 'admin')))
|
||||
.order_by(Notification.created)
|
||||
.desc())
|
||||
|
||||
if not include_dismissed:
|
||||
query = query.switch(Notification).where(Notification.dismissed == False)
|
||||
|
||||
if kind_name:
|
||||
query = (query
|
||||
|
@ -1729,6 +1740,11 @@ def list_notifications(user, kind_name=None):
|
|||
.join(NotificationKind)
|
||||
.where(NotificationKind.name == kind_name))
|
||||
|
||||
if id_filter:
|
||||
query = (query
|
||||
.switch(Notification)
|
||||
.where(Notification.uuid == id_filter))
|
||||
|
||||
return query
|
||||
|
||||
|
||||
|
|
Reference in a new issue