annotate forums/management/commands/sync_forums.py @ 693:ad69236e8501

For issue #52, update many 3rd party Javascript libraries. Updated to jquery 1.10.2, jquery ui 1.10.3. This broke a lot of stuff. - Found a newer version of the jquery cycle all plugin (3.0.3). - Updated JPlayer to 2.4.0. - Updated to MarkItUp 1.1.14. This also required me to add multiline attributes set to true on various buttons in the markdown set. - As per a stackoverflow post, added some code to get multiline titles in a jQuery UI dialog. They removed that functionality but allow you to put it back. Tweaked the MarkItUp preview CSS to show blockquotes in italic. Did not update TinyMCE at this time. I'm not using the JQuery version and this version appears to work ok for now. What I should do is make a repo for MarkItUp and do a vendor branch thing so I don't have to futz around diffing directories to figure out if I'll lose changes when I update.
author Brian Neal <bgneal@gmail.com>
date Wed, 04 Sep 2013 19:55:20 -0500
parents ee87ea74d46b
children
rev   line source
bgneal@294 1 """
bgneal@294 2 sync_forums.py - A management command to synchronize the forums by recomputing
bgneal@294 3 the de-normalized fields in the forum and topic objects.
bgneal@294 4
bgneal@294 5 """
bgneal@294 6 import optparse
bgneal@294 7
bgneal@294 8 from django.core.management.base import NoArgsCommand, CommandError
bgneal@294 9
bgneal@294 10 from forums.models import Forum
bgneal@294 11 from forums.models import Topic
bgneal@294 12
bgneal@294 13
bgneal@294 14 class Command(NoArgsCommand):
bgneal@294 15 help = """\
bgneal@294 16 This command synchronizes the forum application's forums and topic objects
bgneal@294 17 by updating their de-normalized fields.
bgneal@294 18 """
bgneal@294 19 option_list = NoArgsCommand.option_list + (
bgneal@294 20 optparse.make_option("-p", "--progress", action="store_true",
bgneal@294 21 help="Output a . after every 50 topics to show progress"),
bgneal@294 22 )
bgneal@294 23
bgneal@294 24 def handle_noargs(self, **opts):
bgneal@294 25
bgneal@294 26 show_progress = opts.get('progress', False) or False
bgneal@294 27
bgneal@294 28 n = 0
bgneal@294 29 for topic in Topic.objects.iterator():
bgneal@294 30 topic.post_count_update()
bgneal@294 31 topic.save()
bgneal@294 32 n += 1
bgneal@294 33 if n % 50 == 0:
bgneal@294 34 self.stdout.write('.')
bgneal@294 35 self.stdout.flush()
bgneal@294 36
bgneal@294 37 for forum in Forum.objects.all():
bgneal@294 38 forum.sync()
bgneal@294 39 forum.save()
bgneal@294 40
bgneal@294 41 self.stdout.write('\n')
bgneal@294 42