2013-05-28 15:20:06 +02:00
|
|
|
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') )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2013-06-30 11:01:12 +02:00
|
|
|
user = models.OneToOneField( User, verbose_name=_("user") )
|
2013-05-28 15:20:06 +02:00
|
|
|
|
|
|
|
# Properties
|
2013-06-30 11:01:12 +02:00
|
|
|
image = models.ImageField( upload_to = musicianPictureName, verbose_name=_("image") )
|
2013-05-28 15:20:06 +02:00
|
|
|
|
2013-06-30 11:01:12 +02:00
|
|
|
instrument = models.CharField( max_length=4, choices=INSTRUMENTS, blank=True, verbose_name=_("instrument") )
|
|
|
|
birthday = models.DateField( null=True, verbose_name=_("birthday") )
|
|
|
|
street = models.CharField( max_length=80, blank=True, verbose_name=_("street") )
|
|
|
|
city = models.CharField( max_length=40, blank=True, verbose_name=_("city") )
|
|
|
|
zip_code = models.IntegerField( null=True, verbose_name=_("zip_code") )
|
2013-05-28 15:20:06 +02:00
|
|
|
|
2013-06-30 11:01:12 +02:00
|
|
|
public_description = models.TextField( blank=True, verbose_name=_("public_description") )
|
2013-06-02 16:00:01 +02:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.user.username
|
2013-05-28 15:20:06 +02:00
|
|
|
|