Statistics
| Branch: | Tag: | Revision:

root / cloudcms / cms_utils.py @ 719d8d08

History | View | Annotate | Download (617 Bytes)

1 719d8d08 Kostas Papadimitriou
from feincms.content.application.models import ApplicationContent
2 719d8d08 Kostas Papadimitriou
3 719d8d08 Kostas Papadimitriou
def get_app_page(model, urlconf_path):
4 719d8d08 Kostas Papadimitriou
    """
5 719d8d08 Kostas Papadimitriou
    Returns the model entry that has been associated with the application that
6 719d8d08 Kostas Papadimitriou
    provides the passed urlconf_path.
7 719d8d08 Kostas Papadimitriou

8 719d8d08 Kostas Papadimitriou
    e.g. to retrieve the page associated with
9 719d8d08 Kostas Papadimitriou

10 719d8d08 Kostas Papadimitriou
    >>> page = get_app_page(Page, 'cloudcmsblog')
11 719d8d08 Kostas Papadimitriou
    >>> print page.get_navigation_url()
12 719d8d08 Kostas Papadimitriou
    >>> "/blog/"
13 719d8d08 Kostas Papadimitriou

14 719d8d08 Kostas Papadimitriou
    """
15 719d8d08 Kostas Papadimitriou
    app_content_type = model.content_type_for(ApplicationContent)
16 719d8d08 Kostas Papadimitriou
    try:
17 719d8d08 Kostas Papadimitriou
        blog_block = app_content_type.objects.filter(urlconf_path="cloudcmsblog")[0]
18 719d8d08 Kostas Papadimitriou
    except:
19 719d8d08 Kostas Papadimitriou
        return None
20 719d8d08 Kostas Papadimitriou
    return blog_block.parent