]> git.openstreetmap.org Git - osqa.git/blob - forum/models/page.py
Avoids a strange error probably coming from either django or python.
[osqa.git] / forum / models / page.py
1 from base import *
2 from django.utils.translation import ugettext as _
3
4 class Page(Node):
5     friendly_name = _("page")
6
7     @property
8     def published(self):
9         return self.marked
10
11     def save(self, *args, **kwargs):
12         old_options = self._original_state.get('extra', None)
13
14         super(Page, self).save(*args, **kwargs)
15
16         registry = settings.STATIC_PAGE_REGISTRY
17
18         if old_options:
19             registry.pop(old_options.get('path', ''), None)
20
21         registry[self.extra['path']] = self.id
22
23
24         settings.STATIC_PAGE_REGISTRY.set_value(registry)
25
26     @property
27     def headline(self):
28         if self.published:
29             return self.title
30         else:
31             return _("[Unpublished] %s") % self.title
32
33     @models.permalink
34     def get_absolute_url(self):
35         return ('static_page', (), {'path': self.extra['path']})
36
37     class Meta(Node.Meta):
38         proxy = True
39
40