<s> import uuid <EOL> from quokka . core . db import db <EOL> from quokka . core . models . signature import Publishable <EOL> from quokka . utils . settings import get_setting_value <EOL> class BaseComment ( object ) : <EOL> author_name = db . StringField ( max_length = <NUM_LIT:255> , required = True ) <EOL> author_email = db . StringField ( max_length = <NUM_LIT:255> ) <EOL> body = db . StringField ( required = True ) <EOL> spam = db . BooleanField ( ) <EOL> deleted = db . BooleanField ( ) <EOL> content_format = db . StringField ( <EOL> choices = ( '<STR_LIT>' , ) , <EOL> default = "<STR_LIT>" <EOL> ) <EOL> @ property <EOL> def gravatar_email ( self ) : <EOL> if self . created_by : <EOL> return self . created_by . email <EOL> return self . author_email <EOL> class Reply ( Publishable , BaseComment , db . EmbeddedDocument ) : <EOL> uid = db . StringField ( ) <EOL> parent = db . StringField ( ) <EOL> def clean ( self ) : <EOL> if not self . uid : <EOL> self . uid = str ( uuid . uuid4 ( ) ) <EOL> class Comment ( Publishable , BaseComment , db . Document ) : <EOL> path = db . StringField ( max_length = <NUM_LIT:255> , required = True ) <EOL> replies = db . ListField ( db . EmbeddedDocumentField ( Reply ) ) <EOL> def __unicode__ ( self ) : <EOL> return u"<STR_LIT>" . format ( self . author_name , self . body [ : <NUM_LIT:15> ] ) <EOL> def get_canonical_url ( self ) : <EOL> return "<STR_LIT>" . format ( <EOL> self . path , get_setting_value ( '<STR_LIT>' , '<STR_LIT:html>' ) <EOL> ) if not self . path . startswith ( "<STR_LIT:/>" ) else self . path <EOL> meta = { <EOL> "<STR_LIT>" : [ '<STR_LIT>' ] , <EOL> "<STR_LIT>" : [ '<STR_LIT>' , '<STR_LIT:path>' ] <EOL> } </s>
