blob: 0f45c3da5068eb7ebb5f3beeff92d0d8be117430 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
from django.core.management.base import NoArgsCommand
from django.db import transaction
from askbot.models import Post
from askbot.utils.console import ProgressBar
class Command(NoArgsCommand):
help = 'Generates snippets for all posts'
@transaction.commit_manually
def handle_noargs(self, *args, **kwargs):
posts = Post.objects.all()
count = posts.count()
message = 'Building post snippets'
for post in ProgressBar(posts.iterator(), count, message):
if hasattr(post, 'summary'):
post.summary = post.get_snippet()
post.html = post.parse_post_text()['html']
post.save()
transaction.commit()
if post.thread:
post.thread.invalidate_cached_data(lazy=True)
transaction.commit()
|