Ejemplo n.º 1
0
    def list(self, request, cursor=None):
        # TODO: bi-directional pagination instead of one way ticket forward
        self._import_model_if_not()
        self.check_authority(request, OP_LIST)
        q = self.get_query(request)
        if cursor:
            q.with_cursor(cursor)
        entities = q.fetch(self.entities_per_page)
        if entities:
            next_cursor = q.cursor()

            q2 = self.get_query(request)
            q2.with_cursor(next_cursor)
            if q2.get() is None:
                next_cursor = None
        else:
            next_cursor = None
        return render_to_response(self.get_template(request, OP_LIST), {
            'model': self.model_name,
            'entities': entities,
            'cursor': next_cursor,
            'message': get_flash(),
        },
                                  processors=(self.url_processor, ))
Ejemplo n.º 2
0
 def list(self, request, cursor=None):
   self._import_model_if_not()
   self.check_authority(request, OP_LIST)
   q = self.get_query(request)
   try:
       page = int(request.args.get('page','1'))
   except ValueError:
       page = 1
   paginator = Paginator(q,self.entities_per_page)
   try:
       entities = paginator.page(page)
   except (EmptyPage,InvalidPage):
       entities = paginator.page(paginator.num_pages)
   return render_to_response(self.get_template(request, OP_LIST),
                             {'model': self.model_name,
                              'entities': entities.object_list,
                              'message': get_flash(),
                              'current_page':entities.number,
                              'previous_page':entities.previous_page_number,
                              'next_page':entities.next_page_number,
                              'has_next':entities.has_next,
                              'total_pages':entities.paginator.num_pages,
                             },
                             processors=(self.url_processor,))
Ejemplo n.º 3
0
Archivo: crud.py Proyecto: IanLewis/kay
  def list(self, request, cursor=None):
    # TODO: bi-directional pagination instead of one way ticket forward
    self._import_model_if_not()
    self.check_authority(request, OP_LIST)
    q = self.get_query(request)
    if cursor:
      q.with_cursor(cursor)
    entities = q.fetch(self.entities_per_page)
    if entities:
      next_cursor = q.cursor()

      q2 = self.get_query(request)
      q2.with_cursor(next_cursor)
      if q2.get() is None:
        next_cursor = None
    else:
      next_cursor = None
    return render_to_response(self.get_template(request, OP_LIST),
                              {'model': self.model_name,
                               'entities': entities,
                               'cursor': next_cursor,
                               'message': get_flash(),
                              },
                              processors=(self.url_processor,))
Ejemplo n.º 4
0
 def get(self):
     message = flash.get_flash()
     return render_to_response(self.template_name, {"form": self.form.as_widget(), "message": message})
Ejemplo n.º 5
0
 def get(self):
     message = flash.get_flash()
     return render_to_response(self.template_name, {
         "form": self.form.as_widget(),
         "message": message
     })
Ejemplo n.º 6
0
 def get(self, id):
     tweet = get_by_id_or_404(models.Tweet, id)
     return render_to_response('core/show.html', {
         'tweet': tweet,
         'message': get_flash()
     })