class UploadRecord(models.Model): ''' 用户上传记录 ''' def __unicode__(self): return self.user_name + ' upload file ' + self.file_name user_name = models.CharField(max_length=128, verbose_name=_(u'用户名')) fileinfo = models.ForeignKey(FileInfo, verbose_name=_(u'上传文件')) file_name = models.CharField(max_length=256, verbose_name=_(u'文件名')) upload_time = models.DateTimeField(verbose_name=_(u"上传时间"), auto_now_add=True) src_ip = models.IPAddressField(verbose_name=u"上传IP", blank=True, null=True) location_type = models.IntegerField( max_length=32, verbose_name=_(u'上传类型'), choices=enum_template.UPLOAD_TYPE_CHOICES, default=enum_template.UPLOAD_TYPE_LOCAL) remote_path = models.FilePathField(verbose_name=_(u'远程文件路径'), blank=True, null=True) remote_account = models.ForeignKey(Account, verbose_name=_(u'远程账户'), blank=True, null=True) audit_log = AuditLog()
class TipoPago(models.Model): tipopago_id = models.CharField(primary_key=True, max_length=9) pago = models.CharField(max_length=90) value = models.SmallIntegerField(default=7) flag = models.BooleanField(default=True) audit_log = AuditLog()
class FamiliaIcr(models.Model): empdni = models.ForeignKey(Employee, to_field='empdni_id') nombres = models.CharField(max_length=100, null=True, blank=True) parentesco = models.CharField(max_length=20, null=True, blank=True) areatrabajo = models.CharField(max_length=50, null=True, blank=True) audit_log = AuditLog()
class Materiale(models.Model): materiales_id = models.CharField(u'Mnemocode', unique=True, primary_key=True, max_length=15) matnom = models.CharField(max_length=200, null=False) matmed = models.CharField(max_length=200, null=False) unidad = models.ForeignKey(Unidade, to_field='unidad_id') # matpre = models.FloatField(default=0,null=True) # matmar = models.CharField(max_length=40,null=True) # matmod = models.CharField(max_length=40,null=True) matacb = models.CharField(max_length=255, null=True) matare = models.FloatField(null=True) audit_log = AuditLog() class Meta: ordering = ['matnom'] @property def complete_name(self): return '%s %s' % (self.matnom, self.matmed) def __unicode__(self): return '%s %s %s %s' % (self.materiales_id, self.matnom, self.matmed, self.unidad.uninom)
class DSector(models.Model): def url(self, filename): return 'storage/projects/%s/%s/%s/%s.pdf' % ( self.project.registrado.strftime('%Y'), self.project_id, self.sgroup_id, self.dsector_id) dsector_id = models.CharField(primary_key=True, max_length=23, default='PRAA000VEN00SG0000DS000') sgroup = models.ForeignKey(SGroup, to_field='sgroup_id') project = models.ForeignKey(Proyecto, to_field='proyecto_id') sector = models.ForeignKey(Sectore, to_field='sector_id', null=True, blank=True) name = models.CharField(max_length=255) plane = models.FileField(upload_to=url, max_length=200, null=True, blank=True) register = models.DateTimeField(auto_now_add=True) datestart = models.DateField(null=True) dateend = models.DateField(null=True) description = models.TextField(null=True, blank=True) observation = models.TextField(null=True, blank=True) status = models.CharField(max_length=2, default='PE') flag = models.BooleanField(default=True) audit_log = AuditLog() def __unicode__(self): return '%s %s %s %s' % (self.project, self.dsector_id, self.name, self.register)
class InventoryBrand(models.Model): storage = models.ForeignKey(Almacene, to_field='almacen_id') period = models.CharField(max_length=4) materials = models.ForeignKey(Materiale, to_field='materiales_id') brand = models.ForeignKey(Brand, to_field='brand_id') model = models.ForeignKey(Model, to_field='model_id') ingress = models.DateTimeField(auto_now=True) stock = models.FloatField() purchase = models.FloatField() sale = models.FloatField() flag = models.BooleanField(default=True) audit_log = AuditLog() class Meta: ordering = ['materials'] @staticmethod @transaction.commit_on_success def eraseAllInventory(): cn = connection.cursor() try: cn.callproc('proc_erase_all_inventory') return cn.fetchone()[0] except Exception, e: transaction.rollback() return str(e) finally:
class Employee(models.Model): empdni_id = models.CharField(primary_key=True, max_length=8) firstname = models.CharField(max_length=100) lastname = models.CharField(max_length=150) register = models.DateTimeField(auto_now=True) birth = models.DateField(auto_now_add=True) phone = models.CharField(max_length=32, null=True, blank=True) address = models.CharField(max_length=180) charge = models.ForeignKey(Cargo, to_field='cargo_id') email = models.EmailField(max_length=80, null=True, blank=True) fixed = models.CharField(max_length=26, null=True, blank=True) phonejob = models.CharField(max_length=32, null=True, blank=True) observation = models.TextField(null=True, blank=True) flag = models.BooleanField(default=True) audit_log = AuditLog() class Meta: ordering = ['lastname'] def __unicode__(self): return '%s %s %s %s %s' % (self.empdni_id, self.firstname, self.lastname, self.phone, self.charge) @property def name_complete(self): return '%s, %s' % (self.lastname, self.firstname) @property def name_charge(self): return '%s - %s' % (self.charge.cargos, self.charge.area)
class Contact(models.Model): name_prefix = models.CharField(_(u'Name Prefix'), max_length=12) lastname = models.CharField(_(u'Lastname'), max_length=50) firstname = models.CharField(_(u'Firstname'), max_length=50, blank=True) function = models.CharField(_(u'Function'), max_length=50, blank=True) phone = models.CharField(_(u'Phone'), max_length=30, blank=True) email = models.EmailField(_(u'Email'), blank=True) company = models.ForeignKey(Company, verbose_name=_(u'Company'), related_name='contacts') audit_log = AuditLog() def __unicode__(self): s = u'{0} {1} {2}'.format(self.name_prefix, self.firstname, self.lastname) if self.function: return u'{0} ({1})'.format(s, self.function) return s def shortname(self): return u'{0} {1}'.format(self.name_prefix, self.lastname) class Meta: verbose_name = _(u'Contact') verbose_name_plural = _(u'Contacts')
class ReleaseElement(crichtonModel): objects = ReleaseElementManager() release = models.ForeignKey('Release', related_name="elements") package = models.ForeignKey('package.Package') application = models.ForeignKey('prodmgmt.Application', null=True, blank=True) audit_log = AuditLog() deleted = models.BooleanField(default=False) class Meta: app_label = "release" unique_together = ('release', 'package') def __unicode__(self): return "%s: %s %s" % (self.package.name, self.release.product.name, self.release.version) def natural_key(self): return (self.release.product.name, self.release.version, self.package.name) natural_key.dependencies = ['prodmgmt.product', 'release.release', 'package.packagename'] def application_url(self): if self.application: return '<a href="/admin/prodmgmt/application/%s">%s</a>' % ( self.application.id,self.application.name) else: return '(None)' application_url.short_description = "Application" application_url.allow_tags = True def get_api_url(self, suffix): PRODUCT_NAME="TBD" return "/api/release_element/one/%s:%s@%s.%s" % \ (self.package.name, PRODUCT_NAME, self.release.version, suffix)
class MyModel(models.Model): """A model that uses both audit log and model translation.""" title = models.CharField(max_length=50) text = models.TextField() audit_log = AuditLog()
class Template(models.Model): ''' @note: 模板 ''' name = models.CharField(max_length=128, verbose_name=_(u'模板名称'), blank=True, null=True) template_type = models.IntegerField(verbose_name=_(u'模板类型'), choices=enum_template.TEMPLATE_TYPE_CHOICES, default=enum_template.TEMPLATE_TYPE0) work_type = models.CharField(max_length=256, verbose_name=_(u'业务类型'), blank=True, null=True) remarks = models.CharField(max_length=256, verbose_name=_(u'备注'), blank=True, null=True) create_user = models.ForeignKey(User, verbose_name=_(u'创建人'), related_name='template_create_user', blank=True, null=True) # create_user = models.CharField(max_length=256, verbose_name=_(u'创建人'), blank=True, null=True) update_user = models.ForeignKey(User, verbose_name=_(u'更新人'), related_name='template_update_user', blank=True, null=True) # update_user = models.CharField(max_length=256, verbose_name=_(u'更新人'), blank=True, null=True) created = models.DateTimeField(verbose_name=_(u"创建时间"), auto_now_add=True) updated = models.DateTimeField(verbose_name=_(u"更新时间"), auto_now=True) mode = models.IntegerField(verbose_name=_(u'执行模式'), choices=enum_template.TEMPLATE_MODE_CHOICES, default=enum_template.TEMPLATE_MODE_MANNUAL, blank=True, null=True) account = models.ForeignKey(Account, verbose_name=_(u'常用账户'), blank=True, null=True) target = models.TextField(verbose_name=_(u'目标机器'), blank=True, null=True) is_delete = models.BooleanField(verbose_name=_(u'是否删除'), default=False) audit_log = AuditLog() def __unicode__(self): return self.name class Meta: #模板 verbose_name = _('Template') verbose_name_plural = _('Templates')
class DetCompra(models.Model): compra = models.ForeignKey(Compra, to_field='compra_id') materiales = models.ForeignKey(Materiale, to_field='materiales_id') unit = models.ForeignKey(Unidade, to_field='unidad_id', null=True, blank=True) brand = models.ForeignKey(Brand, to_field='brand_id', default='BR000', blank=True) model = models.ForeignKey(Model, to_field='model_id', default='MO000', blank=True) cantidad = models.FloatField() precio = models.FloatField() discount = models.DecimalField(max_digits=5, decimal_places=2, default=0) cantstatic = models.FloatField() flag = models.CharField(max_length=1, default='0') perception = models.FloatField(default=0, blank=True) convertto = models.DecimalField(max_digits=6, decimal_places=2, default=1) observation = models.TextField(blank=True, default='') audit_log = AuditLog() class Meta: ordering = ['materiales'] def __unicode__(self): return u'%s %s %f %f' % (self.compra, self.materiales, self.cantstatic, self.precio)
class Game(models.Model): name = models.CharField(max_length=254, null=False, blank=False) analytics_view_id = models.CharField( null=True, blank=True, max_length=254, validators=[ MinLengthValidator(9), RegexValidator(re.compile(r'^[0-9]*$'), Constants.ONLY_NUMBERS_ALLOWED) ]) package_name = models.CharField(max_length=254, null=False, blank=False) game_service_id = models.CharField(max_length=254, null=False, blank=False) game_image = models.URLField(max_length=254) api_key = models.CharField(max_length=254, null=False, blank=False) modified_date = models.DateTimeField(auto_now=True, null=True) form_template = models.TextField() audit_log = AuditLog() manager = GameManager() class Meta: permissions = (('view_game', 'Can view game'), ) def __str__(self): return str(self.name) + "|" + str(self.package_name) + "|" + str( self.game_service_id)
class Products(models.Model): products = models.CharField(max_length=100) measure = models.ForeignKey('units_measures.UnitsMeasures') quantity = models.DecimalField(max_digits=100, default='0', decimal_places=2, null=True, blank=True) price = models.DecimalField(max_digits=100, default='0', decimal_places=2, blank=True) description = models.TextField(max_length=250, blank=True) category = models.ForeignKey('category.Category') image = models.ImageField(upload_to=content_file_products, blank=True) active = models.BooleanField(default=True) audit_log = AuditLog() def __str__(self): return self.products class Meta: permissions = ( ("to_access_warehouse", "Puede acceder a almacen"), ("add_entry", "Puede agregar entrada"), ("update_entry", "Puede actualizar entrada"), ("delete_entry", "Puede eliminar entrada"), ("add_exit", "Puede agregar salida"), ("update_exit", "Puede actualizar salida"), ("delete_exit", "Puede eliminar salida"), ("to_access_inventory", "Puede acceder a inventario"), ("to_access_request", "Puede acceder a solicitudes"), ("to_access_search", "Puede acceder a busquedas"), )
class Course(models.Model): title = models.CharField(max_length = 255) created_date = models.DateTimeField(auto_now_add = True, auto_now = False) updated_date = models.DateTimeField(auto_now_add = False, auto_now = True) course_description = models.TextField() couch = models.ForeignKey(Couch, blank = True, null = True, limit_choices_to={'is_couch': True}) course_start_date = models.DateTimeField() course_end_date = models.DateTimeField() publish = models.BooleanField(default = True) registration_start_date = models.DateField() registration_end_date = models.DateField() open_registration = models.BooleanField(default = False) course_price = models.DecimalField(max_digits = 5, decimal_places = 2, help_text="Course price in 2 digits format. Example 23.45.", default = 0.00) notes = models.TextField(blank = True, null = True, help_text="Notes to the course, what to bring etc...") registration_form_link = models.URLField(blank = True, null = True) interested_form_link = models.URLField(blank = True, null = True) course_venue = models.ForeignKey(CourseVenue, default = 1) course_category = models.ForeignKey(Category, default = 2) audit_log = AuditLog() def __unicode__(self): return u"%s" %(self.title) def price(self): return '{} CZK'.format(self.course_price) class Meta: ordering = ['updated_date']
class Shapping(models.Model): order = models.IntegerField() name = models.CharField(max_length=250) shappclass = models.ForeignKey(Shappclass, related_name="shapp_class", on_delete=models.PROTECT) parent = models.ForeignKey("self", blank=True, null=True, related_name="shapp_parent", on_delete=models.PROTECT) source = models.ForeignKey(Address, blank=True, null=True, related_name="shapp_source", on_delete=models.PROTECT) srcport = models.ForeignKey(Port, blank=True, null=True, related_name="shapp_srcport", on_delete=models.PROTECT) destiny = models.ForeignKey(Address, blank=True, null=True, related_name="shapp_destiny", on_delete=models.PROTECT) dstport = models.ForeignKey(Port, blank=True, null=True, related_name="shapp_dstport", on_delete=models.PROTECT) audit_log = AuditLog() class Meta: ordering = ["order"] def __str__(self): return self.name def save(self): if self.pk is not None: if Shapping.objects.filter(order=self.order): orig = Shapping.objects.get(pk=self.pk) if orig.order > self.order: Shapping.objects.filter(order__lt=orig.order, order__gte=self.order).update(order=F('order') + 1) elif orig.order < self.order: Shapping.objects.filter(order__lte=self.order, order__gte=orig.order).update(order=F('order') - 1) else: Shapping.objects.filter(order__gte=self.order).update(order=F('order') + 1) super(Shapping, self).save() def delete(self): Shapping.objects.filter(order__gte=self.order).update(order=F('order') - 1) print self.order super(Shapping, self).delete()
def log_user_save(sender, **kwargs): ''' Keeping these print statements here for reference for potential later use. print(kwargs.get('user'), '1') print(kwargs.get('user_id'), '2') print(kwargs.get('instance'), '3') print(kwargs.get('instance'), '4') print(kwargs.get('update_fields'), '5') print(kwargs.get('signal'), '6') print(kwargs.get('instance').get_username(), '8') print(kwargs.get('instance').groups, '9') # print(kwargs.get('instance').get_all_permissions()) print(kwargs.get('instance').groups, '10') print(kwargs.get('instance').pagerevision_set, '11') print(kwargs.get('instance').user_permissions, '12') print(kwargs.get('instance').logentry_set, '12.5') print(sender.logentry_set, '13') # print(sender.__base__.id, '13') # print(sender.get('id'), '14') print(sender.id, '15') ''' if kwargs.get('update_fields'): logger.info("User {0} logged in".format(kwargs.get('instance').get_username())) else: logger.info("User change: username {0} by instance {1}".format(kwargs.get('instance').get_username(), kwargs.get('instance'))) audit_log = AuditLog() #currently not used, will attempt to use for future PR adding admin logging
class ContactData(models.Model): # surname givenname company department title phone mobile fax origin email address birthday region website qq weibo im contact = models.ForeignKey('Contacts', related_name='data', unique=True) surname = models.CharField(max_length=255, blank=True) givenname = models.CharField(max_length=255, blank=True) company = models.CharField(max_length=100, blank=True) department = models.CharField(max_length=100, blank=True) title = models.CharField(max_length=100, blank=True) phone = models.CharField(max_length=100, blank=True) mobile = models.CharField(max_length=100, blank=True) fax = models.CharField(max_length=100, blank=True) origin = models.CharField(max_length=100, blank=True) email = models.EmailField(blank=True) address = models.CharField(max_length=100, blank=True) birthday = models.DateField(null=True, blank=True) region = models.CharField(max_length=100, blank=True) website = models.URLField(blank=True) qq = models.CharField(max_length=100, blank=True) weibo = models.CharField(max_length=100, blank=True) im = models.CharField(max_length=100, blank=True) createdDate = models.DateTimeField(auto_now_add=True) createdBy = models.CharField(max_length=100) modifiedDate = models.DateTimeField(auto_now=True) modifiedBy = models.CharField(max_length=100) audit_log = AuditLog()
class Detpedido(models.Model): pedido = models.ForeignKey(Pedido, to_field='pedido_id') materiales = models.ForeignKey(Materiale, to_field='materiales_id') brand = models.ForeignKey(Brand, to_field='brand_id', default='BR000', blank=True, null=False) model = models.ForeignKey(Model, to_field='model_id', default='MO000', blank=True, null=False) cantidad = models.FloatField(null=False) cantshop = models.FloatField(default=0, null=False) cantguide = models.FloatField(default=0, null=True, blank=True) tag = models.CharField(max_length=1, default='0', null=False) spptag = models.BooleanField(default=False) comment = models.CharField(max_length=250, default='', null=True) cantenv = models.FloatField(blank=True, default=0) flagcantenv = models.BooleanField(blank=True, default=False) flag = models.BooleanField(default=True) cenvdevmat = models.FloatField(default=0) #devmaterial flagcenvdevmat = models.BooleanField(default=False) #d audit_log = AuditLog() class Meta: ordering = ['materiales'] def __unicode__(self): return '%s %s %f' % (self.pedido.pedido_id, self.materiales.materiales_id, self.cantidad)
class PurchaseOrder(models.Model): def url(self, filename): ruta = 'storage/projects/%s/%s/purchase_order_customers/%s.pdf' % ( search.searchPeriodProject( self.project_id), self.project_id, self.nropurchase) return ruta project = models.ForeignKey(Proyecto, to_field='proyecto_id') # subproject = models.ForeignKey( # Subproyecto, to_field='subproyecto_id',null=True, blank=True) register = models.DateTimeField(auto_now_add=True) nropurchase = models.CharField(max_length=14) issued = models.DateField() currency = models.ForeignKey(Moneda, to_field='moneda_id') document = models.ForeignKey(Documentos, to_field='documento_id') method = models.ForeignKey(FormaPago, to_field='pagos_id') observation = models.TextField(null=True, blank=True) dsct = models.FloatField(default=0, blank=True) igv = models.FloatField(default=0, blank=True) order = models.FileField(upload_to=url, null=True, blank=True, max_length=200) flag = models.BooleanField(default=True) audit_log = AuditLog() class Meta: ordering = ['project'] def __unicode__(self): return '%s - %s' % (self.project, self.purchase_id)
class Cliente(models.Model): ruccliente_id = models.CharField(primary_key=True, max_length=11) razonsocial = models.CharField(max_length=200) pais = models.ForeignKey(Pais, to_field='pais_id') departamento = models.ForeignKey(Departamento, to_field='departamento_id') provincia = models.ForeignKey(Provincia, to_field='provincia_id') distrito = models.ForeignKey(Distrito, to_field='distrito_id') direccion = models.CharField(max_length=200, null=False) telefono = models.CharField(max_length=30, null=True, blank=True, default='000-000-000') contact = models.CharField(max_length=200, default='', blank=True) flag = models.BooleanField(default=True) class Meta: ordering = ['razonsocial'] audit_log = AuditLog() def __unicode__(self): return '%s %s' % (self.ruccliente_id, self.razonsocial) def get_absolute_url(self): return reverse('customers_edit', kwargs={'pk': self.ruccliente_id})
class CloseProject(models.Model): def url(self, filename): return 'storage/projects/%s/%s/closed/%s' % ( self.project.registrado.strftime('%Y'), self.project_id, filename) def uridoc(self, filename): return 'storage/projects/%s/%s/closed/calidad/%s' % ( self.project.registrado.strftime('%Y'), self.project_id, filename) def uriaco(self, filename): return 'storage/projects/%s/%s/closed/contabilidad/%s' % ( self.project.registrado.strftime('%Y'), self.project_id, filename) project = models.ForeignKey(Proyecto, to_field='proyecto_id') storageclose = models.BooleanField(default=False, blank=True) datestorage = models.DateTimeField() letterdelivery = models.FileField(upload_to=url, null=True, max_length=250) dateletter = models.DateTimeField(null=True, blank=True) documents = models.FileField(upload_to=uridoc, null=True, blank=True, max_length=255) docregister = models.DateTimeField(null=True) accounting = models.BooleanField(default=False, blank=True) tinvoice = models.FloatField(null=True, blank=True) tiva = models.FloatField(null=True, blank=True) otherin = models.FloatField(blank=True, null=True) otherout = models.FloatField(null=True, blank=True) retention = models.FloatField(null=True, blank=True) fileaccounting = models.FileField(upload_to=uriaco, null=True, max_length=250) performedstorage = models.ForeignKey(Employee, related_name='storage', null=True, blank=True) performedoperations = models.ForeignKey(Employee, related_name='operations', null=True, blank=True) performeddocument = models.ForeignKey(Employee, related_name='documents', null=True, blank=True) performedaccounting = models.ForeignKey(Employee, related_name='accounting', null=True, blank=True) performedclose = models.ForeignKey(Employee, related_name='closeasproject', null=True, blank=True) closeconfirm = models.CharField(default='', max_length=6, blank=True) dateclose = models.DateTimeField(null=True) status = models.CharField(default='PE', max_length=2) keyreopens = models.CharField(max_length=6, null=True) performedre = models.ForeignKey(Employee, related_name='reopen', null=True) datereopen = models.DateTimeField(null=True) audit_log = AuditLog()
class Letter(models.Model): def url(self, filename): uri = 'storage/projects/%s/%s/letters/%s/%s.%s' % ( self.project.registrado.strftime('%Y'), self.project_id, self.letter_id, self.letter_id, filename.split('.')[-1]) name = '%s%s' % (globalVariable.relative_path, uri) if os.path.exists(name): os.remove(name) return uri letter_id = models.CharField(primary_key=True, max_length=19) project = models.ForeignKey(Proyecto, to_field='proyecto_id') register = models.DateTimeField(auto_now=True) performed = models.ForeignKey(Employee, to_field='empdni_id') froms = models.CharField(max_length=80) fors = models.CharField(max_length=80) status = models.CharField(max_length=2, default='PE') letter = models.FileField(upload_to=url, blank=True, null=True, max_length=200) observation = models.TextField(blank=True, null=True) flag = models.BooleanField(default=True) audit_log = AuditLog() class Meta: ordering = ['letter_id']
class Environment(crichtonModel): objects = EnvironmentManager() name = models.CharField( max_length=128, unique=True, help_text="Uniquely identifies the environment. Used in URLs.") repositories = models.ManyToManyField('package.PackageRepository', related_name='environments') audit_log = AuditLog() deleted = models.BooleanField(default=False) class Meta: app_label = "system" ordering = ('name', ) def __unicode__(self): return self.name def natural_key(self): return (self.name, ) def get_api_url(self, suffix): return "/api/environment/one/%s.%s" % (self.name, suffix) def deployment_preference_list_urls(self): qs = self.deployment_preferences.filter(deleted=False) return ", ".join([dp.get_link() for dp in qs]) deployment_preference_list_urls.short_description = "Deployment preferences" deployment_preference_list_urls.allow_tags = True
class DSMetrado(models.Model): dsector = models.ForeignKey(DSector, to_field='dsector_id') sector = models.ForeignKey(Sectore, to_field='sector_id', null=True) materials = models.ForeignKey(Materiale, to_field='materiales_id') brand = models.ForeignKey(Brand, to_field='brand_id') model = models.ForeignKey(Model, to_field='model_id') quantity = models.FloatField() qorder = models.FloatField() qguide = models.FloatField() ppurchase = models.DecimalField(max_digits=8, decimal_places=3, default=0) psales = models.DecimalField(max_digits=8, decimal_places=3, default=0) comment = models.TextField(null=True, blank=True) tag = models.CharField(max_length=1, default='0') nipple = models.BooleanField(default=False, blank=True) flag = models.BooleanField(default=True) audit_log = AuditLog() # class Meta: # verbose_name = 'DSMetrado' # verbose_name_plural = 'DSMetrados' def __unicode__(self): return '%s %s %f %f' % (self.dsector_id, self.materials, self.quantity, self.ppurchase)
class crichtonStatusType(crichtonModel): """ This is a parent for possible different crichton status types. Every new status type should inherit from this parent. There are not going to be any records for this parent in database. """ name = models.CharField( max_length=128, help_text="The unique name of status. Used in URLs.", unique=True, null=False, blank=False) # Django model inheritance does not support field overwriting :( , so I will rather comment this out #status = models.CharField(max_length=100, help_text="Status", null=False, blank=False) comment = models.CharField(max_length=1024, help_text="Comment", null=True, blank=True) date = models.DateTimeField('Created / Updated', null=False, blank=False) audit_log = AuditLog() deleted = models.BooleanField(default=False) class Meta: abstract = True
class CuentaEmple(models.Model): empdni = models.ForeignKey(Employee, to_field='empdni_id') cuenta = models.CharField(max_length=25) #191-xxxxxxxx-0-14 tipodepago = models.ForeignKey( TipoPago, to_field='tipopago_id') #semanal,quincenal,mensual estado = models.CharField(max_length=50, null=True, blank=True) remuneracion = models.FloatField(null=False, default=0) tipocontrato = models.ForeignKey(TipoContrato, to_field='tipocontrato_id') cts = models.DecimalField(max_digits=8, decimal_places=3, blank=True, null=True) gratificacion = models.DecimalField(max_digits=8, decimal_places=3, null=True, blank=True) costxhora = models.DecimalField(max_digits=8, decimal_places=3, null=True, blank=True) registro = models.DateTimeField(auto_now_add=True) setfamily = models.BooleanField(default=False) flag = models.BooleanField(default=True) audit_log = AuditLog()
class Category(models.Model): title = models.CharField(max_length = 80) color_code = models.CharField(max_length = 25, help_text = "Add HEXA code of the course color. Example fffff.", unique = True) created_date = models.DateTimeField(auto_now_add = True, auto_now = False) updated_date = models.DateTimeField(auto_now_add = False, auto_now = True) active = models.BooleanField(default = True) audit_log = AuditLog() def __unicode__(self): return self.title def category_color(self): return format_html('<span style="color: #{};">#{}</span>', self.color_code, self.color_code ) def category_color_code(self): return u"#" + self.color_code class Meta: verbose_name = 'Category' verbose_name_plural = 'Categories' ordering = ['updated_date']
class Assistance(models.Model): userregister = models.ForeignKey(Employee, related_name='EmployeeRegister') employee = models.ForeignKey(Employee, related_name='AssistanceEmployee') project = models.ForeignKey(Proyecto, related_name='AssistanceProject', null=True) types = models.ForeignKey(TypesEmployee, related_name='AssistanceTypeEmpployee') register = models.DateTimeField(auto_now_add=True) assistance = models.DateField(null=False) hourin = models.TimeField(null=False, default='00:00:00') hourinbreak = models.TimeField(null=False, default='00:00:00') houroutbreak = models.TimeField(null=False, default='00:00:00') hourout = models.TimeField(null=False, default='00:00:00') viatical = models.DecimalField(max_digits=4, decimal_places=2, default=0) status = models.ForeignKey(EmployeeBreak, related_name='breakforemployee', null=True, default='AS01') flag = models.CharField(max_length=1, default='A') tag = models.BooleanField(default=True) audit_log = AuditLog() class Meta: ordering = ['-register'] def __unicode__(self): return '%s %s %s %s' % (self.register, self.employee, self.assistance, self.tag)
class DetGuiaRemision(models.Model): guia = models.ForeignKey(GuiaRemision, to_field='guia_id') materiales = models.ForeignKey(Materiale, to_field='materiales_id') cantguide = models.FloatField(default=0, null=True, blank=True) brand = models.ForeignKey(Brand, to_field='brand_id', blank=True, default='BR000') model = models.ForeignKey(Model, to_field='model_id', blank=True, default='MO000') obrand = models.ForeignKey(Brand, related_name='obrandAsDetGuide', blank=True, default='BR000') omodel = models.ForeignKey(Model, related_name='omodelAsDetGuide', blank=True, default='MO000') observation = models.CharField(max_length=250, null=True, blank=True) order = models.ForeignKey(Pedido, to_field='pedido_id', null=True, blank=True) flag = models.BooleanField(default=True) audit_log = AuditLog() class Meta: ordering = ['materiales'] def __unicode__(self): return '%s %s %f' % (self.guia.guia_id, self.materiales.materiales_id, self.cantguide)