comparison gpp/legacy/management/commands/fix_potd_smiles.py @ 538:97593a955291

Added a command to fix the old 1.0 POTD smileys to match the new.
author Brian Neal <bgneal@gmail.com>
date Sat, 31 Dec 2011 23:39:24 +0000
parents
children
comparison
equal deleted inserted replaced
537:eac0ce5e137d 538:97593a955291
1 """
2 This command fixes the old 1.0 smiley system to match the new scheme.
3
4 """
5 from django.core.management.base import NoArgsCommand
6 from comments.models import Comment
7
8
9 SMILEY_MAP = {
10 ':confused:': ':?',
11 ':upset:': ':argh:',
12 ':eek:': ':shock:',
13 ':rolleyes:': ':whatever:',
14 ':mad:': 'X-(',
15 ':shy:': ':oops:',
16 ':laugh:': ':lol:',
17 ':dead:': 'x_x',
18 ':cry:': ':-(',
19 ';)': ':wink:',
20 ':|': ':-|',
21 ';-)': ':wink:',
22 ':D': ':-D',
23 ':P': ':-P',
24 'B)': '8)',
25 ':(': ':-(',
26 ':)': ':-)',
27 }
28
29
30 class Command(NoArgsCommand):
31
32 def handle_noargs(self, **opts):
33
34 comments = Comment.objects.filter(id__gt=3000)
35 for comment in comments:
36 save = False
37 for key, val in SMILEY_MAP.items():
38 if key in comment.comment:
39 comment.comment = comment.comment.replace(key, val)
40 save = True
41
42 if save:
43 comment.save()
44