from django.db import models from django.contrib.auth.models import User from django.utils.translation import ugettext as _ import os INSTRUMENTS = ( ('TR', _('Trumpet') ), ('TRB', _('Trombone') ), ('EUPH',_('Euphonium') ), ('TUBA',_('Tuba') ) ) class PhoneNumber( models.Model ): user = models.OneToOneField( User ) desc = models.CharField( max_length=15 ) number = models.CharField( max_length=25 ) def musicianPictureName( musician, originalName ): fileExtension = os.path.splitext(originalName)[1] return "user_images/" + musician.user.username + fileExtension class Musician( models.Model ): # Link to user object, contains first name and last name user = models.OneToOneField( User ) # Properties image = models.ImageField( upload_to = musicianPictureName ) instrument = models.CharField( max_length=4, choices=INSTRUMENTS, blank=True ) birthday = models.DateField( null=True ) street = models.CharField( max_length=80, blank=True ) city = models.CharField( max_length=40, blank=True ) zip_code = models.IntegerField( null=True) public_description = models.TextField( blank=True ) def __unicode__(self): return self.user.username