Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(0)  |  Derive(0)  |  Import(2)

src/d/j/django-notifyme-onsite-0.0.2a1/notifyme_onsite/views.py   django-notifyme-onsite(Download)
#-*- coding: utf-8 -*-
from django import http
from notifyme_onsite.models import OnsiteNotification
from notifyme_onsite.settings import DISMISSED_NOTIFICATION_SESSION_VAR
 
def dismiss_notification(request, notification_id):
    user = request.user
    if user.is_anonymous():
        dismissed_notifications = request.session.get(DISMISSED_NOTIFICATION_SESSION_VAR, [])
        existing_notifications = [n['id'] for n in OnsiteNotification.objects.filter(user=None).values('id')]
        dismissed_notifications = [n for n in list(set(dismissed_notifications)) if n in existing_notifications]
        request.session[DISMISSED_NOTIFICATION_SESSION_VAR] = dismissed_notifications
#        request.session.modified = True
    else:

src/d/j/django-notifyme-onsite-0.0.2a1/notifyme_onsite/context_processors.py   django-notifyme-onsite(Download)
from django.utils.translation import get_language
from notifyme_onsite.models import OnsiteNotification
from notifyme_onsite.settings import DISMISSED_NOTIFICATION_SESSION_VAR
 
def sticky_notifications(request):
        notifications = notifications.filter(user=None, language=language)
        # remove any notices that have been dismissed by the anonymous user in his session
        dismissed = request.session.get(DISMISSED_NOTIFICATION_SESSION_VAR, [])
        notifications = [n for n in notifications if not n.id in dismissed]
    else: