1 6 11 13 14 16 17 18 19 20 22 23 29 32 34 37 39 40 41 42 43 49 51 53 55 57 58 60 61 62 64 65 68 70 73 76 77 78 79 81 83 84 86 88 89 92 94 96 97 99 100 102 103 112 113 119 120 122 123 125 127 128 132 133 135 137 138 139 140 141 142 143 144 149 150 153 156 158 159 160 161 162 163 164 165 166 171 177 178 180 181 182 183 184 185 186 187 188 191 194 199 201 202 207 208 209 210 213 222 225 230 232 234 235 236 237 238 246 248 250 251 252 253 255 256 257 258 259 263 264 266 267 269 270 271 272 273 274 275 276 277 278 279 281 283 292 296 299 |
# -*- coding: utf-8 -*-
""" Page manager provide several filters to obtain pages :class:`QuerySet` that respect the page attributes and project settings. """
"""Create a population of :class:`Page <pages.models.Page>` for testing purpose.""" status=self.model.PUBLISHED) language='en-us', page=p).save() language='en-us', page=p).save()
"""Return a :class:`QuerySet` of pages that are published on the site defined by the ``SITE_ID`` setting.
:param site_id: specify the id of the site object to filter with. """
"""Return a :class:`QuerySet` of pages without parent."""
"""Creates a :class:`QuerySet` of the published root pages.""" status=self.model.PUBLISHED).filter(parent__isnull=True)
"""Creates a :class:`QuerySet` of the hidden pages.""" return self.on_site().filter(status=self.model.HIDDEN)
"""Filter the given pages :class:`QuerySet` to obtain only published page."""
Q(publication_end_date__gt=datetime.now()) | Q(publication_end_date__isnull=True) )
"""Creates a :class:`QuerySet` of published :class:`Page <pages.models.Page>`."""
"""Creates a :class:`QuerySet` of drafts using the page's :attr:`Page.publication_date`.""" pub = pub.filter(publication_date__gte=datetime.now())
"""Creates a :class:`QuerySet` of expired using the page's :attr:`Page.publication_end_date`.""" publication_end_date__lte=datetime.now())
"""Return a :class:`Page <pages.models.Page>` according to the page's path.""" # if more than one page is matching the slug, # we need to use the full URL
""":class:`Content <pages.models.Content>` manager methods"""
"""Sanitize a string in order to avoid possible XSS using ``html5lib``.""" # TODO: that's a bit of a hack there # we need to remove <html><head/><body>...</body></html>
"""Set or create a :class:`Content <pages.models.Content>` for a particular page and language.
:param page: the concerned page object. :param language: the wanted language. :param ctype: the content type. :param body: the content of the Content object. """ type=ctype).latest('creation_date') content.body = body type=ctype)
"""Create a :class:`Content <pages.models.Content>` for a particular page and language only if the content has changed from the last time.
:param page: the concerned page object. :param language: the wanted language. :param ctype: the content type. :param body: the content of the Content object. """ type=ctype).latest('creation_date') type=ctype)
"""Gets the latest :class:`Content <pages.models.Content>` for a particular page and language. Falls back to another language if wanted.
:param page: the concerned page object. :param language: the wanted language. :param ctype: the content type. :param language_fallback: fallback to another language if ``True``. """
else:
# fill a dict object for each language 'language':lang[0], 'type':ctype, 'page':page } # using the same variable name "language" introduce nasty bugs.
ctype)
"""Returns the latest :class:`Content <pages.models.Content>` slug object that match the given slug for the current site domain.
:param slug: the wanted slug. """ else:
"""Return all page's id matching the given slug.
:param slug: the wanted slug. """ MAX(pages_content.creation_date) FROM pages_content WHERE (pages_content.type = %s AND pages_content.body =%s) GROUP BY pages_content.page_id'''
""":class:`PageAlias <pages.models.PageAlias>` manager."""
""" Resolve a request to an alias. returns a :class:`PageAlias <pages.models.PageAlias>` if the url matches no page at all. The aliasing system supports plain aliases (``/foo/bar``) as well as aliases containing GET parameters (like ``index.php?page=foo``).
:param request: the request object :param path: the complete path to the page :param lang: not used """
# §1: try with complete query string # §2: try with path only return alias # §3: not alias found, we give up |