# HG changeset patch # User Brian Neal # Date 1325374764 0 # Node ID 97593a955291a844b3d29a8bd782f62d21eb6c37 # Parent eac0ce5e137d00f4ebd5e8d1dd59d86e79a890e6 Added a command to fix the old 1.0 POTD smileys to match the new. diff -r eac0ce5e137d -r 97593a955291 gpp/legacy/management/commands/fix_potd_smiles.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/legacy/management/commands/fix_potd_smiles.py Sat Dec 31 23:39:24 2011 +0000 @@ -0,0 +1,44 @@ +""" +This command fixes the old 1.0 smiley system to match the new scheme. + +""" +from django.core.management.base import NoArgsCommand +from comments.models import Comment + + +SMILEY_MAP = { + ':confused:': ':?', + ':upset:': ':argh:', + ':eek:': ':shock:', + ':rolleyes:': ':whatever:', + ':mad:': 'X-(', + ':shy:': ':oops:', + ':laugh:': ':lol:', + ':dead:': 'x_x', + ':cry:': ':-(', + ';)': ':wink:', + ':|': ':-|', + ';-)': ':wink:', + ':D': ':-D', + ':P': ':-P', + 'B)': '8)', + ':(': ':-(', + ':)': ':-)', +} + + +class Command(NoArgsCommand): + + def handle_noargs(self, **opts): + + comments = Comment.objects.filter(id__gt=3000) + for comment in comments: + save = False + for key, val in SMILEY_MAP.items(): + if key in comment.comment: + comment.comment = comment.comment.replace(key, val) + save = True + + if save: + comment.save() +