import tornado.gen
import tornado.web

from core.requesthandler import RequestHandler
import core.util

class PushesServlet(RequestHandler):

    @tornado.web.authenticated
    @tornado.web.asynchronous
    @tornado.gen.engine
    def get(self):
        pushes_per_page = core.util.get_int_arg(self.request, 'rpp', 50)
        before = core.util.get_int_arg(self.request, 'before', 0)
        response = yield tornado.gen.Task(
                        self.async_api_call,
                        "pushes",
                        {"rpp": pushes_per_page, "before": before}
                    )

        results = self.get_api_results(response)
        if not results:
            self.finish()

        pushes, last_push = results
        self.render(
            "pushes.html",
            page_title="Pushes",
            pushes=pushes,
            rpp=pushes_per_page,
            last_push=last_push
        )

import tornado.gen
import tornado.web

from core.requesthandler import RequestHandler
import core.util

class PushesServlet(RequestHandler):

    @tornado.web.authenticated
    @tornado.web.asynchronous
    @tornado.gen.engine
    def get(self):
        pushes_per_page = core.util.get_int_arg(self.request, 'rpp', 50)
        before = core.util.get_int_arg(self.request, 'before', 0)
        response = yield tornado.gen.Task(
                        self.async_api_call,
                        "pushes",
                        {"rpp": pushes_per_page, "before": before}
                    )

        results = self.get_api_results(response)
        if not results:
            self.finish()

        pushes, last_push = results
        self.render(
            "pushes.html",
            page_title="Pushes",
            pushes=pushes,
            rpp=pushes_per_page,
            last_push=last_push
        )
