mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Add shop field (from properties) (#48)
* Add shop field (from properties) * Update template
This commit is contained in:
@@ -8,6 +8,7 @@ from metadata.models import (
|
||||
Decoder,
|
||||
DecoderDocument,
|
||||
Scale,
|
||||
Shop,
|
||||
Manufacturer,
|
||||
Company,
|
||||
Tag,
|
||||
@@ -130,3 +131,10 @@ class GenericDocumentAdmin(admin.ModelAdmin):
|
||||
),
|
||||
)
|
||||
actions = [publish, unpublish]
|
||||
|
||||
|
||||
@admin.register(Shop)
|
||||
class ShopAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "on_line", "active")
|
||||
list_filter = ("on_line", "active")
|
||||
search_fields = ("name",)
|
||||
|
40
ram/metadata/migrations/0023_shop.py
Normal file
40
ram/metadata/migrations/0023_shop.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# Generated by Django 5.1.4 on 2025-01-26 14:27
|
||||
|
||||
import django_countries.fields
|
||||
import django.db.models.functions.text
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("metadata", "0022_decoderdocument_creation_time_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Shop",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("name", models.CharField(max_length=128, unique=True)),
|
||||
(
|
||||
"country",
|
||||
django_countries.fields.CountryField(blank=True, max_length=2),
|
||||
),
|
||||
("website", models.URLField(blank=True)),
|
||||
("on_line", models.BooleanField(default=True)),
|
||||
("active", models.BooleanField(default=True)),
|
||||
],
|
||||
options={
|
||||
"ordering": [django.db.models.functions.text.Lower("name")],
|
||||
},
|
||||
),
|
||||
]
|
@@ -247,6 +247,20 @@ class GenericDocument(Document):
|
||||
verbose_name_plural = "Generic Documents"
|
||||
|
||||
|
||||
class Shop(models.Model):
|
||||
name = models.CharField(max_length=128, unique=True)
|
||||
country = CountryField(blank=True)
|
||||
website = models.URLField(blank=True)
|
||||
on_line = models.BooleanField(default=True)
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
ordering = [models.functions.Lower("name"),]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
@receiver(models.signals.pre_save, sender=Manufacturer)
|
||||
@receiver(models.signals.pre_save, sender=Company)
|
||||
@receiver(models.signals.pre_save, sender=Scale)
|
||||
|
Reference in New Issue
Block a user