示例#1
0
    def push_notification(self, event, active_call):
        p = pusher.Pusher(
            app_id=settings.PUSHER_APP_ID,
            key=settings.PUSHER_KEY,
            secret=settings.PUSHER_SECRET,
            encoder=DjangoJSONEncoder)

        resource = ActiveCallResource()

        bundle = resource.build_bundle(obj=active_call)
        bundle = resource.full_dehydrate(bundle)

        p[settings.PUSHER_CHANNEL].trigger(event, bundle.data)
示例#2
0
def index(request):
    """
    Page shell for the client-side application.

    Bootstraps read-once data onto the page.
    """
    serializer = Serializer()
    resource = ActiveCallResource()

    since = datetime.now() - timedelta(hours=settings.DEFAULT_HOURS_DISPLAYED)
    calls = ActiveCall.objects.filter(reported__gt=since)

    bundles = [resource.build_bundle(obj=c) for c in calls]
    calls_bootstrap = [resource.full_dehydrate(b) for b in bundles]

    return render_to_response('index.html', {
        'settings': settings,
        'bootstrap_data': serializer.to_json({
            'active_calls': calls_bootstrap
        })
    })