mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 21:27:49 +02:00
Fix the API
This commit is contained in:
@@ -6,7 +6,7 @@ from roster.models import (
|
||||
@admin.register(RollingClass)
|
||||
class RollingClass(admin.ModelAdmin):
|
||||
list_display = ('__str__', 'type', 'company')
|
||||
list_filter = ('type', 'company')
|
||||
list_filter = ('company', 'type__category', 'type')
|
||||
search_fields = list_display
|
||||
|
||||
|
||||
@@ -28,8 +28,11 @@ class RollingStockAdmin(admin.ModelAdmin):
|
||||
inlines = (RollingStockImageInline, RollingStockDocInline)
|
||||
readonly_fields = ('creation_time', 'updated_time')
|
||||
list_display = (
|
||||
'__str__', 'manufacturer', 'scale', 'sku', 'company', 'country')
|
||||
list_filter = ('manufacturer', 'scale')
|
||||
'__str__', 'address', 'manufacturer',
|
||||
'scale', 'sku', 'company', 'country')
|
||||
list_filter = (
|
||||
'rolling_class__type__category', 'rolling_class__type',
|
||||
'scale', 'manufacturer')
|
||||
search_fields = list_display
|
||||
|
||||
fieldsets = (
|
||||
|
18
dcc/roster/migrations/0003_rollingstockimage_description.py
Normal file
18
dcc/roster/migrations/0003_rollingstockimage_description.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.2 on 2022-04-02 17:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('roster', '0002_rename_class_rollingclass_alter_rollingclass_options_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='rollingstockimage',
|
||||
name='description',
|
||||
field=models.CharField(blank=True, max_length=256),
|
||||
),
|
||||
]
|
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.0.2 on 2022-04-02 17:17
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('roster', '0003_rollingstockimage_description'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='rollingstockimage',
|
||||
name='description',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='rollingclass',
|
||||
name='description',
|
||||
field=models.CharField(blank=True, max_length=256),
|
||||
),
|
||||
]
|
@@ -20,6 +20,7 @@ class RollingClass(models.Model):
|
||||
type = models.ForeignKey(
|
||||
RollingStockType, on_delete=models.CASCADE,
|
||||
null=True, blank=True)
|
||||
description = models.CharField(max_length=256, blank=True)
|
||||
company = models.ForeignKey(
|
||||
Company, on_delete=models.CASCADE,
|
||||
null=True, blank=True)
|
||||
|
@@ -1,13 +1,25 @@
|
||||
from rest_framework import serializers
|
||||
from roster.models import RollingStock
|
||||
from roster.models import RollingClass, RollingStock
|
||||
from metadata.serializers import (
|
||||
ManufacturerSerializer, CompanySerializer, DecoderSerializer)
|
||||
RollingStockTypeSerializer, ManufacturerSerializer, ScaleSerializer,
|
||||
CompanySerializer, DecoderSerializer, TagSerializer)
|
||||
|
||||
|
||||
class RollingClassSerializer(serializers.ModelSerializer):
|
||||
company = CompanySerializer()
|
||||
type = RollingStockTypeSerializer()
|
||||
|
||||
class Meta:
|
||||
model = RollingClass
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class RollingStockSerializer(serializers.ModelSerializer):
|
||||
rolling_class = RollingClassSerializer()
|
||||
manufacturer = ManufacturerSerializer()
|
||||
decoder = DecoderSerializer()
|
||||
company = CompanySerializer()
|
||||
scale = ScaleSerializer()
|
||||
tags = TagSerializer(many=True)
|
||||
|
||||
class Meta:
|
||||
model = RollingStock
|
||||
|
Reference in New Issue
Block a user