diff --git a/asset/__init__.py b/asset/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/asset/admin.py b/asset/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/asset/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/asset/apps.py b/asset/apps.py new file mode 100644 index 0000000..46953e7 --- /dev/null +++ b/asset/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AssetConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'asset' diff --git a/asset/migrations/0001_initial.py b/asset/migrations/0001_initial.py new file mode 100644 index 0000000..a1f8be8 --- /dev/null +++ b/asset/migrations/0001_initial.py @@ -0,0 +1,30 @@ +# Generated by Django 3.2.12 on 2022-03-10 16:09 + +import asset.models +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Asset', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=40)), + ('description', models.CharField(blank=True, max_length=250)), + ('quantity', models.IntegerField(default=1)), + ('created_ts', models.DateTimeField(auto_now_add=True, verbose_name='datetime created')), + ('changed_ts', models.DateTimeField(auto_now=True, verbose_name='datetime updated')), + ('changed_by', models.ForeignKey(on_delete=models.SET(asset.models.get_sentinel_user), related_name='changed_assets', to=settings.AUTH_USER_MODEL)), + ('created_by', models.ForeignKey(on_delete=models.SET(asset.models.get_sentinel_user), related_name='created_assets', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/asset/migrations/0002_auto_20220310_1620.py b/asset/migrations/0002_auto_20220310_1620.py new file mode 100644 index 0000000..a5d5340 --- /dev/null +++ b/asset/migrations/0002_auto_20220310_1620.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.12 on 2022-03-10 16:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('asset', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='asset', + name='name', + ), + migrations.AddField( + model_name='asset', + name='named_id', + field=models.CharField(default='defval', max_length=40, unique=True), + preserve_default=False, + ), + ] diff --git a/asset/migrations/__init__.py b/asset/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/asset/models.py b/asset/models.py new file mode 100644 index 0000000..eb0c85c --- /dev/null +++ b/asset/models.py @@ -0,0 +1,18 @@ +from django.db import models +from django.conf import settings +from django.contrib.auth import get_user_model +# from django.contrib.auth.models import User +from container.models import Container + +def get_sentinel_user(): + return get_user_model().objects.get_or_create(username='deleted')[0] + +class Asset(models.Model): + named_id = models.CharField(max_length=40, unique=True) + description = models.CharField(max_length=250, blank=True) + quantity = models.IntegerField(default=1) + created_ts = models.DateTimeField('datetime created', auto_now_add=True) + created_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET(get_sentinel_user), related_name='created_assets') + changed_ts = models.DateTimeField('datetime updated', auto_now=True) + changed_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET(get_sentinel_user), related_name='changed_assets') + diff --git a/asset/templates/asset/asset_confirm_delete.html b/asset/templates/asset/asset_confirm_delete.html new file mode 100644 index 0000000..bf4a076 --- /dev/null +++ b/asset/templates/asset/asset_confirm_delete.html @@ -0,0 +1,6 @@ +{% extends 'base.html' %} +{% load statics %} + +{% block content %} +
No new assets are available.
+ {% endif %} +