mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 21:27:49 +02:00
Add properties
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import os
|
||||
from uuid import uuid4
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
# from django.core.files.storage import FileSystemStorage
|
||||
# from django.dispatch import receiver
|
||||
|
||||
from dcc.utils import get_image_preview
|
||||
from metadata.models import (
|
||||
Property,
|
||||
Scale,
|
||||
Manufacturer,
|
||||
Decoder,
|
||||
@@ -27,15 +27,14 @@ class RollingClass(models.Model):
|
||||
type = models.ForeignKey(
|
||||
RollingStockType, on_delete=models.CASCADE, null=True, blank=True
|
||||
)
|
||||
company = models.ForeignKey(
|
||||
Company, 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
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["company", "identifier"]
|
||||
@@ -46,6 +45,21 @@ class RollingClass(models.Model):
|
||||
return "{0} {1}".format(self.company, self.identifier)
|
||||
|
||||
|
||||
class RollingClassProperty(models.Model):
|
||||
rolling_class = models.ForeignKey(
|
||||
RollingClass,
|
||||
on_delete=models.CASCADE,
|
||||
null=False,
|
||||
blank=False,
|
||||
verbose_name="Class",
|
||||
)
|
||||
property = models.ForeignKey(Property, on_delete=models.CASCADE)
|
||||
value = models.CharField(max_length=256)
|
||||
|
||||
def __str__(self):
|
||||
return self.property.name
|
||||
|
||||
|
||||
class RollingStock(models.Model):
|
||||
uuid = models.UUIDField(primary_key=True, default=uuid4, editable=False)
|
||||
rolling_class = models.ForeignKey(
|
||||
|
Reference in New Issue
Block a user