Mercurial > public > sg101
view gpp/forums/management/commands/forum_cleanup.py @ 374:dd673fae508d
Fixing #156. Making it possible to goto the first unread post in a thread. Made the 'New' icon a link; when displayed on a topic, takes you to the first unread post.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 07 Mar 2011 01:22:49 +0000 |
parents | 7e19180b128d |
children |
line wrap: on
line source
""" forum_cleanup.py - A management command to cleanup forum model objects. Right now this entails deleting old forum and topic last visit records. """ import datetime from django.core.management.base import NoArgsCommand, CommandError from forums.models import ForumLastVisit, TopicLastVisit import forums.unread class Command(NoArgsCommand): help = "This command deletes old forum and topic last visit records." def handle_noargs(self, **opts): now = datetime.datetime.now() threshold = now - forums.unread.THRESHOLD * 2 # delete old topic last visit records TopicLastVisit.objects.filter(last_visit__lt=threshold).delete() # delete old forum visit records ForumLastVisit.objects.filter(end_date__lt=threshold).delete()