from django.db import models

from .domaine import Domaine


class Filiere(models.Model):
    """
    Modèle des filières
    """

    class Cols():
        """ Constantes pour les noms de colonnes """

        PK            = 'f_code'
        # relations one-to-one ou many-to-one
        REL_DOMAINE   = 'domaine'


    f_code = models.CharField('code', primary_key=True, max_length=100)
    domaine = models.ForeignKey(Domaine, on_delete=models.SET_NULL, null=True, blank=True)

    def as_dict(self):
        return {
            'id': self.f_code,
            'domaineId': self.domaine_id,
            'code': self.f_code,
            'libelle': self.f_code,
        }
