From c20ffa09925ec21f3631e6f14f078f2f8b05be70 Mon Sep 17 00:00:00 2001 From: jordan Date: Wed, 29 Jun 2011 10:30:54 +0000 Subject: [PATCH] a new setting has been added that allows to choose whether to update the latest activity date-time of a question when editing only the tags or not git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1083 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/models/node.py | 17 ++++++++++++++++- forum/settings/view.py | 6 +++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/forum/models/node.py b/forum/models/node.py index 96b41dc..72ef0c0 100644 --- a/forum/models/node.py +++ b/forum/models/node.py @@ -359,7 +359,22 @@ class Node(BaseModel, NodeContent): self.body = self.rendered(revision.body) self.active_revision = revision - self.update_last_activity(user) + + # Try getting the previous revision + try: + prev_revision = NodeRevision.objects.get(node=self, revision=revision.revision-1) + + update_activity = True + + # Do not update the activity if only the tags are changed + if prev_revision.title == revision.title and prev_revision.body == revision.body \ + and prev_revision.tagnames != revision.tagnames and not settings.UPDATE_LATEST_ACTIVITY_ON_TAG_EDIT: + update_activity = False + except NodeRevision.DoesNotExist: + update_activity = True + finally: + if update_activity: + self.update_last_activity(user) self.save() diff --git a/forum/settings/view.py b/forum/settings/view.py index fa6edf3..5ebd228 100644 --- a/forum/settings/view.py +++ b/forum/settings/view.py @@ -16,6 +16,10 @@ RECENT_AWARD_SIZE = Setting('RECENT_AWARD_SIZE', 15, VIEW_SET, dict( label = _("Recent awards block size"), help_text = _("The number of awards to display in the recent awards block in the front page."))) +UPDATE_LATEST_ACTIVITY_ON_TAG_EDIT = Setting('UPDATE_LATEST_ACTIVITY_ON_TAG_EDIT', True, VIEW_SET, dict( +label = _("Update latest activity on tag edit"), required=False, +help_text = _("If you check this the latest activity will be updated when editing only the tags of a question."))) + LIMIT_RELATED_TAGS = Setting('LIMIT_RELATED_TAGS', 0, VIEW_SET, dict( label = _("Limit related tags block"), -help_text = _("Limit related tags block size in questions list pages. Set to 0 to display all all tags."))) \ No newline at end of file +help_text = _("Limit related tags block size in questions list pages. Set to 0 to display all all tags."))) -- 2.45.1