mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Extend manufacturer and make volume frendly
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -129,5 +129,5 @@ dmypy.json
|
||||
.pyre/
|
||||
|
||||
*.swp
|
||||
dcc/media
|
||||
dcc/storage
|
||||
arduino/CommandStation-EX/build/
|
||||
|
@@ -15,7 +15,7 @@ from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
STORAGE_DIR = BASE_DIR / "storage"
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
||||
@@ -90,7 +90,7 @@ WSGI_APPLICATION = "dcc.wsgi.application"
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": BASE_DIR / "db.sqlite3",
|
||||
"NAME": STORAGE_DIR / "db.sqlite3",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ STATIC_URL = "static/"
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
MEDIA_URL = "media/"
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
MEDIA_ROOT = STORAGE_DIR / "media"
|
||||
|
||||
COUNTRIES_OVERRIDE = {
|
||||
"ZZ": "Freelance",
|
||||
@@ -151,6 +151,11 @@ DECODER_INTERFACES = [
|
||||
(5, "Next18/Next18S"),
|
||||
]
|
||||
|
||||
MANUFACTURER_TYPES = [
|
||||
("model", "Model"),
|
||||
("real", "Real")
|
||||
]
|
||||
|
||||
ROLLING_STOCK_TYPES = [
|
||||
("engine", "Engine"),
|
||||
("car", "Car"),
|
||||
|
@@ -14,12 +14,14 @@ class DecoderAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("image_thumbnail",)
|
||||
list_display = ("__str__", "interface")
|
||||
list_filter = ("manufacturer", "interface")
|
||||
search_fields = ("__str__",)
|
||||
|
||||
|
||||
@admin.register(Scale)
|
||||
class ScaleAdmin(admin.ModelAdmin):
|
||||
list_display = ("scale", "ratio", "gauge")
|
||||
list_filter = ("ratio", "gauge")
|
||||
search_fields = list_display
|
||||
|
||||
|
||||
@admin.register(Company)
|
||||
@@ -27,20 +29,26 @@ class CompanyAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("logo_thumbnail",)
|
||||
list_display = ("name", "country")
|
||||
list_filter = list_display
|
||||
search_fields = ("name",)
|
||||
|
||||
|
||||
@admin.register(Manufacturer)
|
||||
class ManufacturerAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("logo_thumbnail",)
|
||||
list_display = ("name", "category")
|
||||
list_filter = ("category",)
|
||||
search_fields = ("name",)
|
||||
|
||||
|
||||
@admin.register(Tag)
|
||||
class TagAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("slug",)
|
||||
list_display = ("name", "slug")
|
||||
search_fields = ("name",)
|
||||
|
||||
|
||||
@admin.register(RollingStockType)
|
||||
class RollingStockTypeAdmin(admin.ModelAdmin):
|
||||
list_display = ("__str__",)
|
||||
list_filter = ("type", "category")
|
||||
search_fields = list_display
|
||||
|
19
dcc/metadata/migrations/0006_manufacturer_category.py
Normal file
19
dcc/metadata/migrations/0006_manufacturer_category.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-04 19:14
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('metadata', '0005_alter_company_freelance_alter_decoder_sound'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='manufacturer',
|
||||
name='category',
|
||||
field=models.CharField(choices=[('model', 'Model train'), ('real', 'Real train')], default='model', max_length=64),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
18
dcc/metadata/migrations/0007_alter_manufacturer_category.py
Normal file
18
dcc/metadata/migrations/0007_alter_manufacturer_category.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-04 19:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('metadata', '0006_manufacturer_category'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='manufacturer',
|
||||
name='category',
|
||||
field=models.CharField(choices=[('model', 'Model train manufacturer'), ('real', 'Real train manufacturer')], max_length=64),
|
||||
),
|
||||
]
|
@@ -8,9 +8,15 @@ from dcc.utils import get_image_preview, slugify
|
||||
|
||||
class Manufacturer(models.Model):
|
||||
name = models.CharField(max_length=128, unique=True)
|
||||
category = models.CharField(
|
||||
max_length=64, choices=settings.MANUFACTURER_TYPES
|
||||
)
|
||||
website = models.URLField(blank=True)
|
||||
logo = models.ImageField(upload_to="images/", null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["category", "name"]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-04 18:56
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('roster', '0004_remove_rollingstockimage_description_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='rollingclass',
|
||||
name='builder',
|
||||
field=models.CharField(blank=True, max_length=128),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='rollingclass',
|
||||
name='wheel_arrangement',
|
||||
field=models.CharField(blank=True, max_length=8),
|
||||
),
|
||||
]
|
@@ -0,0 +1,29 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-04 19:14
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('metadata', '0006_manufacturer_category'),
|
||||
('roster', '0005_rollingclass_builder_rollingclass_wheel_arrangement'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='rollingclass',
|
||||
name='builder',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='rollingclass',
|
||||
name='manufacturer',
|
||||
field=models.ForeignKey(blank=True, limit_choices_to={'category': 'real'}, null=True, on_delete=django.db.models.deletion.CASCADE, to='metadata.manufacturer'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='rollingstock',
|
||||
name='manufacturer',
|
||||
field=models.ForeignKey(blank=True, limit_choices_to={'category': 'model'}, null=True, on_delete=django.db.models.deletion.CASCADE, to='metadata.manufacturer'),
|
||||
),
|
||||
]
|
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-04 19:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('roster', '0006_remove_rollingclass_builder_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='rollingclass',
|
||||
name='wheel_arrangement',
|
||||
field=models.CharField(blank=True, max_length=64),
|
||||
),
|
||||
]
|
@@ -28,6 +28,11 @@ class RollingClass(models.Model):
|
||||
RollingStockType, on_delete=models.CASCADE, null=True, blank=True
|
||||
)
|
||||
description = models.CharField(max_length=256, blank=True)
|
||||
wheel_arrangement = models.CharField(max_length=64, blank=True)
|
||||
manufacturer = models.ForeignKey(
|
||||
Manufacturer, on_delete=models.CASCADE, null=True, blank=True,
|
||||
limit_choices_to={"category": "real"}
|
||||
)
|
||||
company = models.ForeignKey(
|
||||
Company, on_delete=models.CASCADE, null=True, blank=True
|
||||
)
|
||||
@@ -52,7 +57,8 @@ class RollingStock(models.Model):
|
||||
)
|
||||
road_number = models.CharField(max_length=128, unique=False)
|
||||
manufacturer = models.ForeignKey(
|
||||
Manufacturer, on_delete=models.CASCADE, null=True, blank=True
|
||||
Manufacturer, on_delete=models.CASCADE, null=True, blank=True,
|
||||
limit_choices_to={"category": "model"}
|
||||
)
|
||||
scale = models.ForeignKey(Scale, on_delete=models.CASCADE)
|
||||
sku = models.CharField(max_length=32, blank=True)
|
||||
|
Reference in New Issue
Block a user