Added Ability to Delete Notifications

This commit is contained in:
orbitroom
2016-02-23 19:41:32 -05:00
parent 974698fe2c
commit 11b1f2fb0e
3 changed files with 22 additions and 0 deletions

View File

@@ -29,3 +29,14 @@ def notification_view(request, notif_id):
else:
logger.warn("User %s not authorized to view notif_id %s belonging to user %s" % (request.user, notif_id, notif.user))
return redirect('auth_notification_list')
@login_required
def remove_notification(request, notif_id):
logger.debug("remove notification called by user %s for notif_id %s" % (request.user, notif_id))
if Notification.objects.filter(id=notif_id).exists():
notif = get_object_or_404(Notification, pk=notif_id)
notif.delete()
logger.info("Deleting notif id %s by user %s" % (notif_id, request.user))
else:
logger.error("Unable to delete notif id %s for user %s - notif matching id not found." % (notif_id, request.user))
return redirect('auth_notification_list')