#encoding:utf-8 from django.db import models from django.contrib.auth.models import User class cat_nivel(models.Model): nombre = models.CharField('nombre', max_length=50, help_text = 'Escriba el nombre', ) def __unicode__(self): return u'%s' % self.nombre class Meta: ordering = ['nombre'] verbose_name = 'Catálogo de Niveles' verbose_name_plural = 'Catálogo de Niveles' unique_together = ['nombre'] class directorio(models.Model): padre = models.ForeignKey('self', null = True, blank = True, verbose_name = 'pertenece a') nombre = models.CharField('nombre', max_length=200, help_text = 'Escriba el nombre', ) nivel = models.ForeignKey(cat_nivel) def __unicode__(self): if self.padre == None: r = self.nombre else: r = u'%s - %s' % (self.padre, self.nombre) return u'%s' % r class Meta: ordering = ['nivel','nombre'] verbose_name = 'Directorio' verbose_name_plural = 'Directorio' unique_together = ['padre', 'nombre'] class cat_cargos(models.Model): clave = models.CharField( max_length = 30 ) nombre = models.CharField( max_length = 150 ) def __unicode__(self): return u'%s' % self.nombre class Meta: ordering = ['nombre'] verbose_name = 'Catálogo de Cargos' verbose_name_plural = 'Catálogo de Cargos' unique_together = ['clave' , 'nombre'] class cat_persona(models.Model): foto = models.ImageField(upload_to= 'cargas', blank=True, null=True) nombre = models.CharField( max_length = 200 ) apellido_paterno = models.CharField( max_length = 100 ) apellido_materno = models.CharField( max_length = 100 ) def nombre_completo(self): return u'%s %s %s' % (self.nombre, self.apellido_paterno, self.apellido_materno ) def __unicode__(self): return u'%s' % self.nombre class Meta: ordering = ['nombre'] verbose_name = 'Catálogo de Personas' verbose_name_plural = 'Catálogo de Personas' class contacto(models.Model): dependencia = models.ForeignKey( directorio ) persona = models.ForeignKey( cat_persona ) cargo = models.ForeignKey( cat_cargos ) correo = models.EmailField( max_length = 100, blank = True, null = True ) telefono = models.CharField( max_length = 30, blank = True, null = True ) extencion = models.CharField( max_length = 5, blank = True, null = True ) celular = models.CharField( max_length = 15, blank = True, null = True ) direccion = models.CharField( max_length = 300 ) pagina_web = models.URLField( max_length=400, blank=True, null=True ) longitud = models.DecimalField( max_digits = 15, decimal_places = 5, null = True, blank = True ) latitud = models.DecimalField( max_digits = 15, decimal_places = 5, null = True, blank = True ) def __unicode__(self): return u'%s' % self.persona.nombre class Meta: ordering = ['persona'] verbose_name = 'Contacto' verbose_name_plural = 'Contacto' class control_versiones(models.Model): version = models.IntegerField( max_length = 10, null = True, blank = True ) def __unicode__(self): return u'%s' % self.version class Meta: ordering = ['version'] verbose_name = 'Control de Versiones' verbose_name_plural = 'Control de Versiones' # from django.db import models # from django.contrib.auth.models import User # class categoria(models.Model): # clave = models.CharField( max_length = 30 ) # nombre = models.CharField( max_length = 150 ) # def __unicode__(self): # return u'%s' % self.nombre # class Meta: # ordering = ['nombre'] # verbose_name = 'Categorías' # verbose_name_plural = 'Categorías' # unique_together = ['nombre'] # class subcategoria(models.Model): # clave = models.CharField( max_length = 30 ) # nombre = models.CharField( max_length = 150 ) # categoria = models.ForeignKey( categoria ) # def __unicode__(self): # return u'%s' % self.nombre # class Meta: # ordering = ['nombre'] # verbose_name = 'Sub-Categorías' # verbose_name_plural = 'Sub-Categorías' # unique_together = ['nombre'] # class dependencia(models.Model): # clave = models.CharField( max_length = 30 ) # nombre = models.CharField( max_length = 200 ) # subcategoria = models.ForeignKey( subcategoria ) # def __unicode__(self): # return u'%s' % self.nombre # class Meta: # ordering = ['nombre'] # verbose_name = 'Dependencias' # verbose_name_plural = 'Dependencias' # unique_together = ['nombre'] # class cat_cargos(models.Model): # clave = models.CharField( max_length = 30 ) # nombre = models.CharField( max_length = 200 ) # def __unicode__(self): # return u'%s' % self.nombre # class Meta: # ordering = ['nombre'] # verbose_name = 'Catálogo de Cargos' # verbose_name_plural = 'Catálogo de Cargos' # unique_together = ['nombre'] # class contacto(models.Model): # Dependencia = models.ForeignKey( dependencia ) # foto_contacto = models.ImageField(upload_to= 'cargas', blank=True, null=True) # nombre_contacto = models.CharField( max_length = 200 ) # apellido_paterno = models.CharField( max_length = 100 ) # apellido_materno = models.CharField( max_length = 100 ) # cargo = models.ForeignKey( cat_cargos ) # correo = models.EmailField( max_length = 100 ) # telefono = models.CharField( max_length = 15 ) # extencion = models.CharField( max_length = 5, blank = True, null = True ) # celular = models.CharField( max_length = 15, blank = True, null = True ) # direccion = models.CharField( max_length = 300 ) # pagina_web = models.URLField( max_length=400, blank=True, null=True ) # longitud = models.DecimalField( max_digits = 15, decimal_places = 5, null = True, blank = True ) # latitud = models.DecimalField( max_digits = 15, decimal_places = 5, null = True, blank = True )