# Path: dinette/libs/postmarkup.py
# def render_bbcode(bbcode,
#                   encoding="ascii",
#                   exclude_tags=None,
#                   auto_urls=True,
#                   paragraphs=False,
#                   clean=True,
#                   tag_data=None):
# 
#     """ Renders a bbcode string in to XHTML. This is a shortcut if you don't
#         need to customize any tags.
# 
#         post_markup -- String containing bbcode.
#         encoding -- Encoding of string, defaults to "ascii" if the string is not
#         already unicode.
#         exclude_tags -- A collection of tag names to ignore.
#         auto_urls -- If True, then urls will be wrapped with url bbcode tags.
#         paragraphs -- If True then line breaks will be replaces with paragraph
#         tags, rather than break tags.
#         clean -- If True, html will be run through a cleanup_html method.
#         tag_data -- An optional dictionary to store tag data in. The default of
#         None will create a dictionary internally.
# 
#     """
#     return _postmarkup(bbcode,
#                        encoding,
#                        exclude_tags=exclude_tags,
#                        auto_urls=auto_urls,
#                        paragraphs=paragraphs,
#                        clean=clean,
#                        tag_data=tag_data)


import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from dinette.libs.postmarkup import render_bbcode
# encoding: utf-8


class Migration(DataMigration):

    def forwards(self, orm):
        "Write your forwards methods here."
        for reply in orm.Reply.objects.all():
            # migrate older bbcode replies to markup

# Path: dinette/libs/postmarkup.py
# def render_bbcode(bbcode,
#                   encoding="ascii",
#                   exclude_tags=None,
#                   auto_urls=True,
#                   paragraphs=False,
#                   clean=True,
#                   tag_data=None):
# 
#     """ Renders a bbcode string in to XHTML. This is a shortcut if you don't
#         need to customize any tags.
# 
#         post_markup -- String containing bbcode.
#         encoding -- Encoding of string, defaults to "ascii" if the string is not
#         already unicode.
#         exclude_tags -- A collection of tag names to ignore.
#         auto_urls -- If True, then urls will be wrapped with url bbcode tags.
#         paragraphs -- If True then line breaks will be replaces with paragraph
#         tags, rather than break tags.
#         clean -- If True, html will be run through a cleanup_html method.
#         tag_data -- An optional dictionary to store tag data in. The default of
#         None will create a dictionary internally.
# 
#     """
#     return _postmarkup(bbcode,
#                        encoding,
#                        exclude_tags=exclude_tags,
#                        auto_urls=auto_urls,
#                        paragraphs=paragraphs,
#                        clean=clean,
#                        tag_data=tag_data)


# Path: dinette/migrations/0010_migrate_reply_markup.py
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from dinette.libs.postmarkup import render_bbcode

# encoding: utf-8


class Migration(DataMigration):

    def forwards(self, orm):
        "Write your forwards methods here."
        for reply in orm.Reply.objects.all():
            # migrate older bbcode replies to markup

            reply._message_rendered = render_bbcode(reply.message.raw)