bgneal@538: """ bgneal@538: This command fixes the old 1.0 smiley system to match the new scheme. bgneal@538: bgneal@538: """ bgneal@538: from django.core.management.base import NoArgsCommand bgneal@538: from comments.models import Comment bgneal@538: bgneal@538: bgneal@538: SMILEY_MAP = { bgneal@538: ':confused:': ':?', bgneal@538: ':upset:': ':argh:', bgneal@538: ':eek:': ':shock:', bgneal@538: ':rolleyes:': ':whatever:', bgneal@538: ':mad:': 'X-(', bgneal@538: ':shy:': ':oops:', bgneal@538: ':laugh:': ':lol:', bgneal@538: ':dead:': 'x_x', bgneal@538: ':cry:': ':-(', bgneal@538: ';)': ':wink:', bgneal@538: ':|': ':-|', bgneal@538: ';-)': ':wink:', bgneal@538: ':D': ':-D', bgneal@538: ':P': ':-P', bgneal@538: 'B)': '8)', bgneal@538: ':(': ':-(', bgneal@538: ':)': ':-)', bgneal@538: } bgneal@538: bgneal@538: bgneal@538: class Command(NoArgsCommand): bgneal@538: bgneal@538: def handle_noargs(self, **opts): bgneal@538: bgneal@538: comments = Comment.objects.filter(id__gt=3000) bgneal@538: for comment in comments: bgneal@538: save = False bgneal@538: for key, val in SMILEY_MAP.items(): bgneal@538: if key in comment.comment: bgneal@538: comment.comment = comment.comment.replace(key, val) bgneal@538: save = True bgneal@538: bgneal@538: if save: bgneal@538: comment.save() bgneal@538: