]> git.openstreetmap.org Git - osqa.git/blob - forum/models/page.py
Merge cacheimp -> master
[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     @property
12     def html(self):
13         return self._as_markdown(self.body)
14
15     def save(self, *args, **kwargs):
16         old_options = self._original_state.get('extra', None)
17
18         super(Page, self).save(*args, **kwargs)
19
20         registry = settings.STATIC_PAGE_REGISTRY
21
22         if old_options:
23             registry.pop(old_options.get('path', ''), None)
24
25         registry[self.extra['path']] = self.id
26
27
28         settings.STATIC_PAGE_REGISTRY.set_value(registry)
29
30     @property
31     def headline(self):
32         if self.published:
33             return self.title
34         else:
35             return _("[Unpublished] %s") % self.title
36
37     @models.permalink
38     def get_absolute_url(self):
39         return ('static_page', (), {'path': self.extra['path']})
40         
41     def activate_revision(self, user, revision, extensions=['urlize']):
42         self.title = revision.title
43         self.tagnames = revision.tagnames        
44         self.body = revision.body
45
46         self.active_revision = revision
47         self.update_last_activity(user)
48
49         self.save()
50
51     class Meta(Node.Meta):
52         proxy = True
53
54