annotate legacy/management/commands/fix_potd_smiles.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@538 1 """
bgneal@538 2 This command fixes the old 1.0 smiley system to match the new scheme.
bgneal@538 3
bgneal@538 4 """
bgneal@538 5 from django.core.management.base import NoArgsCommand
bgneal@538 6 from comments.models import Comment
bgneal@538 7
bgneal@538 8
bgneal@538 9 SMILEY_MAP = {
bgneal@538 10 ':confused:': ':?',
bgneal@538 11 ':upset:': ':argh:',
bgneal@538 12 ':eek:': ':shock:',
bgneal@538 13 ':rolleyes:': ':whatever:',
bgneal@538 14 ':mad:': 'X-(',
bgneal@538 15 ':shy:': ':oops:',
bgneal@538 16 ':laugh:': ':lol:',
bgneal@538 17 ':dead:': 'x_x',
bgneal@538 18 ':cry:': ':-(',
bgneal@538 19 ';)': ':wink:',
bgneal@538 20 ':|': ':-|',
bgneal@538 21 ';-)': ':wink:',
bgneal@538 22 ':D': ':-D',
bgneal@538 23 ':P': ':-P',
bgneal@538 24 'B)': '8)',
bgneal@538 25 ':(': ':-(',
bgneal@538 26 ':)': ':-)',
bgneal@538 27 }
bgneal@538 28
bgneal@538 29
bgneal@538 30 class Command(NoArgsCommand):
bgneal@538 31
bgneal@538 32 def handle_noargs(self, **opts):
bgneal@538 33
bgneal@538 34 comments = Comment.objects.filter(id__gt=3000)
bgneal@538 35 for comment in comments:
bgneal@538 36 save = False
bgneal@538 37 for key, val in SMILEY_MAP.items():
bgneal@538 38 if key in comment.comment:
bgneal@538 39 comment.comment = comment.comment.replace(key, val)
bgneal@538 40 save = True
bgneal@538 41
bgneal@538 42 if save:
bgneal@538 43 comment.save()
bgneal@538 44