[python] views.py
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- from django.http import HttpResponseRedirect
- from django.urls import reverse
- from notifications.utils import id2slug, slug2id
- from django.shortcuts import get_object_or_404, redirect
- from notifications.models import Notification
- import Fusion.settings as FusionIIIT_settings
- def delete(request, slug=None):
- notification_id = slug2id(slug)
- notification = get_object_or_404(
- Notification, recipient=request.user, id=notification_id)
- notification.delete()
- previous_page = request.META.get('HTTP_REFERER', '/')
- # Redirect to the previous page or the home page if the referrer is not available
- return HttpResponseRedirect(previous_page)
- # return HttpResponseRedirect('dashboard/')
- def mark_as_read_and_redirect(request, slug=None):
- notification_id = slug2id(slug)
- notification = get_object_or_404(
- Notification, recipient=request.user, id=notification_id)
- notification.mark_as_read()
- # This conditional statement is True only in
- # case of complaint_module and course_management_module.
- # return redirect('notifications:all')
- if(notification.data['module'] == 'Complaint System'):
- complaint_id=notification.description
- return HttpResponseRedirect(reverse(notification.data['url'],kwargs={'detailcomp_id1':complaint_id}))
- elif(notification.data['module'] == 'Course Management'):
- course_code = notification.data['course_code']
- version = notification.data['version']
- return HttpResponseRedirect(reverse(notification.data['url'],kwargs={'course_code': course_code,'version': version}))
- else:
- return HttpResponseRedirect(reverse(notification.data['url']))
Editor
You can edit this paste and save as new: