<s> import datetime <EOL> import django . utils . copycompat as copy <EOL> from django . contrib . auth . models import User <EOL> from django . db import models <EOL> class RevisionableModel ( models . Model ) : <EOL> base = models . ForeignKey ( '<STR_LIT>' , null = True ) <EOL> title = models . CharField ( blank = True , max_length = <NUM_LIT:255> ) <EOL> when = models . DateTimeField ( default = datetime . datetime . now ) <EOL> def __unicode__ ( self ) : <EOL> return u"<STR_LIT>" % ( self . title , self . id , self . base . id ) <EOL> def save ( self , * args , ** kwargs ) : <EOL> super ( RevisionableModel , self ) . save ( * args , ** kwargs ) <EOL> if not self . base : <EOL> self . base = self <EOL> kwargs . pop ( '<STR_LIT>' , None ) <EOL> kwargs . pop ( '<STR_LIT>' , None ) <EOL> super ( RevisionableModel , self ) . save ( * args , ** kwargs ) <EOL> def new_revision ( self ) : <EOL> new_revision = copy . copy ( self ) <EOL> new_revision . pk = None <EOL> return new_revision <EOL> class Order ( models . Model ) : <EOL> created_by = models . ForeignKey ( User ) <EOL> text = models . TextField ( ) <EOL> class TestObject ( models . Model ) : <EOL> first = models . CharField ( max_length = <NUM_LIT:20> ) <EOL> second = models . CharField ( max_length = <NUM_LIT:20> ) <EOL> third = models . CharField ( max_length = <NUM_LIT:20> ) <EOL> def __unicode__ ( self ) : <EOL> return u'<STR_LIT>' % ( self . first , self . second , self . third ) </s>
