This commit is contained in:
j3d1 2024-05-22 20:20:57 +02:00
parent 1d6a6c765e
commit c243ceb2ac
3 changed files with 50 additions and 2 deletions

View file

@ -1,6 +1,6 @@
from django.contrib import admin
from tickets.models import IssueThread, Comment, StateChange, Assignment, ShippingVoucher
from tickets.models import IssueThread, Comment, StateChange, Assignment, ItemRelation, ShippingVoucher
class IssueThreadAdmin(admin.ModelAdmin):
@ -19,6 +19,10 @@ class AssignmentAdmin(admin.ModelAdmin):
pass
class ItemRelationAdmin(admin.ModelAdmin):
pass
class ShippingVouchersAdmin(admin.ModelAdmin):
pass
@ -27,4 +31,5 @@ admin.site.register(IssueThread, IssueThreadAdmin)
admin.site.register(Comment, CommentAdmin)
admin.site.register(StateChange, StateChangeAdmin)
admin.site.register(Assignment, AssignmentAdmin)
admin.site.register(ItemRelation, ItemRelationAdmin)
admin.site.register(ShippingVoucher, ShippingVouchersAdmin)

View file

@ -0,0 +1,25 @@
# Generated by Django 4.2.7 on 2024-05-22 18:19
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('inventory', '0004_alter_event_created_at_alter_item_created_at'),
('tickets', '0009_issuethread_event'),
]
operations = [
migrations.CreateModel(
name='ItemRelation',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('timestamp', models.DateTimeField(auto_now_add=True)),
('status', models.CharField(choices=[('possible', 'Possible'), ('confirmed', 'Confirmed'), ('discarded', 'Discarded'), ('provided', 'Provided')], default='possible', max_length=255)),
('issue_thread', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='item_relations', to='tickets.issuethread')),
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='issues', to='inventory.item')),
],
),
]

View file

@ -3,7 +3,7 @@ from django.utils import timezone
from django_softdelete.models import SoftDeleteModel
from authentication.models import ExtendedUser
from inventory.models import Event
from inventory.models import Event, Item
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
@ -29,6 +29,13 @@ STATE_CHOICES = (
('found_closed', 'Item Found and stored externally and closed'),
)
RELATION_STATUS_CHOICES = (
('possible', 'Possible'),
('confirmed', 'Confirmed'),
('discarded', 'Discarded'),
('provided', 'Provided'),
)
class IssueThread(SoftDeleteModel):
id = models.AutoField(primary_key=True)
@ -120,6 +127,17 @@ class Assignment(models.Model):
return str(self.issue_thread) + ' assigned to ' + self.assigned_to.username
class ItemRelation(models.Model):
id = models.AutoField(primary_key=True)
issue_thread = models.ForeignKey(IssueThread, on_delete=models.CASCADE, related_name='item_relations')
item = models.ForeignKey(Item, on_delete=models.CASCADE, related_name='issues')
timestamp = models.DateTimeField(auto_now_add=True)
status = models.CharField(max_length=255, choices=RELATION_STATUS_CHOICES, default='possible')
def __str__(self):
return str(self.issue_thread) + ' related to ' + str(self.item)
class ShippingVoucher(models.Model):
id = models.AutoField(primary_key=True)
issue_thread = models.ForeignKey(IssueThread, on_delete=models.CASCADE, related_name='shipping_vouchers', null=True)