2 from django.utils.translation import ugettext as _
4 def silent_permalink(func):
6 Decorator that calls urlresolvers.reverse() to return a URL using
7 parameters returned by the decorated function "func".
9 "func" should be a function that returns a tuple in one of the
12 (viewname, viewargs, viewkwargs)
14 from django.core.urlresolvers import reverse
15 def inner(*args, **kwargs):
16 bits = func(*args, **kwargs)
18 return reverse(bits[0], None, *bits[1:3])
20 return "javascript:alert('Configure this page URL in the urls.py file');"
24 friendly_name = _("page")
32 return self._as_markdown(self.body)
34 def save(self, *args, **kwargs):
35 old_options = self._original_state.get('extra', None)
37 super(Page, self).save(*args, **kwargs)
39 registry = settings.STATIC_PAGE_REGISTRY
42 registry.pop(old_options.get('path', ''), None)
44 registry[self.extra['path']] = self.id
47 settings.STATIC_PAGE_REGISTRY.set_value(registry)
54 return _("[Unpublished] %s") % self.title
57 def get_absolute_url(self):
58 return ('static_page', (), {'path': self.extra['path']})
60 def activate_revision(self, user, revision, extensions=['urlize']):
61 self.title = revision.title
62 self.tagnames = revision.tagnames
63 self.body = revision.body
65 self.active_revision = revision
66 self.update_last_activity(user)
70 class Meta(Node.Meta):