From c25d23548d434bafec9fa87701990f13457ba71a Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 8 Mar 2021 11:10:03 +0000 Subject: [PATCH] mods to django admin --- companies/models.py | 4 ++-- products/admin.py | 13 +++++++------ products/models.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/companies/models.py b/companies/models.py index 70c46ef..6c1ae98 100644 --- a/companies/models.py +++ b/companies/models.py @@ -24,7 +24,7 @@ class Company(models.Model): cif = models.CharField('CIF', max_length=15, null=True, blank=True) company_name = models.CharField('Razón Social Cooperativa', max_length=1000, null=True, blank=True) - short_name = models.CharField('Apócope', max_length=100, null=True, blank=True) # autogenerar si blank + short_name = models.CharField('Nombre', max_length=100, null=True, blank=True) # autogenerar si blank web_link = models.URLField('Enlace a la web', null=True, blank=True) shop = models.BooleanField('Tienda Online', null=True, default=False) shop_link = models.URLField('Enlace a la tienda', null=True, blank=True) @@ -52,7 +52,7 @@ class Company(models.Model): created = models.DateTimeField('date of creation', auto_now_add=True) updated = models.DateTimeField('date last update', auto_now=True) creator = models.ForeignKey('core.CustomUser', on_delete=models.DO_NOTHING, null=True, blank=True, related_name='creator') - history = models.ForeignKey(HistorySync, null=True, blank=True, on_delete=models.DO_NOTHING, related_name='company') + history = models.ForeignKey(HistorySync, null=True, blank=True, on_delete=models.DO_NOTHING, related_name='comp_hist') class Meta: verbose_name = "Compañía" diff --git a/products/admin.py b/products/admin.py index 94cc68e..94d8743 100644 --- a/products/admin.py +++ b/products/admin.py @@ -5,18 +5,19 @@ from . import forms # Register your models here. + +def model_admin_callable(co): + return co.company_name + class ProductAdmin(admin.ModelAdmin): form = forms.ProductTagForm - list_display = ('name', 'category', 'sourcing_date', 'company') + list_display = ('name', 'category', 'sourcing_date', 'company_name', 'active' ) list_filter = ('company', 'tags', 'category', 'attributes') search_fields = ('name', 'sku', 'description') + def company_name(self, product): + return product.company.company_name -''' -class ProductInline(admin.TabularInline): - model = models.Product - form = forms.ProductTagForm -''' admin.site.register(models.Product, ProductAdmin) admin.site.register(models.TreeTag) diff --git a/products/models.py b/products/models.py index d3b4a16..7ee89fd 100644 --- a/products/models.py +++ b/products/models.py @@ -64,7 +64,7 @@ class Product(models.Model): category = SingleTagField(to=CategoryTag, null=True, blank=True, on_delete=models.SET_NULL) # main tag category attributes = TagField(to=AttributeTag, blank=True, related_name='product_attributes') identifiers = models.TextField('Identificador único de producto', null=True, blank=True) - active = models.BooleanField('Mostrar producto', default=False) + active = models.BooleanField('Activo', default=False) # internal created = models.DateTimeField('date of creation', auto_now_add=True)