stash
This commit is contained in:
parent
d3b832f45a
commit
235bf249e2
3 changed files with 55 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from tickets.models import IssueThread, Comment, StateChange
|
||||
from tickets.models import IssueThread, Comment, StateChange, Assignment, ItemRelation
|
||||
|
||||
|
||||
class IssueThreadAdmin(admin.ModelAdmin):
|
||||
|
@ -15,6 +15,16 @@ class StateChangeAdmin(admin.ModelAdmin):
|
|||
pass
|
||||
|
||||
|
||||
class AssignmentAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
class ItemRelationAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
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)
|
||||
|
|
25
core/tickets/migrations/0010_itemrelation.py
Normal file
25
core/tickets/migrations/0010_itemrelation.py
Normal 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')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -2,7 +2,7 @@ from django.db import models
|
|||
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
|
||||
|
||||
|
@ -28,6 +28,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)
|
||||
|
@ -117,3 +124,14 @@ class Assignment(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue