Permalink
Browse files

optimize some queries

  • Loading branch information...
1 parent 58005b9 commit 834c84e924396b87ac15cac39469feaf4ab62cc1 @digi604 committed Apr 5, 2013
Showing with 10 additions and 4 deletions.
  1. +10 −4 cms/admin/pageadmin.py
View
@@ -882,16 +882,22 @@ def publish_page(self, request, page_id):
content_type = ContentType.objects.get_for_model(Page)
versions_qs = Version.objects.filter(type=1, content_type=content_type, object_id_int=page.pk)
+ deleted = []
for version in versions_qs.exclude(revision__comment__exact=PUBLISH_COMMENT):
- revision = version.revision
- revision.delete()
+ if not version.revision_id in deleted:
+ revision = version.revision
+ revision.delete()
+ deleted.append(revision.pk)
# delete all publish revisions that are more then MAX_PAGE_PUBLISH_REVERSIONS
limit = get_cms_setting("MAX_PAGE_PUBLISH_REVERSIONS")
if limit:
+ deleted = []
for version in versions_qs.filter(revision__comment__exact=PUBLISH_COMMENT).order_by(
'-revision__pk')[limit - 1:]:
- revision = version.revision
- revision.delete()
+ if not version.revision_id in deleted:
+ revision = version.revision
+ revision.delete()
+ deleted.append(revision.pk)
helpers.make_revision_with_plugins(page, request.user, PUBLISH_COMMENT)
# create a new publish reversion
if 'node' in request.REQUEST:

0 comments on commit 834c84e

Please sign in to comment.