annotate legacy/management/commands/fix_potd_smiles.py @ 821:71db8076dc3d

Bandmap WIP: geocoding integrated with add form. Add form works. Before submitting the form, client side JS makes a geocode request to Google and populates hidden lat/lon fields with the result. Successfully created a model instance on the server side. Still need to update admin dashboard, admin approval, and give out badges for adding bands to the map. Once that is done, then work on displaying the map with filtering.
author Brian Neal <bgneal@gmail.com>
date Tue, 23 Sep 2014 20:40:31 -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