Revision 719d8d08 cloudcmsblog/models.py

b/cloudcmsblog/models.py
54 54
from feincms.content.application.models import ApplicationContent
55 55

  
56 56
from cloudcms.models import Application
57
from cloudcms.cms_utils import get_app_page
57 58

  
58 59
# monkeypatch django reverse (feincms 1.5+ solves this issue)
59 60
urlresolvers.reverse = reverse
......
114 115
    def latest(self, limit=3):
115 116
        return self.filter()[:limit]
116 117

  
118

  
119
def get_blog_page():
120
    """
121
    Returns Page model that has been associated with blog application
122
    """
123
    return get_app_page(Page, "cloudcmsblog")
124

  
117 125
class Entry(Base):
118 126
    """
119 127
    Blog post entry
......
166 174
        # ugly hack to fix proper application reverse url
167 175
        BLOG_URL = ""
168 176
        try:
169
            AC = Page.content_type_for(ApplicationContent)
170
            blog_block = AC.objects.filter(urlconf_path="cloudcmsblog")[0]
171
            BLOG_URL = blog_block.parent.get_navigation_url()
177
            BLOG_URL = get_blog_page().get_navigation_url()
172 178
        except Exception, e:
173 179
            print e
174 180
        if r.startswith(BLOG_URL):
......
177 183
            return BLOG_URL + r
178 184

  
179 185
    def back_url(self):
180
        AC = Page.content_type_for(ApplicationContent)
181
        blog_block = AC.objects.filter(urlconf_path="cloudcmsblog")[0]
182
        BLOG_URL = blog_block.parent.get_navigation_url()
183
        return BLOG_URL
186
        return get_blog_page().get_navigation_url()
184 187

  
185 188

  
186 189
# Feincms navigation extension

Also available in: Unified diff