1 from django.utils.translation import ugettext as _
2 from forum.models.action import ActionProxy
3 from forum.models import Page
5 class NewPageAction(ActionProxy):
8 def process_data(self, **data):
9 title = data.pop('title')
10 body = data.pop('content')
12 page = Page(author=self.user, title=title, body=body, extra=data)
16 def describe(self, viewer=None):
17 return _("%(user)s created a new page titled %(page)s") % {
18 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
19 'page': self.hyperlink(self.node.get_absolute_url(), self.node.title)
22 class EditPageAction(ActionProxy):
25 def process_data(self, **data):
26 title = data.pop('title')
27 body = data.pop('content')
29 if (title != self.node.title) and (body != self.node.body):
30 self.node.create_revision(self.user, title=title, body=body)
32 self.node.extra = data
35 def describe(self, viewer=None):
36 return _("%(user)s edited the page titled %(page)s") % {
37 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
38 'page': self.hyperlink(self.node.get_absolute_url(), self.node.title)
41 class PublishAction(ActionProxy):
44 def process_action(self):
45 self.node.marked = True
46 self.node.nstate.published = self
49 def cancel_action(self):
50 self.node.marked = False
51 self.node.nstate.published = None
54 def describe(self, viewer=None):
55 return _("%(user)s published a new page titled %(page)s") % {
56 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
57 'page': self.hyperlink(self.node.get_absolute_url(), self.node.title)