class NativeLanguage(models.Model): user = models.OneToOneField(User, related_name='native_languages', on_delete=models.CASCADE) native_language = LanguageField(_('Native Language'), blank=True) second_native_language = LanguageField(_('Second Native Language'), blank=True) third_native_language = LanguageField(_('Third Native Language'), blank=True) fourth_native_language = LanguageField(_('Fourth Native Language'), blank=True)
class LanguageInfo(models.Model): ''' A model that stores all supported languages This code is for internal use (url & comparison), mostly compatiple with ISO 639-1, with a few exceptions. All lowercase. Desh seperated (if any) ''' code = LanguageField() # store 'none' if not available google_code = models.CharField(_('Google Translate Code'), max_length=10, blank=True) bing_code = models.CharField(_('Bing Translator Code'), max_length=10, blank=True) baidu_code = models.CharField(_('Baidu Fanyi Code'), max_length=10, blank=True) TRANSLATION_ENGINE_CHOICES = ( ('google', _('Google Translate')), ('bing', _('Bing Translator')), ('baidu', _('Baidu Fanyi')), ) default_translation_engine = models.CharField( max_length=6, choices=TRANSLATION_ENGINE_CHOICES, default='bing') def __str__(self): return self.code def get_audio_accent_choices(self): lang_code = self.code if lang_code == 'zh-hans' or lang_code == 'zh-hant': return (('cn', _('Mainland Mandarin')), ('tw', _('Taiwanese Mandarin'))) elif lang_code == 'es': return (('es', _('Spain')), ('la', _('Latin America')), ('ar', _('Argentina'))) elif lang_code == 'en': return (('uk', _('British')), ('us', _('North American'))) elif lang_code == 'fr': return (('fr', _('Parisian')), ('qc', _('Québécois')), ('af', _('African'))) elif lang_code == 'pt-pt' or lang_code == 'pt-br': return (('br', _('Brazil')), ('pt', _('Portugal'))) elif lang_code == 'de': return (('de', _('Germany')), ('aut', _('Austria')), ('che', _('Switzerland'))) elif lang_code == 'ar': arabic_accents = ( # Translators: See: https://en.wikipedia.org/wiki/Varieties_of_Arabic#Regional_varieties ('std', _('Modern Standard')), ('arp', _('Arabian')), ('lvt', _('Levantine')), ('mag', _('Maghrebi')), ('mes', _('Mesopotamian')), ('sud', _('Sudanese')), ('egt', _("Egyptian")), ) return arabic_accents else: return None
class Personal_Information(models.Model): first_name = models.CharField(max_length=128, default='') middle_name = models.CharField(max_length=128, default='', null=True, blank=True) last_name = models.CharField(max_length=128, default='') dob = models.DateField() sex = models.CharField(choices=GENDER_CHOICES, max_length=32, default='Blank') race = models.CharField(choices=RACE_CHOICES, max_length=64, default='Blank') ethnicity = models.CharField(choices=ETHNICITY_CHOICES, max_length=64, default='Blank') language = LanguageField(default='en') country = CountryField(blank_label='',default='US') ssn = USSocialSecurityNumberField(null=True, blank=True, help_text='XXX-XX-XXXX') address = models.CharField(max_length=128,default='') city = models.CharField(max_length=128,default='') state = USStateField(default='') zip = models.IntegerField(default='') home_phone = PhoneNumberField(help_text='XXX-XXX-XXXX') cell_phone = PhoneNumberField(null=True, blank=True, help_text='XXX-XXX-XXXX') email = models.EmailField(null=True, blank=True) call_pref = models.CharField(choices=CALL_PREF_CHOICES, max_length=10, default='Home') written_pref = models.CharField(choices=WRITTEN_PREF_CHOICES, max_length=12, default='Post') emp_status = models.CharField(choices=EMP_STATUS_CHOICES, max_length=64, default='Blank') #Account Information chart_no = models.AutoField(primary_key=True) date_registered = models.DateField(default=timezone.now) account_type = models.CharField(choices=ACCOUNT_TYPE_CHOICES, max_length=64, default='Blank') account_status = models.CharField(choices=ACCOUNT_STATUS_CHOICES, max_length=64, default='Current') sign = models.CharField(choices=SIGN_CHOICES, max_length=3, default='Yes') audit_log = AuditLog() def __unicode__(self): return self.first_name+' '+self.last_name
class News(TimeStampedModel): headline = models.CharField(verbose_name=_('Headline'), max_length=255) content = models.TextField(verbose_name=_('Content')) publication_date = models.DateField(verbose_name=_('Publication Date')) language = LanguageField() def __str__(self): return self.headline class Meta: verbose_name = _('News') verbose_name_plural = _('News')
class Provider(models.Model): """ A service provider """ ## Fields ## name = models.CharField(max_length=128) email = models.EmailField() # assuming international number, not specific format phone = models.CharField(max_length=16) language = LanguageField() # https://en.wikipedia.org/wiki/ISO_4217 currency = models.CharField(max_length=3) ## Methods ## def __unicode__(self): return u'%s' % self.name
class ResourceLanguage(models.Model): """ Une langue utilisée dans une ou plusieurs resources répertoriées """ code = LanguageField() @staticmethod def get_mycurrent(): "Retourne la langue actuellement utilisée pour la session en cours" code = get_language().split('-')[0] language, created = ResourceLanguage.objects.get_or_create(code=code) return language def __unicode__(self): "Retourne le nom de la langue" return self.get_code_display()
class Guarantor_Information(models.Model): patient = models.ForeignKey(Personal_Information) relation = models.CharField(choices=RELATION_CHOICES,max_length=128) #If relation is self, auto fill rest of the details first_name = models.CharField(max_length=128, default='') middle_name = models.CharField(max_length=128, default='', null=True, blank=True) last_name = models.CharField(max_length=128, default='') dob = models.DateField() sex = models.CharField(choices=GENDER_CHOICES, max_length=32, default='Blank') race = models.CharField(choices=RACE_CHOICES, max_length=64, default='Blank') ethnicity = models.CharField(choices=ETHNICITY_CHOICES, max_length=64, default='Blank') language = LanguageField(default='en') country = CountryField(blank_label='',default='US') ssn = USSocialSecurityNumberField(null=True, blank=True, help_text='XXX-XX-XXXX') address = models.CharField(max_length=128,default='') city = models.CharField(max_length=128,default='') state = USStateField(default='') zip = models.IntegerField(default='') home_phone = PhoneNumberField(help_text='XXX-XXX-XXXX') def __unicode__(self): return self.patient+' '+self.relation
class Article(EncryptedIDModel): user = models.ForeignKey(User, related_name='articles', blank=True, null=True, on_delete=models.SET_NULL) language = LanguageField(_('Language')) title = models.CharField(_('Title'), max_length=200) DIFFICULTY_CHOICES = ( ('A1', _('A1 - Beginner')), ('A2', _('A2 - Elementary')), ('B1', _('B1 - Intermediate')), ('B2', _('B2 - Upper Intermediate')), ('C1', _("C1 - Advanced")), ('C2', _("C2 - Mastery")), ) difficulty = models.CharField(_('Level of Difficulty'), max_length=2, choices=DIFFICULTY_CHOICES) body = models.TextField(_('Text Body'), max_length=30000) pronunciation = models.TextField( _('Pronunciation Marks'), max_length=240000, blank=True, help_text='Pinyin, Furigana, Romanisation, etc.') audio = models.FileField( _('Audio File'), blank=True, null=True, help_text=_("An audio narration for this exact text.")) allow_comments = models.BooleanField( _('Allow Comments'), default=True, ) private = models.BooleanField( _('Make Private'), default=False, help_text= _('Please share your article so that other people can benefit. At the same time, please do not share copyrighted content without consent by its owner.' )) anonymous = models.BooleanField( _('Share Anonymously'), default=False, ) flagged = models.BooleanField( _('Flagged'), default=False, ) audio_accent = models.CharField( _('Audio Accent'), max_length=10, blank=True, help_text= _("Please briefly describe the accent of the audio, eg. 'American English', 'Mexican Spanish', etc." )) script_type = models.CharField(_('Script Type'), max_length=10, blank=True) tags = TaggableManager( blank=True, help_text= _('Please add tags <em>only in this language</em> so that you can practise your vocabulary and other peope can understand you. Seperate each tag with a comma.' )) author = models.CharField(_('Text Author'), blank=True, max_length=70) narrator = models.CharField(_('Audio Narrator'), blank=True, max_length=70) text_source_url = models.URLField(_('Text Source URL'), blank=True) audio_source_url = models.URLField(_('Audio Source URL'), blank=True) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) def __str__(self): return self.title def get_absolute_url(self): return reverse('learn:article_detail', kwargs={ 'language': self.language, 'ekey': self.ekey })
class UserReferencePreference(models.Model): user = models.ForeignKey(User, related_name='ref_prefs', blank=True, null=True, on_delete=models.CASCADE) language = LanguageField(_('Language')) # limit this to user's target languages ref_1_link = models.URLField(_('Reference 1 URL'), blank=True) ref_2_link = models.URLField(_('Reference 2 URL'), blank=True) ref_3_link = models.URLField(_('Reference 3 URL'), blank=True) ref_4_link = models.URLField(_('Reference 4 URL'), blank=True) ref_5_link = models.URLField(_('Reference 5 URL'), blank=True) ref_6_link = models.URLField(_('Reference 6 URL'), blank=True) display_pinyin = models.BooleanField( _('Display Pinyin'), default=True, ) display_furigana = models.BooleanField( _('Display Furigana'), default=True, ) display_ipa = models.BooleanField( _('Display IPA'), default=True, ) display_romanisation = models.BooleanField( _('Display Romanisation'), default=True, ) display_phonetic_spelling = models.BooleanField( _('Display Phonetic Spelling'), default=True, ) display_hanzi = models.BooleanField( _('Display Chinese Characters'), default=True, ) autoplay_pronunciation = models.BooleanField( _('Autoplay Pronunciation'), default=True, ) FONT_SIZE_CHOICES = ( ('sm', _('Small')), ('rg', _('Regular')), ('lg', _('Large')), ('xl', _('Extra-Large')), ) font_size = models.CharField(max_length=2, choices=FONT_SIZE_CHOICES, default='rg') # font_family = # insert_image = # translation_engine = '''
class User(AbstractUser): name = models.CharField( _('Name'), blank=True, max_length=30, help_text=_('Please enter your real name. 30 characters or fewer.')) # Custom user fields GENDER_CHOICES = ( ('M', _('Male')), ('F', _('Female')), ('O', _('Other')), ) gender = models.CharField(_('Gender'), max_length=1, choices=GENDER_CHOICES, blank=True) birthday = models.DateField(_('Birthday'), null=True, blank=True) place_of_origin = CountryField(_('Country/Region of Origin'), blank=True) current_residence = CountryField(_('Current Residence'), blank=True, help_text=_('If different from above.')) skype_id = models.CharField(_('Skype ID'), max_length=256, blank=True) EDUCATION_CHOICES = ( ('XIAO', _('Elementary School or Below')), ('ZHONG', _('Middle School')), ('GAO', _('High School or Equivalent')), ('XUE', _("Undergrad or Equivalent")), ('SHUO', _("Master's Degree")), ('BO', _("Doctoral Degree or above")), ) OCUPATION_CHOICES = ( ('student', _('Student')), ('worker', _('Office Worker')), ('teacher', _('Tutor/Teacher/Professor')), ('manager', _('Business Administration')), ('unemployed', _('Housewife/Househusband')), ('server', _('Restaurant/Hotel/Service')), ('seller', _('Retail/Merchant/Wholesale')), ('farmer', _("Agricultural/Forestry/Fishery")), ('officer', _('Police/Firefighter/Security')), ('health', _('Doctor/Nurse/Health Worker')), ('official', _('Government/NGO')), ('manufacturer', _("Manufacturing/Construction")), ('engineer', _('Engineering')), ('entertainer', _('Media/Entertainment')), ('designer', _('Designer/Artist/Craftsperson')), ('writer', _('Author/Scholar/Scientist')), ('soldier', _("Military")), ('entrepreneur', _('Entrepreneur/Freelancer/Self-Employed')), ('other', _('Other')), ) education = models.CharField(_('Education'), max_length=6, choices=EDUCATION_CHOICES, blank=True) occupation = models.CharField(_('Occupation'), max_length=14, choices=EDUCATION_CHOICES, blank=True) personal_slogan = models.CharField(_('Personal Slogan'), max_length=60, blank=True) self_introduction = models.CharField(_('Self Introduction'), max_length=254, blank=True) native_language = LanguageField(_('Native Language'), blank=True) second_native_language = LanguageField(_('Second Native Language'), blank=True) third_native_language = LanguageField(_('Third Native Language'), blank=True) all_native_languages = [ native_language, second_native_language, third_native_language ] user_native_languages = [] target_language_1 = LanguageField(_('Target Language 1'), blank=True) target_language_2 = LanguageField(_('Target Language 2'), blank=True) target_language_3 = LanguageField(_('Target Language 3'), blank=True) target_language_4 = LanguageField(_('Target Language 4'), blank=True) target_language_5 = LanguageField(_('Target Language 5'), blank=True) target_language_6 = LanguageField(_('Target Language 6'), blank=True) target_language_7 = LanguageField(_('Target Language 7'), blank=True) target_language_8 = LanguageField(_('Target Language 8'), blank=True) target_language_9 = LanguageField(_('Target Language 9'), blank=True) target_language_10 = LanguageField(_('Target Language 10'), blank=True) target_language_11 = LanguageField(_('Target Language 11'), blank=True) target_language_12 = LanguageField(_('Target Language 12'), blank=True) target_language_13 = LanguageField(_('Target Language 13'), blank=True) target_language_14 = LanguageField(_('Target Language 14'), blank=True) target_language_15 = LanguageField(_('Target Language 15'), blank=True) target_language_16 = LanguageField(_('Target Language 16'), blank=True) all_target_languages = [ target_language_1, target_language_2, target_language_3, target_language_4, target_language_5, target_language_6, target_language_7, target_language_8, target_language_9, target_language_10, target_language_11, target_language_12, target_language_13, target_language_14, target_language_15, target_language_16 ] user_target_languages = [] FLUENCY_CHOICES = ( ('A1', _('A1 - Beginner')), ('A2', _('A2 - Elementary')), ('B1', _('B1 - Intermediate')), ('B2', _('B2 - Upper Intermediate')), ('C1', _("C1 - Advanced")), ('C2', _("C2 - Mastery")), ) fluency_1 = models.CharField(_('Level of Fluency (1)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_1 = LanguageField( _('Primary Language (1)'), blank=True, help_text= _('This is the language into which your target language 1 will be translated. The default is your first native language.' )) fluency_2 = models.CharField(_('Level of Fluency (2)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_2 = LanguageField( _('Primary Language (2)'), blank=True, help_text= _('This is the language into which your target language 2 will be translated. The default is your first native language.' )) fluency_3 = models.CharField(_('Level of Fluency (3)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_3 = LanguageField( _('Primary Language (3)'), blank=True, help_text= _('This is the language into which your target language 3 will be translated. The default is your first native language.' )) fluency_4 = models.CharField(_('Level of Fluency (4)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_4 = LanguageField( _('Primary Language (4)'), blank=True, help_text= _('This is the language into which your target language 4 will be translated. The default is your first native language.' )) fluency_5 = models.CharField(_('Level of Fluency (5)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_5 = LanguageField( _('Primary Language (5)'), blank=True, help_text= _('This is the language into which your target language 5 will be translated. The default is your first native language.' )) fluency_6 = models.CharField(_('Level of Fluency (6)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_6 = LanguageField( _('Primary Language (6)'), blank=True, help_text= _('This is the language into which your target language 6 will be translated. The default is your first native language.' )) fluency_7 = models.CharField(_('Level of Fluency (7)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_7 = LanguageField( _('Primary Language (7)'), blank=True, help_text= _('This is the language into which your target language 7 will be translated. The default is your first native language.' )) fluency_8 = models.CharField(_('Level of Fluency (8)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_8 = LanguageField( _('Primary Language (8)'), blank=True, help_text= _('This is the language into which your target language 8 will be translated. The default is your first native language.' )) fluency_9 = models.CharField(_('Level of Fluency (9)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_9 = LanguageField( _('Primary Language (9)'), blank=True, help_text= _('This is the language into which your target language 9 will be translated. The default is your first native language.' )) fluency_10 = models.CharField(_('Level of Fluency (10)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_10 = LanguageField( _('Primary Language (10)'), blank=True, help_text= _('This is the language into which your target language 10 will be translated. The default is your first native language.' )) fluency_11 = models.CharField(_('Level of Fluency (11)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_11 = LanguageField( _('Primary Language (11)'), blank=True, help_text= _('This is the language into which your target language 11 will be translated. The default is your first native language.' )) fluency_12 = models.CharField(_('Level of Fluency (12)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_12 = LanguageField( _('Primary Language (12)'), blank=True, help_text= _('This is the language into which your target language 12 will be translated. The default is your first native language.' )) fluency_13 = models.CharField(_('Level of Fluency (13)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_13 = LanguageField( _('Primary Language (13)'), blank=True, help_text= _('This is the language into which your target language 13 will be translated. The default is your first native language.' )) fluency_14 = models.CharField(_('Level of Fluency (14)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_14 = LanguageField( _('Primary Language (14)'), blank=True, help_text= _('This is the language into which your target language 14 will be translated. The default is your first native language.' )) fluency_15 = models.CharField(_('Level of Fluency (15)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_15 = LanguageField( _('Primary Language (15)'), blank=True, help_text= _('This is the language into which your target language 15 will be translated. The default is your first native language.' )) fluency_16 = models.CharField(_('Level of Fluency (16)'), max_length=2, choices=FLUENCY_CHOICES, blank=True) primary_language_16 = LanguageField( _('Primary Language (16)'), blank=True, help_text= _('This is the language into which your target language 16 will be translated. The default is your first native language.' )) def __str__(self): return self.username def get_absolute_url(self): return reverse('users:detail', kwargs={'username': self.username}) def calculate_age(self): born = self.birthday today = date.today() return today.year - born.year - ((today.month, today.day) < (born.month, born.day)) def get_target_languages(self): for target_lang in self.all_target_languages: if target_lang: user_target_languages.append(target_lang) return user_target_languages def get_user_languages(self): all_user_languages = [] for native_lang in self.all_native_languages: if native_lang: user_native_languages.append(native_lang) all_user_languages = user_native_languages + self.get_target_languages( ) return all_user_languages
class TargetLanguage(EncryptedIDModel): user = models.ForeignKey(User, related_name='target_languages', on_delete=models.CASCADE) code = LanguageField(_('Language')) FLUENCY_CHOICES = ( ('A1', _('A1 - Beginner')), ('A2', _('A2 - Elementary')), ('B1', _('B1 - Intermediate')), ('B2', _('B2 - Upper Intermediate')), ('C1', _("C1 - Advanced")), ('C2', _("C2 - Mastery")), ) fluency = models.CharField(_('Level of Fluency'), max_length=2, choices=FLUENCY_CHOICES, blank=True) words_read = models.IntegerField(default=0) words_learnt = models.IntegerField(default=0) articles_read = models.IntegerField(default=0) articles_posted = models.IntegerField(default=0) created = models.DateTimeField(_('Initial Timestamp'), auto_now_add=True) updated = models.DateTimeField(_('Last Active Timestamp'), auto_now=True) default_ref_link_1 = models.URLField(blank=True) default_ref_link_2 = models.URLField(blank=True) default_ref_link_3 = models.URLField(blank=True) default_ref_link_4 = models.URLField(blank=True) default_ref_link_5 = models.URLField(blank=True) default_ref_link_6 = models.URLField(blank=True) TRANSLATOR_CHOICES = ( ('bing', _('Bing Translator')), ('google', _('Google Translate')), ('baidu', _('Baidu Fanyi')), ) preferred_translation_engine = models.CharField( _('Preferred Translation Engine'), max_length=6, blank=True, choices=TRANSLATOR_CHOICES) display_pronunciation = models.BooleanField( _('Display Pronunciation Marks'), default=True, ) display_hanzi = models.BooleanField( _('Display Chinese Characters'), default=False, ) autoplay_pronunciation = models.BooleanField( _('Autoplay Pronunciation'), default=True, ) create_flashcards = models.BooleanField( _('Automatically Create Flash Cards'), default=True, ) insert_image = models.BooleanField( _('Automatically Add Images in Your Flash Cards'), default=False, ) IMAGE_POSITION_CHOICES = ( # Translators: The front or back of a flash card ('f', _('Card Front')), ('b', _('Card Back')), ) image_position = models.CharField(max_length=2, choices=IMAGE_POSITION_CHOICES, default='b') FONT_SIZE_CHOICES = ( ('sm', _('Small')), ('de', _('Default')), ('lg', _('Large')), ('xl', _('Extra-Large')), ) font_size = models.CharField(max_length=2, choices=FONT_SIZE_CHOICES, default='de') LINE_SPACING_CHOICES = ( ('de', _('Default')), ('1x', _('Single')), ('2x', _('Double')), ('3x', _('Triple')), ) line_spacing = models.CharField(max_length=2, choices=LINE_SPACING_CHOICES, default='de') # font_family = created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) ''' Example links dict_1_link = "http://www.oxfordlearnersdictionaries.com/definition/english/placeholder?q=placeholder" dict_2_link = "http://www.dictionary.com/browse/placeholder?s=t" dict_3_link = "http://www.thefreedictionary.com/placeholder" ref_img_link = "https://www.google.com/search?q=placeholder&dcr=0&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiAqfac7pLWAhVJxrwKHV29D1UQ_AUICigB&biw=1280&bih=651&gws_rd=cr&ei=0R6xWZKsGsGT8wXOi5N4" ref_wiki_link = "https://en.wikipedia.org/wiki/placeholder" ref_forvo_link = "https://es.forvo.com/search/placeholder/" ''' def __str__(self): return self.code
class User(AbstractUser): name = models.CharField(_('Name'), blank=True, max_length=30, help_text=_('Please enter your real name. 30 characters or fewer.')) # Custom user fields GENDER_CHOICES = ( ('M', _('Male')), ('F', _('Female')), ('O', _('Other')), ) gender = models.CharField(_('Gender'),max_length=1, choices=GENDER_CHOICES, blank=True) birthday = models.DateField(_('Birthday'),null=True, blank=True) native_language = LanguageField(_('Native Language'), blank=True) second_native_language = LanguageField(_('Second Native Language'), blank=True) third_native_language = LanguageField(_('Third Native Language'), blank=True) place_of_origin = CountryField(_('Country/Region of Origin'),blank=True) current_residence = CountryField(_('Current Residence'), blank=True) skype_id = models.CharField(_('Skype ID'),max_length=256, blank=True) EDUCATION_CHOICES = ( ('XIAO', _('Elementary School or Below')), ('ZHONG', _('Middle School')), ('GAO', _('High School or Equivalent')), ('XUE', _("Undergrad or Equivalent")), ('SHUO', _("Master's Degree")), ('BO', _("Doctoral Degree or above")), ) OCUPATION_CHOICES = ( ('student', _('Student')), ('worker', _('Office Worker')), ('teacher', _('Tutor/Teacher/Professor')), ('manager', _('Business Administration')), ('unemployed', _('Housewife/Househusband')), ('server', _('Restaurant/Hotel/Service')), ('seller', _('Retail/Merchant/Wholesale')), ('farmer', _("Agricultural/Forestry/Fishery")), ('officer', _('Police/Firefighter/Security')), ('health', _('Doctor/Nurse/Health Worker')), ('official', _('Government/NGO')), ('manufacturer', _("Manufacturing/Construction")), ('engineer', _('Engineering')), ('entertainer', _('Media/Entertainment')), ('designer', _('Designer/Artist/Craftsperson')), ('writer', _('Author/Scholar/Scientist')), ('soldier', _("Military")), ('entrepreneur', _('Entrepreneur/Freelancer/Self-Employed')), ('other', _('Other')), ) education = models.CharField(_('Education'),max_length=6, choices=EDUCATION_CHOICES, blank=True) occupation = models.CharField(_('Occupation'),max_length=14, choices=EDUCATION_CHOICES, blank=True) personal_slogan = models.CharField(_('Personal Slogan'),max_length=60, blank=True) self_introduction = models.CharField(_('Self Introduction'),max_length=254, blank=True) MEMBERSHIP_CHOICES = ( ('free', _('Free Trial')), ('basic', _('Basic')), ('premium', _('Premium')), ('gold', _('Gold')), ) membership = models.CharField(_('Membership'),max_length=8, choices=MEMBERSHIP_CHOICES ,default='free') def __str__(self): return self.username def get_absolute_url(self): return reverse('users:detail', kwargs={'username': self.username}) def calculate_age(self): if self.birthday: born = self.birthday today = date.today() return today.year - born.year - ((today.month, today.day) < (born.month, born.day)) else: return None