Things added, WIP
Some checks are pending
SonarQube Scan / SonarQube Trigger (push) Waiting to run
Build containers when image tags change / build-if-image-changed (., web, containers, main container, git.baumann.gr/adebaumann/labhelper) (push) Successful in 7s
Build containers when image tags change / build-if-image-changed (data-loader, loader, initContainers, init-container, git.baumann.gr/adebaumann/labhelper-data-loader) (push) Successful in 7s

This commit is contained in:
2025-12-28 20:20:57 +01:00
parent fe3b1f00ba
commit ac6bd2f666
9 changed files with 101 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
from django.contrib import admin
from .models import Box, BoxType
from .models import Box, BoxType, Thing, ThingType
@admin.register(BoxType)
@@ -18,3 +18,20 @@ class BoxAdmin(admin.ModelAdmin):
list_display = ('id', 'box_type')
list_filter = ('box_type',)
search_fields = ('id',)
@admin.register(ThingType)
class ThingTypeAdmin(admin.ModelAdmin):
"""Admin configuration for ThingType model."""
list_display = ('name',)
search_fields = ('name',)
@admin.register(Thing)
class ThingAdmin(admin.ModelAdmin):
"""Admin configuration for Thing model."""
list_display = ('name', 'thing_type', 'box')
list_filter = ('thing_type', 'box')
search_fields = ('name', 'description')

View File

@@ -0,0 +1,38 @@
# Generated by Django 5.2.9 on 2025-12-28 19:06
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('boxes', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='ThingType',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True)),
],
options={
'ordering': ['name'],
},
),
migrations.CreateModel(
name='Thing',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('description', models.TextField(blank=True)),
('picture', models.ImageField(blank=True, upload_to='things/')),
('box', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='things', to='boxes.box')),
('thing_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='things', to='boxes.thingtype')),
],
options={
'ordering': ['name'],
},
),
]

View File

@@ -35,3 +35,39 @@ class Box(models.Model):
def __str__(self):
return self.id
class ThingType(models.Model):
"""A type/category for things stored in boxes."""
name = models.CharField(max_length=255, unique=True)
class Meta:
ordering = ['name']
def __str__(self):
return self.name
class Thing(models.Model):
"""An item stored in a box."""
name = models.CharField(max_length=255)
thing_type = models.ForeignKey(
ThingType,
on_delete=models.PROTECT,
related_name='things'
)
box = models.ForeignKey(
Box,
on_delete=models.PROTECT,
related_name='things'
)
description = models.TextField(blank=True)
picture = models.ImageField(upload_to='things/', blank=True)
class Meta:
ordering = ['name']
def __str__(self):
return self.name