Last active
January 12, 2020 01:57
-
-
Save walison17/4c8eb57fea87912d606eff509b52fd02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date | |
from django.db import models | |
class EmpresaContratada(models.Model): | |
nome_empresa = models.CharField(max_length=50, blank=False, null=True) | |
contrato_sap = models.CharField(max_length=20, blank=False, null=True) | |
data_inicio_contrato = models.DateField(blank=False, null=True) | |
data_termino_contrato = models.DateField(blank=False, null=True) | |
slug = models.SlugField(max_length=50, blank=False, null=True, unique=True, default='page-slug') | |
@property | |
def status(self): | |
if self.data_termino_contrato > date.today(): | |
return 'Contrato Vigente' | |
else: | |
return 'Contrato Inativo' | |
def __str__(self): | |
return self.nome_empresa | |
def save(self, *args, **kwargs): | |
if not self.id: | |
self.slug = uuid4() | |
super().save(*args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment