Ejemplo n.º 1
0
class User(AbstractBaseUser, PermissionsMixin):
    ci = models.CharField(_('Cedula'),
                          max_length=8,
                          blank=False,
                          null=False,
                          unique=True)
    name = models.CharField(_('Nombres'),
                            max_length=50,
                            blank=False,
                            null=False)
    last_name = models.CharField(_('Apellidos'),
                                 max_length=50,
                                 blank=False,
                                 null=False)
    email = models.EmailField(_('Correo Electronico'),
                              null=False,
                              blank=False,
                              unique=True)

    # user
    uuid = models.CharField(_("Uuid"), max_length=50, null=True, blank=True)
    change_pass = models.BooleanField(_("Cambio La Contraseña"), default=False)
    question = models.BooleanField(_("Completo Sus Preguntas"), default=False)
    is_active = models.BooleanField(_('Es Activo'), default=True)
    is_staff = models.BooleanField(_('Es Staff'), default=False)
    is_superuser = models.BooleanField(_('Es Super Usuario'), default=False)
    is_delete = models.BooleanField(_('Eliminado'), default=False)
    ip = models.CharField(_('Direccion IP'), max_length=20)
    is_login = models.BooleanField(_('Tiene Una Sesion Activa'), default=False)
    role = models.CharField(_('Rol'),
                            max_length=500,
                            null=True,
                            blank=True,
                            choices=Selects().role())
    level = models.CharField(_('Level'),
                             max_length=50,
                             null=True,
                             blank=True,
                             choices=Selects().level())
    # join
    date_joined = models.DateTimeField(_('Unido Desde'), default=timezone.now)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    history = HistoricalRecords()
    objects = UserManager()
    USERNAME_FIELD = 'email'

    class Meta:
        verbose_name = "Usuario"
        ordering = ('-created_at', )

    def __str__(self):
        return self.email

    def get_full_name(self):
        return f'{self.name} {self.last_name}'

    def get_short_name(self):
        return self.name
Ejemplo n.º 2
0
class Account(models.Model):
    id = models.UUIDField(default=uuid.uuid4,
                          editable=False,
                          unique=True,
                          primary_key=True)
    type_document = models.CharField(_('Tipo De Documento'),
                                     max_length=2,
                                     null=False,
                                     blank=False,
                                     choices=Selects().type_document_user())
    document = models.CharField(_('Documento'),
                                max_length=15,
                                null=False,
                                blank=False,
                                unique=True,
                                validators=[user_exists])
    name = models.CharField(_('Nombres'),
                            max_length=50,
                            null=False,
                            blank=False)
    last_name = models.CharField(_('Apellidos'),
                                 max_length=50,
                                 null=False,
                                 blank=False)
    sex = models.CharField(_('Sexo'), max_length=15, choices=Selects().sex())
    tlf = models.CharField(_('Telefono'), max_length=15, null=True, blank=True)
    tlf_house = models.CharField(_('Telefono Casa'),
                                 max_length=15,
                                 null=True,
                                 blank=True)
    birthday = models.DateField(null=True,
                                blank=True,
                                verbose_name=_('Fecha de Nacimiento'))
    address = models.TextField(_('Dirección'), null=False, blank=False)
    is_active = models.BooleanField(default=True, verbose_name=_('Activo'))

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ('-created_at', )

    def __str__(self):
        return self.name

    def get_document(self):
        return f'{self.type_document}-{self.document}'

    def get_full_name(self):
        return f'{self.name} {self.last_name}'

    def get_short_name(self):
        return self.name

    def age(self):
        return int((datetime.now().date() - self.birthday).days / 365.25)
Ejemplo n.º 3
0
class Inspection(models.Model):
    id = models.UUIDField(
        default=uuid.uuid4, editable=False, unique=True, primary_key=True)
    company_account_type = models.ForeignKey(
        ContentType, on_delete=models.CASCADE)
    company_account_id = models.UUIDField()
    company_account = GenericForeignKey(
        'company_account_type', 'company_account_id')
    date = models.DateField(verbose_name=_('Fecha de la Inspección'))
    result = models.CharField(
        max_length=15, choices=Selects().inspection_result(),
        verbose_name=_('Resultados'))
    next_date = models.DateField(verbose_name=_(
        'Fecha de la siguiente Inspección'))
    notes = models.TextField(null=True, blank=True,
                             verbose_name=_('Observaciones'))
    pass_inspection = models.BooleanField(default=False)
    account_register = models.ForeignKey(authentication.User, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ('-created_at',)

    def __str__(self):
        return str(self.company_account)
Ejemplo n.º 4
0
class Lagoon(models.Model):
    id = models.UUIDField(
        default=uuid.uuid4, editable=False, unique=True, primary_key=True)

    producion_unit = models.ForeignKey(
        ProductionUnit, on_delete=models.CASCADE)

    lagoon_diameter = models.FloatField(
        _("Ancho de la Laguna"), blank=False, null=False)

    lagoon_deepth = models.FloatField(
        _("Largo de la Laguna "), blank=False, null=False)

    lagoon_height = models.FloatField(
        _('Altura De La Laguna'), blank=False, null=False)

    lagoon_type = models.CharField(_('Tipo De Laguna'),
                                   max_length=30, blank=False, null=False)

    total_area_mirror_guater = models.FloatField(
        _("Area total de Terreno"), blank=True, null=True)

    sistem_cultivate = models.CharField(
        _("Sistema de Cultivo"), max_length=50, blank=True,
        null=True, choices=Selects().type_cultive())

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return str(self.pk)
Ejemplo n.º 5
0
class Transport(models.Model):
    company_driver_type = models.ForeignKey(
        ContentType, on_delete=models.CASCADE)
    company_driver_id = models.UUIDField()
    company_driver = GenericForeignKey(
        'company_driver_type', 'company_driver_id')

    id = models.UUIDField(
        default=uuid.uuid4, editable=False, unique=True, primary_key=True)
    type = models.CharField(_('Tipo'), max_length=20,
                            choices=Selects().type_transport())

    # land
    registration = models.CharField(
        _('Matricula'), max_length=20, null=True, blank=True)
    model = models.CharField(_('Modelo'), max_length=20, null=True, blank=True)
    brand = models.CharField(_('Marca'), max_length=20, null=True, blank=True)
    load_capacity = models.CharField(
        _('Capacidad de Carga'), max_length=20, null=True, blank=True)

    # maritime
    name = models.CharField(_('Nombre'), max_length=20, null=True, blank=True)
    year_vessel = models.CharField(
        _('Año De Embarcación'), max_length=20, null=True, blank=True)

    # fluvial
    name_fluvial = models.CharField(
        _('Nombre'), max_length=20, null=True, blank=True)
    type_vessel = models.CharField(
        _('Tipo De Embarcación'), max_length=20,
        null=True, blank=True,
        choices=Selects().type_vissel())
    result = models.CharField(
        _('Resultado'), max_length=9999, null=True, blank=True)

    is_active = models.BooleanField(default=True, verbose_name=_('Activo'))
    is_delete = models.BooleanField(default=False, verbose_name=_('Eliminado'))
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.type
Ejemplo n.º 6
0
class Company(models.Model):
    id = models.UUIDField(default=uuid.uuid4,
                          editable=False,
                          unique=True,
                          primary_key=True)
    type_document = models.CharField(_('Tipo De Documento'),
                                     max_length=2,
                                     null=False,
                                     blank=False,
                                     choices=Selects().type_document())
    document = models.CharField(_('Documento'),
                                max_length=15,
                                null=False,
                                blank=False,
                                unique=True)
    name = models.CharField(_('Nombre'),
                            max_length=50,
                            null=False,
                            blank=False,
                            unique=True)
    tlf = models.CharField(_('Telefono'), max_length=15, null=True, blank=True)
    tlf_house = models.CharField(_('Telefono Casa'),
                                 max_length=15,
                                 null=True,
                                 blank=True)
    state = models.ForeignKey(State,
                              on_delete=models.CASCADE,
                              verbose_name=_('Estado'))
    municipality = models.ForeignKey(Municipality,
                                     on_delete=models.CASCADE,
                                     verbose_name=_('Municipio'))
    parish = models.ForeignKey(
        Parish,
        on_delete=models.CASCADE,
        verbose_name=_('Parroquia'),
    )
    address = models.TextField(_('Direccion'), null=False, blank=False)
    is_active = models.BooleanField(default=True)
    is_delete = models.BooleanField(default=False)

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ('-created_at', )

    def __str__(self):
        return self.name

    def get_document(self):
        return f'{self.type_document}-{self.document}'

    def get_full_name(self):
        return self.name
Ejemplo n.º 7
0
 def dispatch(self, request, *args, **kwargs):
     url = f'/{request.META.get("PATH_INFO").split("/")[1].lower()}/'
     url_user = Selects().level_user_url()
     # if (url_user.get(request.user.level) != url and not request.user.is_superuser and not request.user.role == 'is_coordinator'):
     #     return redirect('/')
     return super().dispatch(request, *args, **kwargs)
Ejemplo n.º 8
0
class PlantIce(models.Model):
    type_ice = models.CharField(max_length=20, choices=Selects().type_ice())
    state = models.ForeignKey(core.State, on_delete=models.CASCADE)
    name = models.CharField(max_length=500)
    capacity_ton = models.DecimalField(max_digits=5, decimal_places=2)
    capacity_ton_mes = models.DecimalField(max_digits=5, decimal_places=2)