Ejemplo n.º 1
0
    def view(self, id, slug="", format="html"):
        obj = model.entity.get(id)

        if not obj:
            abort(404, _("Sorry, there is no entity with id %r") % id)

        if format == "html":
            # validate the slug and redirect to the current url if the slug
            # changed (e.g. fixed typo) with 301 - moved permanently
            if slug != entity_slug(obj):
                url = entity_url(obj)
                redirect(url, code=301)

        return self._view_no_redirect(id, format)
Ejemplo n.º 2
0
    def view(self, id, slug="", format="html"):
        # abort if we have no ObjectId. We don't want to
        # lookup by name.
        try:
            oid = ObjectId(id)
        except InvalidId:
            abort(404, _("Sorry, there is no %s with code %r") % (self.model.__name__.lower(), id))

        if format == "html":
            # validate the slug and redirect to the current url if the slug
            # changed (e.g. fixed typo) with 301 - moved permanently
            entity = self._get_by_id(oid)
            if slug != entity_slug(entity):
                url = entity_url(entity)
                redirect(url, code=301)

        return super(EntityController, self).view(id, format)
Ejemplo n.º 3
0
 def _make_browser(self):
     url = entity_url(c.entity, action="entries")
     c.browser = Browser(request.params, url=url)
     c.browser.filter_by("(+to.id:%s OR +from.id:%s)" % (c.entity.id, c.entity.id))
     c.browser.facet_by_dimensions()
Ejemplo n.º 4
0
 def _make_browser(self):
     url = entity_url(c.entity, action="entries")
     c.browser = Browser(request.params, url=url)
     c.browser.filter_by("(+to.id:%(_id)s OR +from.id:%(_id)s)" % {"_id": c.entity["_id"]})
     c.browser.facet_by_dimensions()