Registered all models
This commit is contained in:
@@ -1,5 +1,21 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import Part
|
from .models.box import Box, BoxAdmin
|
||||||
|
from .models.part import Part, PartAdmin
|
||||||
|
from .models.vendor import Vendor, VendorAdmin
|
||||||
|
from .models.formone import FormOne,FormOneAdmin
|
||||||
|
from .models.customer import Customer, CustomerAdmin
|
||||||
|
from .models.plane import Plane, PlaneAdmin
|
||||||
|
from .models.workorder import Workorder, WorkorderAdmin
|
||||||
|
from .models.operator import Operator, OperatorAdmin
|
||||||
|
from .models.movimag import Movimag, MovimagAdmin
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
admin.site.register(Part)
|
admin.site.register(Box, BoxAdmin)
|
||||||
|
admin.site.register(Part, PartAdmin)
|
||||||
|
admin.site.register(Vendor, VendorAdmin)
|
||||||
|
admin.site.register(FormOne,FormOneAdmin)
|
||||||
|
admin.site.register(Customer, CustomerAdmin)
|
||||||
|
admin.site.register(Plane, PlaneAdmin)
|
||||||
|
admin.site.register(Workorder, WorkorderAdmin)
|
||||||
|
admin.site.register(Operator, OperatorAdmin)
|
||||||
|
admin.site.register(Movimag, MovimagAdmin)
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
# Generated by Django 5.1.2 on 2024-10-18 15:45
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.db.models.functions.datetime
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('catops', '0002_rename_parts_part'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='FormOne',
|
||||||
|
fields=[
|
||||||
|
('reg_date', models.DateTimeField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False)),
|
||||||
|
('id', models.BigAutoField(primary_key=True, serialize=False)),
|
||||||
|
('external_id', models.CharField(db_index=True, null=True)),
|
||||||
|
('doc_path', models.FilePathField(null=True)),
|
||||||
|
('active', models.BooleanField(db_default=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='active',
|
||||||
|
field=models.BooleanField(db_default=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='expiry_time',
|
||||||
|
field=models.DurationField(null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='last_stock',
|
||||||
|
field=models.DateField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='min_reorder',
|
||||||
|
field=models.PositiveIntegerField(null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='part_number',
|
||||||
|
field=models.CharField(db_index=True, default='aaa', max_length=64, unique=True),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='properties',
|
||||||
|
field=models.JSONField(null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='quantity',
|
||||||
|
field=models.PositiveIntegerField(default=0),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='reg_date',
|
||||||
|
field=models.DateTimeField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='serial_number',
|
||||||
|
field=models.CharField(db_index=True, max_length=64, null=True, unique=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='unit',
|
||||||
|
field=models.CharField(choices=[('QTY', 'Quantity'), ('LT', 'Liters'), ('USG', 'US Gallons'), ('QTS', 'US Quarters'), ('KG', 'Kilograms'), ('LBS', 'Pounds')], default='QTY'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='part',
|
||||||
|
name='id',
|
||||||
|
field=models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Box',
|
||||||
|
fields=[
|
||||||
|
('reg_date', models.DateTimeField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False)),
|
||||||
|
('id', models.UUIDField(db_index=True, default=uuid.uuid1, editable=False, primary_key=True, serialize=False)),
|
||||||
|
('loc_room', models.CharField(choices=[('ST1', 'Magazzino'), ('ST2', 'Deposito Esterno')], default='ST1', max_length=3)),
|
||||||
|
('loc_x', models.CharField(max_length=4)),
|
||||||
|
('loc_y', models.CharField(max_length=4)),
|
||||||
|
('loc_z', models.CharField(max_length=4)),
|
||||||
|
('active', models.BooleanField(db_default=True)),
|
||||||
|
('label_printed', models.BooleanField(db_default=False)),
|
||||||
|
('part', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='catops.part')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='part',
|
||||||
|
name='form_one',
|
||||||
|
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='catops.formone'),
|
||||||
|
),
|
||||||
|
]
|
||||||
22
techdb/catops/migrations/0004_vendor.py
Normal file
22
techdb/catops/migrations/0004_vendor.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 5.1.2 on 2024-10-18 15:45
|
||||||
|
|
||||||
|
import django.db.models.functions.datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('catops', '0003_formone_part_active_part_expiry_time_part_last_stock_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Vendor',
|
||||||
|
fields=[
|
||||||
|
('reg_date', models.DateTimeField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False)),
|
||||||
|
('id', models.UUIDField(primary_key=True, serialize=False)),
|
||||||
|
('active', models.BooleanField(db_default=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
26
techdb/catops/migrations/0005_customer.py
Normal file
26
techdb/catops/migrations/0005_customer.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 5.1.2 on 2024-10-18 15:45
|
||||||
|
|
||||||
|
import django.db.models.functions.datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('catops', '0004_vendor'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Customer',
|
||||||
|
fields=[
|
||||||
|
('reg_date', models.DateTimeField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False)),
|
||||||
|
('id', models.BigAutoField(primary_key=True, serialize=False)),
|
||||||
|
('name', models.CharField(max_length=32)),
|
||||||
|
('surname', models.CharField(max_length=32)),
|
||||||
|
('external_id', models.CharField(db_index=True, null=True)),
|
||||||
|
('properties', models.JSONField(null=True)),
|
||||||
|
('active', models.BooleanField(db_default=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
30
techdb/catops/migrations/0006_plane.py
Normal file
30
techdb/catops/migrations/0006_plane.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Generated by Django 5.1.2 on 2024-10-18 15:46
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.db.models.functions.datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('catops', '0005_customer'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Plane',
|
||||||
|
fields=[
|
||||||
|
('reg_date', models.DateTimeField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False)),
|
||||||
|
('id', models.BigAutoField(primary_key=True, serialize=False)),
|
||||||
|
('tail', models.CharField(max_length=6)),
|
||||||
|
('manufacturer', models.CharField(max_length=32)),
|
||||||
|
('model', models.CharField(max_length=32)),
|
||||||
|
('chassis_num', models.CharField(max_length=32)),
|
||||||
|
('external_id', models.CharField(db_index=True, null=True)),
|
||||||
|
('properties', models.JSONField(null=True)),
|
||||||
|
('active', models.BooleanField(db_default=True)),
|
||||||
|
('customer', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='catops.customer')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
41
techdb/catops/migrations/0007_operator_workorder.py
Normal file
41
techdb/catops/migrations/0007_operator_workorder.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Generated by Django 5.1.2 on 2024-10-18 15:47
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.db.models.functions.datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('catops', '0006_plane'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Operator',
|
||||||
|
fields=[
|
||||||
|
('reg_date', models.DateTimeField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False)),
|
||||||
|
('id', models.BigAutoField(primary_key=True, serialize=False)),
|
||||||
|
('name', models.CharField(max_length=32)),
|
||||||
|
('surname', models.CharField(max_length=32)),
|
||||||
|
('external_id', models.CharField(db_index=True, null=True)),
|
||||||
|
('properties', models.JSONField(null=True)),
|
||||||
|
('active', models.BooleanField(db_default=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Workorder',
|
||||||
|
fields=[
|
||||||
|
('reg_date', models.DateTimeField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False)),
|
||||||
|
('id', models.BigAutoField(primary_key=True, serialize=False)),
|
||||||
|
('date_begin', models.DateTimeField(db_default=django.db.models.functions.datetime.Now())),
|
||||||
|
('date_end', models.DateTimeField()),
|
||||||
|
('external_id', models.CharField(db_index=True, max_length=32, null=True)),
|
||||||
|
('properties', models.JSONField(null=True)),
|
||||||
|
('active', models.BooleanField(db_default=True)),
|
||||||
|
('operator', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='catops.operator')),
|
||||||
|
('plane', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='catops.plane')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
26
techdb/catops/migrations/0008_movimag.py
Normal file
26
techdb/catops/migrations/0008_movimag.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 5.1.2 on 2024-10-18 15:47
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.db.models.functions.datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('catops', '0007_operator_workorder'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Movimag',
|
||||||
|
fields=[
|
||||||
|
('mov_datetime', models.DateTimeField(auto_created=True, db_default=django.db.models.functions.datetime.Now(), editable=False)),
|
||||||
|
('id', models.BigAutoField(primary_key=True, serialize=False)),
|
||||||
|
('direction', models.CharField(choices=[('LOAD', 'Load'), ('UNLOAD', 'UnLoad')])),
|
||||||
|
('operator', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='catops.operator')),
|
||||||
|
('part', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='catops.part')),
|
||||||
|
('workorder', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='catops.workorder')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
0
techdb/catops/misc/__init__.py
Normal file
0
techdb/catops/misc/__init__.py
Normal file
19
techdb/catops/misc/units.py
Normal file
19
techdb/catops/misc/units.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
class RoomLocation(models.TextChoices):
|
||||||
|
STORAGE_1 = "ST1", _("Magazzino")
|
||||||
|
STORAGE_2 = "ST2", _("Deposito Esterno")
|
||||||
|
|
||||||
|
class Units(models.TextChoices):
|
||||||
|
NUM = "QTY", _("Quantity")
|
||||||
|
LT = "LT", _("Liters")
|
||||||
|
USG = "USG", _("US Gallons")
|
||||||
|
QTS = "QTS", _("US Quarters")
|
||||||
|
KG = "KG", _("Kilograms")
|
||||||
|
LBS = "LBS", _("Pounds")
|
||||||
|
|
||||||
|
class MoviDirection(models.TextChoices):
|
||||||
|
LOAD = "LOAD", _("Load")
|
||||||
|
UNLOAD = "UNLOAD", _("UnLoad")
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
# These models represent the actual data structure organization of the storage.
|
|
||||||
|
|
||||||
class Part(models.Model):
|
|
||||||
id = models.UUIDField(primary_key=True)
|
|
||||||
|
|
||||||
0
techdb/catops/models/__init__.py
Normal file
0
techdb/catops/models/__init__.py
Normal file
69
techdb/catops/models/box.py
Normal file
69
techdb/catops/models/box.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.db.models.functions import Now
|
||||||
|
from .part import Part
|
||||||
|
from ..misc.units import RoomLocation
|
||||||
|
|
||||||
|
# Box identifies a part storage location, it can be a drawer or a bag or a carbord box.
|
||||||
|
# It has a location and one or multiple parts inside it.
|
||||||
|
|
||||||
|
# Properties to visualize the Box model in the Django admin view
|
||||||
|
class BoxAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ("id", "loc_room", "loc_x", "loc_y", "loc_z", "reg_date", "active")
|
||||||
|
list_filter = ["loc_room"]
|
||||||
|
|
||||||
|
class Box(models.Model):
|
||||||
|
id = models.UUIDField(
|
||||||
|
primary_key=True,
|
||||||
|
default=uuid.uuid1,
|
||||||
|
db_index=True,
|
||||||
|
editable=False,
|
||||||
|
serialize=str,
|
||||||
|
)
|
||||||
|
|
||||||
|
reg_date = models.DateTimeField(
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now(),
|
||||||
|
)
|
||||||
|
|
||||||
|
loc_room = models.CharField(
|
||||||
|
max_length=3,
|
||||||
|
choices=RoomLocation,
|
||||||
|
default=RoomLocation.STORAGE_1,
|
||||||
|
null=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
loc_x = models.CharField(
|
||||||
|
max_length=4,
|
||||||
|
)
|
||||||
|
|
||||||
|
loc_y = models.CharField(
|
||||||
|
max_length=4,
|
||||||
|
)
|
||||||
|
|
||||||
|
loc_z = models.CharField(
|
||||||
|
max_length=4,
|
||||||
|
)
|
||||||
|
|
||||||
|
active = models.BooleanField(
|
||||||
|
db_default=True
|
||||||
|
)
|
||||||
|
|
||||||
|
label_printed = models.BooleanField(
|
||||||
|
db_default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
part = models.OneToOneField(
|
||||||
|
Part,
|
||||||
|
unique=True,
|
||||||
|
db_index=True,
|
||||||
|
swappable=True,
|
||||||
|
null=True,
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{str(self.id)}"
|
||||||
39
techdb/catops/models/customer.py
Normal file
39
techdb/catops/models/customer.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.db.models.functions import Now
|
||||||
|
|
||||||
|
class CustomerAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ()
|
||||||
|
list_filter = []
|
||||||
|
|
||||||
|
class Customer(models.Model):
|
||||||
|
id = models.BigAutoField(
|
||||||
|
primary_key=True
|
||||||
|
)
|
||||||
|
|
||||||
|
reg_date = models.DateTimeField(
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
name = models.CharField(
|
||||||
|
max_length=32
|
||||||
|
)
|
||||||
|
|
||||||
|
surname = models.CharField(
|
||||||
|
max_length=32
|
||||||
|
)
|
||||||
|
|
||||||
|
external_id = models.CharField(
|
||||||
|
db_index=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
properties = models.JSONField(
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
active = models.BooleanField(
|
||||||
|
db_default=True
|
||||||
|
)
|
||||||
31
techdb/catops/models/formone.py
Normal file
31
techdb/catops/models/formone.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.db.models.functions import Now
|
||||||
|
|
||||||
|
class FormOneAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ()
|
||||||
|
list_filter = []
|
||||||
|
|
||||||
|
class FormOne(models.Model):
|
||||||
|
id = models.BigAutoField(
|
||||||
|
primary_key=True
|
||||||
|
)
|
||||||
|
|
||||||
|
reg_date = models.DateTimeField(
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
external_id = models.CharField(
|
||||||
|
db_index=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
doc_path = models.FilePathField(
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
active = models.BooleanField(
|
||||||
|
db_default=True
|
||||||
|
)
|
||||||
43
techdb/catops/models/movimag.py
Normal file
43
techdb/catops/models/movimag.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.db.models.functions import Now
|
||||||
|
|
||||||
|
from .part import Part
|
||||||
|
from .operator import Operator
|
||||||
|
from .workorder import Workorder
|
||||||
|
from ..misc import units
|
||||||
|
|
||||||
|
class MovimagAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ()
|
||||||
|
list_filter = []
|
||||||
|
|
||||||
|
class Movimag(models.Model):
|
||||||
|
id = models.BigAutoField(
|
||||||
|
primary_key=True
|
||||||
|
)
|
||||||
|
|
||||||
|
mov_datetime = models.DateTimeField(
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
part = models.ForeignKey(
|
||||||
|
Part,
|
||||||
|
on_delete=models.DO_NOTHING
|
||||||
|
)
|
||||||
|
|
||||||
|
workorder = models.ForeignKey(
|
||||||
|
Workorder,
|
||||||
|
on_delete=models.DO_NOTHING
|
||||||
|
)
|
||||||
|
|
||||||
|
operator = models.ForeignKey(
|
||||||
|
Operator,
|
||||||
|
on_delete=models.DO_NOTHING
|
||||||
|
)
|
||||||
|
|
||||||
|
direction = models.CharField(
|
||||||
|
null=False,
|
||||||
|
choices=units.MoviDirection
|
||||||
|
)
|
||||||
39
techdb/catops/models/operator.py
Normal file
39
techdb/catops/models/operator.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.db.models.functions import Now
|
||||||
|
|
||||||
|
class OperatorAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ()
|
||||||
|
list_filter = ()
|
||||||
|
|
||||||
|
class Operator(models.Model):
|
||||||
|
id = models.BigAutoField(
|
||||||
|
primary_key=True
|
||||||
|
)
|
||||||
|
|
||||||
|
reg_date = models.DateTimeField(
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
name = models.CharField(
|
||||||
|
max_length=32
|
||||||
|
)
|
||||||
|
|
||||||
|
surname = models.CharField(
|
||||||
|
max_length=32
|
||||||
|
)
|
||||||
|
|
||||||
|
external_id = models.CharField(
|
||||||
|
db_index=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
properties = models.JSONField(
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
active = models.BooleanField(
|
||||||
|
db_default=True
|
||||||
|
)
|
||||||
87
techdb/catops/models/part.py
Normal file
87
techdb/catops/models/part.py
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.db.models.functions import Now
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from ..misc.units import Units
|
||||||
|
from .formone import FormOne
|
||||||
|
|
||||||
|
# Part identifies a part with its part number and associated properties:
|
||||||
|
# such as torage quantity, min reorder quantities and expiry date.
|
||||||
|
|
||||||
|
class PartAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ()
|
||||||
|
list_filter = ()
|
||||||
|
|
||||||
|
class Part(models.Model):
|
||||||
|
id = models.UUIDField(
|
||||||
|
primary_key=True,
|
||||||
|
default=uuid.uuid4,
|
||||||
|
db_index=True,
|
||||||
|
editable=False,
|
||||||
|
serialize=str
|
||||||
|
)
|
||||||
|
|
||||||
|
reg_date = models.DateTimeField(
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
part_number = models.CharField(
|
||||||
|
db_index=True,
|
||||||
|
max_length=64,
|
||||||
|
null=False,
|
||||||
|
unique=True
|
||||||
|
)
|
||||||
|
|
||||||
|
serial_number = models.CharField(
|
||||||
|
db_index=True,
|
||||||
|
max_length=64,
|
||||||
|
null=True,
|
||||||
|
unique=True
|
||||||
|
)
|
||||||
|
|
||||||
|
quantity = models.PositiveIntegerField(
|
||||||
|
null=False,
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
|
||||||
|
unit = models.CharField(
|
||||||
|
choices=Units,
|
||||||
|
default=Units.NUM,
|
||||||
|
null=False
|
||||||
|
)
|
||||||
|
|
||||||
|
last_stock = models.DateField(
|
||||||
|
null=False,
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
expiry_time = models.DurationField(
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
min_reorder = models.PositiveIntegerField(
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
properties = models.JSONField(
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
form_one = models.OneToOneField(
|
||||||
|
FormOne,
|
||||||
|
on_delete=models.DO_NOTHING,
|
||||||
|
db_index=True,
|
||||||
|
unique=True,
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
active = models.BooleanField(
|
||||||
|
db_default=True
|
||||||
|
)
|
||||||
59
techdb/catops/models/plane.py
Normal file
59
techdb/catops/models/plane.py
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.db.models.functions import Now
|
||||||
|
|
||||||
|
from .customer import Customer
|
||||||
|
|
||||||
|
class PlaneAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ()
|
||||||
|
list_filter = []
|
||||||
|
|
||||||
|
class Plane(models.Model):
|
||||||
|
id = models.BigAutoField(
|
||||||
|
primary_key=True
|
||||||
|
)
|
||||||
|
|
||||||
|
reg_date = models.DateTimeField(
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
tail = models.CharField(
|
||||||
|
max_length=6,
|
||||||
|
null=False
|
||||||
|
)
|
||||||
|
|
||||||
|
manufacturer = models.CharField(
|
||||||
|
max_length=32,
|
||||||
|
null=False
|
||||||
|
)
|
||||||
|
|
||||||
|
model = models.CharField(
|
||||||
|
max_length=32,
|
||||||
|
null=False
|
||||||
|
)
|
||||||
|
|
||||||
|
chassis_num = models.CharField(
|
||||||
|
max_length=32,
|
||||||
|
null=False
|
||||||
|
)
|
||||||
|
|
||||||
|
external_id = models.CharField(
|
||||||
|
db_index=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
customer = models.ForeignKey(
|
||||||
|
Customer,
|
||||||
|
on_delete=models.DO_NOTHING
|
||||||
|
)
|
||||||
|
|
||||||
|
properties = models.JSONField(
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
active = models.BooleanField(
|
||||||
|
db_default=True
|
||||||
|
)
|
||||||
|
|
||||||
23
techdb/catops/models/vendor.py
Normal file
23
techdb/catops/models/vendor.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.db.models.functions import Now
|
||||||
|
|
||||||
|
class VendorAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ()
|
||||||
|
list_filter = ()
|
||||||
|
|
||||||
|
class Vendor(models.Model):
|
||||||
|
id = models.UUIDField(primary_key=True)
|
||||||
|
|
||||||
|
reg_date = models.DateTimeField(
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
active = models.BooleanField(
|
||||||
|
db_default=True
|
||||||
|
)
|
||||||
|
|
||||||
54
techdb/catops/models/workorder.py
Normal file
54
techdb/catops/models/workorder.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.db.models.functions import Now
|
||||||
|
|
||||||
|
from .plane import Plane
|
||||||
|
from .operator import Operator
|
||||||
|
|
||||||
|
class WorkorderAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ()
|
||||||
|
list_filter = []
|
||||||
|
|
||||||
|
class Workorder(models.Model):
|
||||||
|
id = models.BigAutoField(
|
||||||
|
primary_key=True
|
||||||
|
)
|
||||||
|
|
||||||
|
reg_date = models.DateTimeField(
|
||||||
|
auto_created=True,
|
||||||
|
editable=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
date_begin = models.DateTimeField(
|
||||||
|
null=False,
|
||||||
|
db_default=Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
date_end = models.DateTimeField(
|
||||||
|
null=False
|
||||||
|
)
|
||||||
|
|
||||||
|
external_id = models.CharField(
|
||||||
|
max_length=32,
|
||||||
|
db_index=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
plane = models.ForeignKey(
|
||||||
|
Plane,
|
||||||
|
on_delete=models.DO_NOTHING
|
||||||
|
)
|
||||||
|
|
||||||
|
operator = models.ForeignKey(
|
||||||
|
Operator,
|
||||||
|
on_delete=models.DO_NOTHING
|
||||||
|
)
|
||||||
|
|
||||||
|
properties = models.JSONField(
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
active = models.BooleanField(
|
||||||
|
db_default=True
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user