<s> from datetime import datetime <EOL> from blog . models import Blog , Post <EOL> from minicms . models import Page <EOL> from django . db import models <EOL> from redirects . models import Redirect <EOL> def migrate_v2 ( ) : <EOL> Page . _meta . get_field ( '<STR_LIT>' ) . default = lambda : datetime . now ( ) <EOL> for page in Page . objects . all ( ) : <EOL> page . save ( ) <EOL> def migrate_v3 ( ) : <EOL> Blog . add_to_class ( '<STR_LIT>' , models . CharField ( '<STR_LIT>' , max_length = <NUM_LIT:200> ) ) <EOL> for blog in Blog . objects . all ( ) : <EOL> blog . url = '<STR_LIT>' + blog . base_url <EOL> blog . save ( ) <EOL> Post . _meta . get_field ( '<STR_LIT>' ) . auto_now = False <EOL> for post in Post . objects . all ( ) : <EOL> if post . url and post . published_on and '<STR_LIT:/>' not in post . url : <EOL> post . url = post . blog . url_prefix + '<STR_LIT>' % ( post . published_on . year , post . published_on . month ) + post . url <EOL> post . save ( ) <EOL> Page . _meta . get_field ( '<STR_LIT>' ) . auto_now = False <EOL> for page in Page . objects . all ( ) : <EOL> page . save ( ) <EOL> def migrate_v4 ( ) : <EOL> Page . _meta . get_field ( '<STR_LIT>' ) . auto_now = False <EOL> for page in Page . objects . all ( ) : <EOL> page . published = True <EOL> page . save ( ) <EOL> def migrate_v5 ( ) : <EOL> resave_content ( ) <EOL> def resave_content ( ) : <EOL> for post in Post . objects . all ( ) : <EOL> post . save ( ) <EOL> for page in Page . objects . all ( ) : <EOL> page . save ( ) <EOL> class DjangoRedirect ( models . Model ) : <EOL> __module__ = '<STR_LIT>' <EOL> old_path = models . CharField ( max_length = <NUM_LIT:200> ) <EOL> new_path = models . CharField ( max_length = <NUM_LIT:200> , blank = True ) <EOL> class Meta : <EOL> db_table = '<STR_LIT>' <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . old_path , self . new_path ) <EOL> def migrate_redirects ( ) : <EOL> for redirect in DjangoRedirect . objects . all ( ) : <EOL> Redirect ( redirect_from = redirect . old_path , redirect_to = redirect . new_path ) . save ( ) </s>
