def chrome_getdata_view(request):
    """Get the data of the last notification sent to the current user.

    This is needed because Chrome, as of version 44, doesn't support
    sending a data payload to a notification. Thus, information on what
    the notification is actually for must be manually fetched.

    """
    data = {}
    if request.user.is_authenticated:
        # authenticated session
        notifs = GCMNotification.objects.filter(sent_to__user=request.user).order_by("-time")
        if notifs.count() > 0:
            notif = notifs.first()
            ndata = notif.data
            if "title" in ndata and "text" in ndata:
                data = {
                    "title": ndata['title'] if 'title' in ndata else '',
                    "text": ndata['text'] if 'text' in ndata else '',
                    "url": ndata['url'] if 'url' in ndata else ''
                }
            else:
                schedule_chk = chrome_getdata_check(request)
                if schedule_chk:
                    data = schedule_chk
        else:
            schedule_chk = chrome_getdata_check(request)
            if schedule_chk:
                data = schedule_chk
            else:
                return HttpResponse("null", content_type="text/json")
    else:
        schedule_chk = chrome_getdata_check(request)
        if schedule_chk:
            data = schedule_chk
        else:
            data = {"title": "Check Intranet", "text": "You have a new notification that couldn't be loaded right now."}
    j = json.dumps(data)
    return HttpResponse(j, content_type="text/json")
def chrome_getdata_view ( request ) : data = { } if request . user . is_authenticated : notifs = GCMNotification . objects . filter ( sent_to__user = request . user ) . order_by ( "-time" ) if notifs . count ( ) > 0 : notif = notifs . first ( ) ndata = notif . data if "title" in ndata and "text" in ndata : data = { "title" : ndata [ 'title' ] if 'title' in ndata else '' , "text" : ndata [ 'text' ] if 'text' in ndata else '' , "url" : ndata [ 'url' ] if 'url' in ndata else '' } else : schedule_chk = chrome_getdata_check ( request ) if schedule_chk : data = schedule_chk else : schedule_chk = chrome_getdata_check ( request ) if schedule_chk : data = schedule_chk else : return HttpResponse ( "null" , content_type = "text/json" ) else : schedule_chk = chrome_getdata_check ( request ) if schedule_chk : data = schedule_chk else : data = { "title" : "Check Intranet" , "text" : "You have a new notification that couldn't be loaded right now." } j = json . dumps ( data ) return HttpResponse ( j , content_type = "text/json" )
Get the data of the last notification sent to the current user.

    This is needed because Chrome, as of version 44, doesn't support
    sending a data payload to a notification. Thus, information on what
    the notification is actually for must be manually fetched.