Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #26

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
14 changes: 5 additions & 9 deletions LabModule/app_forms/Maquina.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.forms import ModelForm
from django import forms
from django.forms import ModelForm

from LabModule.app_models.Maquina import Maquina

Expand All @@ -19,14 +19,10 @@ class MaquinaForm(ModelForm):
:param ModelForm: Instancia de Django.forms.
:type ModelForm: ModelForm.
"""
fechaInicialDisp = forms.DateTimeField(input_formats=["%Y-%m-%d %H:%M"
] )
fechaFinalDisp = forms.DateTimeField(input_formats=["%Y-%m-%d %H:%M"])
fechaInicialDisp = forms.DateTimeField(input_formats = ["%Y-%m-%d %H:%M"
])
fechaFinalDisp = forms.DateTimeField(input_formats = ["%Y-%m-%d %H:%M"])

class Meta:
model = Maquina
exclude = ['mueble']

#widgets = {
# 'fechaInicialDisp': forms.DateInput(attrs={'class': 'form-control date '}),
# 'fechaFinalDisp': forms.DateInput(attrs={'class': 'form-control date '})
#}
9 changes: 5 additions & 4 deletions LabModule/app_forms/Muestra.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from LabModule.app_models.Muestra import Muestra
from LabModule.app_models.SolicitudMuestra import SolicitudMuestra


class MuestraForm(ModelForm):
"""Formulario para crear y modificar muestras.
Se encarga de:
Expand All @@ -30,7 +31,7 @@ class Meta:


class MuestraAddForm(forms.Form):
def __init__(self, *args, **kwargs):
maxi = kwargs.pop('maximo')
super(MuestraAddForm, self).__init__(*args, **kwargs)
self.fields['cantidad'] = forms.IntegerField(label="Cantidad", max_value=maxi,min_value=1)
def __init__(self, *args, **kwargs):
maxi = kwargs.pop('maximo')
super(MuestraAddForm, self).__init__(*args, **kwargs)
self.fields['cantidad'] = forms.IntegerField(label = "Cantidad", max_value = maxi, min_value = 1)
17 changes: 9 additions & 8 deletions LabModule/app_forms/Solicitud.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django import forms
import datetime

from django import forms
from django.db.models import Q
from django.forms import ModelForm

Expand Down Expand Up @@ -29,11 +30,11 @@ def verificar_fecha(self, maquina_id, fechaIni, fechaFin):
return False
return True

def verificarDisponibilidad(self,start,end,fechaIni,fechaFin):
d_end=datetime.datetime.strptime(end, "%Y-%m-%d")
d_start=datetime.datetime.strptime(start, "%Y-%m-%d")
d_fechaIni=datetime.datetime.strptime(fechaIni[:-6], "%Y-%m-%d")
d_fechaFin=datetime.datetime.strptime(fechaFin[:-6], "%Y-%m-%d")
if d_start<=d_fechaIni<=d_end and d_start<=d_fechaFin<=d_end:
def verificarDisponibilidad(self, start, end, fechaIni, fechaFin):
d_end = datetime.datetime.strptime(end, "%Y-%m-%d")
d_start = datetime.datetime.strptime(start, "%Y-%m-%d")
d_fechaIni = datetime.datetime.strptime(fechaIni[:-6], "%Y-%m-%d")
d_fechaFin = datetime.datetime.strptime(fechaFin[:-6], "%Y-%m-%d")
if d_start <= d_fechaIni <= d_end and d_start <= d_fechaFin <= d_end:
return True
return False
return False
4 changes: 2 additions & 2 deletions LabModule/app_models/Almacenamiento.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Meta:

mueble = models.OneToOneField(
Mueble,
null=True,
null = True,
on_delete = models.CASCADE,
related_name = '%(app_label)s_%(class)s_related'
)
Expand All @@ -75,7 +75,7 @@ class Meta:
)

def __unicode__(self):
return self.idSistema+ self.mueble.__unicode__()
return self.idSistema + self.mueble.__unicode__()

def get_id_sistema(self):
return self.idSistema
Expand Down
5 changes: 3 additions & 2 deletions LabModule/app_models/Bandeja.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Meta:

def __unicode__(self):
return 'Bandeja: ' + self.almacenamiento.get_id_sistema() + " " + str(self.posicion)

@classmethod
def getBandejas(cls,idLugar):
return Bandeja.objects.filter(almacenamiento=idLugar)
def getBandejas(cls, idLugar):
return Bandeja.objects.filter(almacenamiento = idLugar)
19 changes: 9 additions & 10 deletions LabModule/app_models/Maquina.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from datetime import datetime, timedelta


from django.db import models
from django.urls import reverse
from django.utils import timezone
Expand Down Expand Up @@ -53,22 +52,22 @@ class Meta:
)

fechaInicialDisp = models.DateTimeField(
blank=False,
null=True,
verbose_name=_("Fecha Inicial"),
default=timezone.now
blank = False,
null = True,
verbose_name = _("Fecha Inicial"),
default = timezone.now
)

fechaFinalDisp = models.DateTimeField(
blank=False,
null=True,
verbose_name=_("Fecha Final"),
default=datetime.now()+timedelta(days=30)
blank = False,
null = True,
verbose_name = _("Fecha Final"),
default = datetime.now() + timedelta(days = 30)
)

mueble = models.OneToOneField(
Mueble,
null=True,
null = True,
on_delete = models.CASCADE,
related_name = '%(app_label)s_%(class)s_related'
)
Expand Down
6 changes: 3 additions & 3 deletions LabModule/app_models/Mueble.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Meta:
estado = models.BooleanField(
default = True,
verbose_name = _('Activa'),
null=False
null = False
)

imagen = models.ImageField(
Expand All @@ -35,15 +35,15 @@ class Meta:
default = 'images/image-not-found.jpg'
)

tipo= models.CharField(
tipo = models.CharField(
max_length = 1000,
default = 'Desconocido',
verbose_name = _("Descripción"),
null = False
)

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

def get_nombre(self):
return self.nombre.capitalize()
Expand Down
2 changes: 2 additions & 0 deletions LabModule/app_models/MuebleEnLab.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class MuebleEnLab(models.Model):
class Meta:
verbose_name = _("Mueble en Laboratorio")
verbose_name_plural = _('Muebles en Laboratorio')
app_label = 'LabModule'
unique_together = ('idLaboratorio', 'posX', 'posY')

idLaboratorio = models.ForeignKey(
Laboratorio,
Expand Down
6 changes: 3 additions & 3 deletions LabModule/app_models/Muestra.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import gettext_lazy as _

from LabModule.app_models import Almacenamiento

permissions_sample = (
('can_addSample', 'muestra||agregar'),
('can_editSample', 'muestra||editar'),
Expand Down Expand Up @@ -77,9 +79,7 @@ class Meta:
null = True,
verbose_name = _("Unidad de Medida")
)
alamacenamientos=models.ManyToManyField(Almacenamiento)
alamacenamientos = models.ManyToManyField(Almacenamiento)

def __unicode__(self):
return 'Muestra: ' + self.nombre


6 changes: 3 additions & 3 deletions LabModule/app_models/MuestraEnBandeja.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Meta:

def __unicode__(self):
return str(self.posX) + ":" + str(self.posY)

@classmethod
def getPosiciones(cls,bandeja):
return MuestraEnBandeja.objects.filter(idBandeja=bandeja)
def getPosiciones(cls, bandeja):
return MuestraEnBandeja.objects.filter(idBandeja = bandeja)
2 changes: 1 addition & 1 deletion LabModule/app_utils/cursores.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def dictfetchall(cursor):
'FROM "LabModule_muestra" m\n'
'LEFT JOIN "LabModule_muestraenbandeja" mb\n'
'ON m.id = mb."idMuestra_id"\n'
'WHERE m.activa = true\n'
'WHERE m.activa = TRUE\n'
'GROUP BY m.id,\n'
' m.nombre,\n'
' m.valor,\n'
Expand Down
Loading