Repository: fossasia/open-event-server

Issue:
Error on clicking on notification
After being added in the conference we get a notification. I accepted the notification but the green circle stays there. Also when I click the notification again it gives this error

![screenshot 121](https://cloud.githubusercontent.com/assets/22588035/26036970/06615e66-3907-11e7-9135-ecbe96dc3997.png)




Discussion:
@heysadboy firstly, please try to share only the necessary part of the screenshot instead of the entire screenshot since it might show many private information. Secondly, can you please be a little more clear. Is it happening for all notifications? Because the url opened has nothing to do with the green notification. And if it was the role invite link, it was supposed to work only once. So I am not sure about the issue. Can you tell the steps to reproduce?
@SaptakS Sorry for this, I updated the screenshot.

- After being added in the conference as co organizer for testing I got this notification.
- I clicked the notification and was able to accept.
- I still see the green bubble of new notification when I go back.
- When I open again and click that old notification this error occurs.
Where should the user be redirected to, once he/she accepts the co-organizer invitation? 
( Right now, there is an error page shown, on top of which is a success message. Also the web page's title is Internal Server Error.  ) I think the notifications page should still be there.
@shubham-padia @SaptakS 

![image](https://cloud.githubusercontent.com/assets/14938154/26121655/9e8f0878-3a92-11e7-8e6a-b7a80d0cd11e.png)

@enigmaeth the issue here is, once an invitation is accepted, the notification should disappear. But it still stays. And when you click on it the second time, you get an internal server error. So, should be done is, the notification should be marked as read once invitation is accepted and the user shouldn't be able to click on the notification again
Yes, I reproduced that, but the screenshot above is from the first time I clicked on the notif. So we need to change this also apart from marking the notif as read.
It says ' We are having issues.' Shouldn't the notifications page be there?
Yes. Notification page should be there.
@niranjan94 @enigmaeth I also noticed this on clicking this again. it shows -1, instead of disappearing  
![screenshot 104](https://cloud.githubusercontent.com/assets/22588035/26122327/b532905c-3a94-11e7-8bc9-d5bf1eeafa23.png)

@niranjan94 

Please go through these two ways for marking notifications as read.
( These are with respect to notifications for invitations)
- The user clicks on a notification in the notif-drop-down and it is marked as read( count decreases by 1 upto 0). Clicking on the notif takes the user to the `/notifications` page where the invitation does not show up under *Unread* - that is an issue. So the user will find it under *All*. 

- The user clicks on a notification in the notif-drop-down and is taken to the `/notifications` page where the invitation is listed under *Unread*. But here the count is not decreased until the user clicks *Accepts/Decline* or marks it as read. In this one, ' Mark as Read' is to be implemented with 'Accept/Decline' which is inside models/system_notifications.py.

The part after accepting the invitation works fine. The error is because the invitation stays there with the same link that has been used to accept it earlier. So we get a 404 error.

What could be other approach? How should we go about decreasing the count in the green bubble and marking notifications as read?


Resolving patch:
diff --git a/app/helpers/system_notifications.py b/app/helpers/system_notifications.py
--- a/app/helpers/system_notifications.py
+++ b/app/helpers/system_notifications.py
@@ -80,8 +80,8 @@
         'title': u'Invitation to be {role_name} at {event_name}',
         'message': u"""You've been invited to be a <strong>{role_name}</strong>
             at <strong>{event_name}</strong>.<br><br>
-            <a href='{accept_link}' class='btn btn-success btn-sm'>Accept</a>
-            <a href='{decline_link}' class='btn btn-danger btn-sm'>Decline</a>""",
+            <a href='{accept_link}' class='btn btn-success btn-sm invite'>Accept</a>
+            <a href='{decline_link}' class='btn btn-danger btn-sm invite'>Decline</a>""",
         'recipient': 'User',
     },
     NEW_SESSION: {


Test patch: