<filename>hr_platform/registrations/models.py
from __future__ import unicode_literals

from django.db import models
from hr_platform.persons.models import *
from hr_platform.locations.models import Location, SDC
from django.utils.translation import ugettext as _
from model_utils import Choices
from model_utils.models import TimeStampedModel
from django.conf import settings


class Registration(TimeStampedModel):

    district = models.ForeignKey(
        Location,
        blank=False,
        null=True,
        related_name='+',
        verbose_name=_('District')
    )

    sdc_name = models.ForeignKey(
        SDC,
        blank=False,
        null=True,
        related_name='+',
        verbose_name=_('SDC')
    )

    branch = models.ForeignKey(
        Branch,
        blank=False,
        null=True,
        related_name='+',
        verbose_name=_('Branch')
    )

    person = models.ForeignKey(
        Person,
        blank=False,
        null=True,
        related_name='registrations',
        verbose_name=_('Person')
    )

    position = models.ForeignKey(
        Position,
        blank=False,
        null=True,
        related_name='+',
        verbose_name=_('Position')
    )

    department = models.ForeignKey(
        Department,
        blank=False,
        null=True,
        related_name='+',
        verbose_name=_('Department')
    )

    status = models.ForeignKey(
        Status,
        blank=False,
        null=True,
        related_name='+',
        verbose_name=_('Status')
    )

    job_entry_date = models.DateField(
        blank=True,
        null=True,
        verbose_name=_('Job entry date')
    )

    job_start_date = models.DateField(
        blank=True,
        null=True,
        verbose_name=_('Job start date')
    )
    job_end_date = models.DateField(
        blank=True,
        null=True,
        verbose_name=_('Job end date')
    )

    level = models.ForeignKey(
        Level,
        blank=False,
        null=True,
        related_name='+',
        verbose_name=_('Level')
    )

    scale = models.ForeignKey(
        Scale,
        blank=False,
        null=True,
        related_name='+',
        verbose_name=_('Scale')
    )

    certificate = models.ForeignKey(
        Certificate,
        blank=False,
        null=True,
        related_name='+',
        verbose_name=_('Certificate')
    )

    trainings = models.ManyToManyField(
        Training,
        blank=True,
        verbose_name=_('Trainings')
    )

    training_party = models.ForeignKey(
        TrainingParty,
        blank=True,
        null=True,
        related_name='+',
        verbose_name=_('Trainer parties')
    )

    number_trips = models.IntegerField(
        blank=True,
        null=True,
        default=0,
        choices=((x, x) for x in range(0, 101)),
        verbose_name=_('Number of trips')
    )

    annual_leaves = models.IntegerField(
        blank=True,
        null=True,
        default=0,
        choices=((x, x) for x in range(0, 101)),
        verbose_name=_('Annual leaves')
    )

    admin_leaves = models.IntegerField(
        blank=True,
        null=True,
        default=0,
        choices=((x, x) for x in range(0, 101)),
        verbose_name=_('Administrative leaves')
    )

    national_communities = models.ManyToManyField(
        NationalCommunity,
        blank=True,
        related_name='+',
        verbose_name=_('National communities')
    )

    directorates = models.ManyToManyField(
        Directorate,
        blank=True,
        related_name='+',
        verbose_name=_('Directorates')
    )

    sections = models.ManyToManyField(
        Section,
        blank=True,
        related_name='+',
        verbose_name=_('Sections')
    )

    sections_bis = models.ManyToManyField(
        SectionBis,
        blank=True,
        related_name='+',
        verbose_name=_('Sections bis')
    )

    regional_sections = models.ManyToManyField(
        RegionalSection,
        blank=True,
        related_name='+',
        verbose_name=_('Regional sections')
    )

    sections2 = models.ManyToManyField(
        Section2,
        blank=True,
        related_name='+',
        verbose_name=_('Sections2')
    )

    expenditure_of_services = models.TextField(
        null=True,
        blank=True,
        verbose_name=_('Expenditure of services')
    )

    adds_in_projects = models.TextField(
        null=True,
        blank=True,
        verbose_name=_('Adds-in projects')
    )

    class Meta:
        ordering = ['pk']
        verbose_name = _('Registration')
        verbose_name_plural = _('Registrations')

    def __unicode__(self):
        return self.person.__unicode__()
