<s> '''<STR_LIT>''' <EOL> from django . db import models <EOL> from django . contrib . auth . models import User <EOL> class UserProfile ( models . Model ) : <EOL> '''<STR_LIT>''' <EOL> user = models . ForeignKey ( User , unique = True ) <EOL> affiliation = models . CharField ( max_length = <NUM_LIT:100> , default = "<STR_LIT>" ) <EOL> def __unicode__ ( self ) : <EOL> try : <EOL> return "<STR_LIT>" % self . user <EOL> except : <EOL> return "<STR_LIT>" <EOL> @ classmethod <EOL> def get_or_create_profile ( cls , user ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> profile = user . get_profile ( ) <EOL> except UserProfile . DoesNotExist : <EOL> profile = cls . objects . create ( <EOL> user = user , <EOL> ) <EOL> return profile </s>
