61
61
return self.cleaned_data
63
def cache_old_content(self):
64
if self.instance.id is None:
65
self.old_title = self.old_content = self.old_markup = ''
68
self.old_title = self.instance.title
69
self.old_content = self.instance.content
70
self.old_markup = self.instance.markup
73
def save(self, *args, **kwargs):
75
65
editor_ip = self.cleaned_data['user_ip']
76
66
comment = self.cleaned_data['comment']
68
# 1 - Get the old stuff before saving
69
if self.instance.id is None:
70
old_title = old_content = old_markup = ''
73
old_title = self.instance.title
74
old_content = self.instance.content
75
old_markup = self.instance.markup
78
78
# 2 - Save the Article
79
article = super(ArticleForm, self).save(*args, **kwargs)
79
article = super(ArticleForm, self).save()
81
81
# 3 - Set creator and group
82
82
editor = getattr(self, 'editor', None)
83
83
group = getattr(self, 'group', None)
85
85
article.creator_ip = editor_ip
86
86
if editor is not None:
87
87
article.creator = editor
88
88
article.group = group
89
article.save(*args, **kwargs)
91
91
# 4 - Create new revision
92
92
changeset = article.new_revision(
93
self.old_content, self.old_title, self.old_markup,
93
old_content, old_title, old_markup,
94
94
comment, editor_ip, editor)
96
96
return article, changeset