<s> from django . conf import settings <EOL> from django_localflavor_us . models import USStateField <EOL> from django . core . files . storage import get_storage_class <EOL> from django . db import models <EOL> from django . utils . functional import LazyObject <EOL> from easy_thumbnails . fields import ThumbnailerImageField <EOL> class AvatarStorage ( LazyObject ) : <EOL> def _setup ( self ) : <EOL> AVATAR_FILE_STORAGE = getattr ( settings , '<STR_LIT>' , settings . DEFAULT_FILE_STORAGE ) <EOL> self . _wrapped = get_storage_class ( AVATAR_FILE_STORAGE ) ( ) <EOL> avatar_storage = AvatarStorage ( ) <EOL> ADR_TYPES = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> TEL_TYPES = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> EMAIL_TYPES = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> WEBSITE_TYPES = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> SOCNET_TYPES = ( <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> social_net_prefixes = dict ( <EOL> Skype = '<STR_LIT>' , <EOL> Twitter = '<STR_LIT>' , <EOL> LinkedIn = '<STR_LIT>' , <EOL> Facebook = '<STR_LIT>' , <EOL> Pinterest = '<STR_LIT>' , <EOL> ) <EOL> class ContactGroup ( models . Model ) : <EOL> user = models . ForeignKey ( settings . AUTH_USER_MODEL ) <EOL> name = models . CharField ( max_length = "<STR_LIT>" , verbose_name = '<STR_LIT>' ) <EOL> class Meta : <EOL> unique_together = ( '<STR_LIT:user>' , '<STR_LIT:name>' ) <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> class Contact ( models . Model ) : <EOL> group = models . ForeignKey ( ContactGroup , related_name = '<STR_LIT>' ) <EOL> last_name = models . CharField ( max_length = "<STR_LIT>" , blank = False ) <EOL> first_name = models . CharField ( max_length = "<STR_LIT>" , blank = False ) <EOL> middle_name = models . CharField ( max_length = "<STR_LIT>" , blank = True ) <EOL> title = models . CharField ( max_length = "<STR_LIT>" , blank = True ) <EOL> organization = models . CharField ( max_length = "<STR_LIT:100>" , blank = True ) <EOL> url = models . URLField ( blank = True ) <EOL> blurb = models . TextField ( null = True , blank = True ) <EOL> profile_image = ThumbnailerImageField ( upload_to = "<STR_LIT>" , blank = True , null = True ) <EOL> qr_image = models . ImageField ( upload_to = "<STR_LIT>" , blank = True , null = True ) <EOL> twitter_handle = models . CharField ( max_length = "<STR_LIT>" , blank = True , null = True ) <EOL> order = models . IntegerField ( blank = False , null = False , default = <NUM_LIT:0> , <EOL> help_text = '<STR_LIT>' ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( Contact , self ) . __init__ ( * args , ** kwargs ) <EOL> self . profile_image . storage = avatar_storage <EOL> self . profile_image . thumbnail_storage = avatar_storage <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . first_name , self . last_name ) <EOL> class Address ( models . Model ) : <EOL> contact = models . ForeignKey ( Contact , related_name = '<STR_LIT>' ) <EOL> street = models . CharField ( max_length = "<STR_LIT>" ) <EOL> city = models . CharField ( max_length = "<STR_LIT>" ) <EOL> state = USStateField ( ) <EOL> zip = models . CharField ( max_length = "<STR_LIT>" ) <EOL> type = models . CharField ( max_length = "<STR_LIT>" , choices = ADR_TYPES ) <EOL> public_visible = models . BooleanField ( default = False ) <EOL> contact_visible = models . BooleanField ( default = False ) <EOL> def __unicode__ ( self ) : <EOL> return '<STR_LIT>' % ( self . contact . first_name , self . contact . last_name , self . street , self . city , self . state ) <EOL> class PhoneNumber ( models . Model ) : <EOL> contact = models . ForeignKey ( Contact , related_name = '<STR_LIT>' ) <EOL> phone = models . CharField ( max_length = "<STR_LIT>" ) <EOL> type = models . CharField ( max_length = "<STR_LIT>" , choices = TEL_TYPES ) <EOL> public_visible = models . BooleanField ( default = False ) <EOL> contact_visible = models . BooleanField ( default = False ) <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . contact . first_name , self . contact . last_name , self . phone ) <EOL> class Email ( models . Model ) : <EOL> contact = models . ForeignKey ( Contact , related_name = '<STR_LIT>' ) <EOL> email = models . EmailField ( ) <EOL> type = models . CharField ( max_length = "<STR_LIT>" , choices = EMAIL_TYPES ) <EOL> public_visible = models . BooleanField ( default = False ) <EOL> contact_visible = models . BooleanField ( default = False ) <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . contact . first_name , self . contact . last_name , self . email ) <EOL> class Website ( models . Model ) : <EOL> contact = models . ForeignKey ( Contact , related_name = '<STR_LIT>' ) <EOL> website = models . URLField ( blank = True ) <EOL> name = models . CharField ( max_length = "<STR_LIT>" , blank = True ) <EOL> type = models . CharField ( max_length = "<STR_LIT>" , choices = WEBSITE_TYPES ) <EOL> public_visible = models . BooleanField ( default = False ) <EOL> contact_visible = models . BooleanField ( default = False ) <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . contact . first_name , self . type , self . website ) <EOL> class SocialNetwork ( models . Model ) : <EOL> contact = models . ForeignKey ( Contact , related_name = '<STR_LIT>' ) <EOL> handle = models . CharField ( max_length = "<STR_LIT>" ) <EOL> type = models . CharField ( max_length = "<STR_LIT>" , choices = SOCNET_TYPES ) <EOL> public_visible = models . BooleanField ( default = False ) <EOL> contact_visible = models . BooleanField ( default = False ) <EOL> @ property <EOL> def url ( self ) : <EOL> prefixes = social_net_prefixes <EOL> prefix = getattr ( settings , '<STR_LIT>' % self . type . upper ( ) , prefixes [ self . type ] ) <EOL> return '<STR_LIT>' % ( prefix , self . handle ) <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . contact . first_name , self . type , self . handle ) </s>
