diff --git a/dhub/urls.py b/dhub/urls.py index 9bd6fb4..6305b93 100644 --- a/dhub/urls.py +++ b/dhub/urls.py @@ -22,4 +22,5 @@ urlpatterns = [ path("", include("login.urls")), path("dashboard/", include("dashboard.urls")), path("device/", include("device.urls")), + path("lot/", include("lot.urls")), ] diff --git a/lot/migrations/0001_initial.py b/lot/migrations/0001_initial.py new file mode 100644 index 0000000..35ca297 --- /dev/null +++ b/lot/migrations/0001_initial.py @@ -0,0 +1,58 @@ +# Generated by Django 5.0.6 on 2024-07-08 13:55 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ("device", "0003_remove_component_type_remove_computer_type_and_more"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name="Lot", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(auto_now_add=True)), + ("updated", models.DateTimeField(auto_now=True)), + ( + "type", + models.CharField( + choices=[ + ("Incoming", "Incoming"), + ("Outgoing", "Outgoing"), + ("Temporal", "Temporal"), + ], + default="Temporal", + max_length=32, + ), + ), + ("name", models.CharField(blank=True, max_length=64, null=True)), + ("code", models.CharField(blank=True, max_length=64, null=True)), + ("description", models.CharField(blank=True, max_length=64, null=True)), + ("closed", models.BooleanField(default=True)), + ("devices", models.ManyToManyField(to="device.device")), + ( + "owner", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + ), + ), + ], + ), + ] diff --git a/lot/models.py b/lot/models.py index 71a8362..9f33e57 100644 --- a/lot/models.py +++ b/lot/models.py @@ -1,3 +1,23 @@ from django.db import models +from django.utils.translation import gettext_lazy as _ +from utils.constants import STR_SM_SIZE, STR_SIZE -# Create your models here. +from user.models import User +from device.models import Device + + +class Lot(models.Model): + class Types(models.TextChoices): + INCOMING = "Incoming" + OUTGOING = "Outgoing" + TEMPORAL = "Temporal" + + created = models.DateTimeField(auto_now_add=True) + updated = models.DateTimeField(auto_now=True) + type = models.CharField(max_length=STR_SM_SIZE, choices=Types, default=Types.TEMPORAL) + name = models.CharField(max_length=STR_SIZE, blank=True, null=True) + code = models.CharField(max_length=STR_SIZE, blank=True, null=True) + description = models.CharField(max_length=STR_SIZE, blank=True, null=True) + closed = models.BooleanField(default=True) + owner = models.ForeignKey(User, on_delete=models.CASCADE) + devices = models.ManyToManyField(Device) diff --git a/lot/templates/new_lot.html b/lot/templates/new_lot.html new file mode 100644 index 0000000..8f2df37 --- /dev/null +++ b/lot/templates/new_lot.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} +