#NEWLINE# @ login_required #NEWLINE# def read_and_redirect( request , notification_id ) : #NEWLINE# #INDENT# '\n    Marks the supplied notification as read and then redirects\n    to the supplied URL from the ``next`` URL parameter.\n\n    **IMPORTANT**: This is CSRF - unsafe method.\n    Only use it if its okay for you to mark notifications     as read without a robust check.\n\n    :param request: HTTP request context.\n    :param notification_id: ID of the notification to be marked a read.\n\n    :returns: Redirect response to a valid target url.\n    ' #NEWLINE# notification_page = reverse ( 'notifications:all' ) #NEWLINE# next_page = request . GET . get ( 'next' , notification_page ) #NEWLINE# if is_safe_url ( next_page ) : #NEWLINE# #INDENT# target = next_page #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# target = notification_page #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# user_nf = request . user . notifications . get ( pk = notification_id ) #NEWLINE# if ( not user_nf . read ) : #NEWLINE# #INDENT# user_nf . mark_as_read ( ) #NEWLINE# #UNINDENT# #UNINDENT# except Notification . DoesNotExist : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# return HttpResponseRedirect ( request )