<s> import datetime <EOL> from django . contrib . auth . models import User <EOL> from django . db import models <EOL> IS_A_CHOICES = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> KNOWLEDGE_CHOICES = ( <EOL> ( '<STR_LIT:0>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:1>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:2>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:3>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:4>' , '<STR_LIT>' ) , <EOL> ) <EOL> CLARITY_CHOICES = ( <EOL> ( '<STR_LIT:0>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:1>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:2>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:3>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:4>' , '<STR_LIT>' ) , <EOL> ) <EOL> YESNO_CHOICES = ( <EOL> ( '<STR_LIT:y>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:n>' , '<STR_LIT>' ) , <EOL> ) <EOL> class Profile ( models . Model ) : <EOL> user = models . OneToOneField ( User ) <EOL> phone = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> organization = models . CharField ( max_length = <NUM_LIT> , blank = True , null = True ) <EOL> is_a = models . CharField ( max_length = <NUM_LIT:16> , choices = IS_A_CHOICES , blank = True ) <EOL> interests = models . TextField ( blank = True ) <EOL> notify = models . BooleanField ( default = False ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> def __unicode__ ( self ) : <EOL> return self . user . username <EOL> class Category ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT> ) <EOL> slug = models . SlugField ( ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> def public_modules ( self ) : <EOL> return self . modules . filter ( is_public = True ) <EOL> class Module ( models . Model ) : <EOL> title = models . CharField ( max_length = <NUM_LIT> ) <EOL> slug = models . SlugField ( ) <EOL> date = models . DateTimeField ( blank = True , null = True ) <EOL> description = models . TextField ( blank = True ) <EOL> content = models . TextField ( blank = True ) <EOL> thumbnail = models . ImageField ( upload_to = '<STR_LIT>' , blank = True , null = True ) <EOL> notes_url = models . URLField ( blank = True ) <EOL> categories = models . ManyToManyField ( Category , related_name = '<STR_LIT>' ) <EOL> is_public = models . BooleanField ( default = False ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , '<STR_LIT:title>' ) <EOL> def __unicode__ ( self ) : <EOL> return self . title <EOL> @ models . permalink <EOL> def get_absolute_url ( self ) : <EOL> return ( '<STR_LIT>' , [ self . slug ] ) <EOL> def related_modules ( self ) : <EOL> qs = Module . objects . exclude ( pk = self . pk ) <EOL> qs = qs . filter ( categories__in = self . categories . all ( ) , is_public = True ) <EOL> return qs . distinct ( ) <EOL> class Completion ( models . Model ) : <EOL> user = models . ForeignKey ( User , related_name = '<STR_LIT>' ) <EOL> module = models . ForeignKey ( Module , related_name = '<STR_LIT>' ) <EOL> timestamp = models . DateTimeField ( default = datetime . datetime . utcnow ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> def __unicode__ ( self ) : <EOL> return u"<STR_LIT>" % ( self . user . username , self . module . title ) <EOL> class Training ( models . Model ) : <EOL> title = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> slug = models . SlugField ( unique = True ) <EOL> date = models . DateField ( ) <EOL> start_time = models . TimeField ( blank = True , null = True ) <EOL> end_time = models . TimeField ( blank = True , null = True ) <EOL> url = models . URLField ( blank = True , <EOL> help_text = "<STR_LIT>" ) <EOL> category = models . CharField ( max_length = <NUM_LIT:255> , blank = True , <EOL> help_text = "<STR_LIT>" ) <EOL> description = models . TextField ( blank = True ) <EOL> module = models . ForeignKey ( Module , related_name = '<STR_LIT>' , blank = True , null = True ) <EOL> is_public = models . BooleanField ( default = False ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> def __unicode__ ( self ) : <EOL> return self . title <EOL> def is_future ( self , today = None ) : <EOL> today = today or datetime . date . today ( ) <EOL> print today , self . date <EOL> return self . date >= today <EOL> class Feedback ( models . Model ) : <EOL> user = models . ForeignKey ( User , related_name = "<STR_LIT>" ) <EOL> module = models . ForeignKey ( Module , related_name = "<STR_LIT>" ) <EOL> knowledge_before = models . CharField ( max_length = <NUM_LIT:1> , choices = KNOWLEDGE_CHOICES ) <EOL> knowledge_after = models . CharField ( max_length = <NUM_LIT:1> , choices = KNOWLEDGE_CHOICES ) <EOL> content_clarity = models . CharField ( max_length = <NUM_LIT:1> , choices = CLARITY_CHOICES ) <EOL> suggestions = models . TextField ( ) <EOL> positives = models . TextField ( ) <EOL> would_recommend = models . CharField ( max_length = <NUM_LIT:1> , choices = YESNO_CHOICES ) <EOL> timestamp = models . DateTimeField ( default = datetime . datetime . utcnow ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> def __unicode__ ( self ) : <EOL> return u"<STR_LIT>" % ( self . user . username , self . module . title ) </s>
