django-depts / depts / scholars /

Full commit
# -*- coding: utf-8 -*-

# django
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.db.models import (CharField, EmailField, ForeignKey, IntegerField,
                              OneToOneField, TextField)
from django.utils.translation import ugettext_lazy as _

# 3rd-party
from autoslug.fields import AutoSlugField
from base.models import TrackedModel

class Scholar(TrackedModel):
    "Person's academic profile."

    # учёные степени
        ('m', _('Master of Arts')),
        ('c', _('Candidate of Science')), # u'кандидат наук'
        ('d', _('Ph.D.')),                  # u'доктор наук'
    # учёные звания
        ('d', _('associate professor')),  # u'доцент'
        ('p', _('professor')),            # u'профессор'
    # номенклатура кандидатов и докторов наук
        _('Biological Sciences'),
        _('Military Sciences'),
        _('Geographical Sciences'),
        _('Geological and Mineralogical Sciences'),
        _('Historical Sciences'),
        _('Medical Sciences'),
        _('Political Sciences'),
        _('Psychological Science'),
        _('Agricultural Sciences'),
        _('Technical Sciences'),
        _('Pharmaceutical Sciences'),
        _('Physical and Mathematical Sciences'),
        _('Chemical Sciences'),
        _('Economic Sciences'),

    first_name = CharField(_('first name'), max_length=150)
    mid_name   = CharField(_('middle name'), max_length=150, blank=True, null=True)
    last_name  = CharField(_('last name'), max_length=150)

    slug = AutoSlugField(populate_from='last_name', unique=True, editable=True, blank=True)

    # academic info
    academic_degree = CharField(_('academic degree'), max_length=1, blank=True,
    academic_field = IntegerField(_('academic field'), max_length=1, blank=True,
                                  null=True, choices=ACADEMIC_FIELD_CHOICES,
                                  help_text=_('makes sense only with degree'))
    academic_title = CharField(_('academic title'), max_length=1, blank=True,
    honor_title = CharField(_('honor title'), max_length=200, blank=True)
    publications = TextField(_('publications'), blank=True)
    consulting_schedule = CharField(_('consulting schedule'), max_length=200, blank=True)
    consulting_topics = TextField(_('scientific advisor on'), blank=True,
                                  help_text=_('possible topics of graduate works'))

    # optional contact information
    email = EmailField(blank=True)

    # optional link to auth
    user = OneToOneField(User, blank=True, null=True)

    class Meta:
        unique_together = ('first_name', 'last_name')
        ordering = ('last_name', 'first_name')
        verbose_name, verbose_name_plural = _('scholar'), _('scholars')

    def __unicode__(self):

    def get_absolute_url(self):
        return reverse('scholars-scholar-detail', kwargs={'slug': self.slug})

    def name(self):
        return ' '.join([self.last_name, self.first_name, self.mid_name])

    def degree(self):
        if self.academic_degree and self.academic_field:
            return _('%(degree)s in %(field)s') % {'degree': self.get_academic_degree_display(),
                                                   'field': self.get_academic_field_display()}
        return self.academic_degree

    def get_academic_props(self):
        return ', '.join([x for x in,
                                     self.honor_title  if x])

    def get_email(self):
        return or (self.user and or None

    def get_positions_count(self):
        return self.positions.count()
    get_positions_count.short_description = _('Total positions')