add tickets module

This commit is contained in:
j3d1 2024-01-07 19:56:10 +01:00
parent 6abf3af6c0
commit 649fff80f8
6 changed files with 104 additions and 0 deletions

View file

@ -56,6 +56,7 @@ INSTALLED_APPS = [
'channels',
'authentication',
'files',
'tickets',
'inventory',
'notify_sessions',
]

0
core/tickets/__init__.py Normal file
View file

View file

@ -0,0 +1,48 @@
# Generated by Django 4.2.7 on 2023-12-09 02:13
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='IssueThread',
fields=[
('is_deleted', models.BooleanField(default=False)),
('deleted_at', models.DateTimeField(blank=True, null=True)),
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=255)),
('state', models.CharField(default='new', max_length=255)),
('assigned_to', models.CharField(max_length=255, null=True)),
('last_activity', models.DateTimeField(auto_now=True)),
],
options={
'permissions': [('send_mail', 'Can send mail')],
},
),
migrations.CreateModel(
name='StateChange',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('state', models.CharField(max_length=255)),
('timestamp', models.DateTimeField(auto_now_add=True)),
('issue_thread', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state_changes', to='tickets.issuethread')),
],
),
migrations.CreateModel(
name='Comment',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('comment', models.TextField()),
('timestamp', models.DateTimeField(auto_now_add=True)),
('issue_thread', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='tickets.issuethread')),
],
),
]

View file

@ -0,0 +1,22 @@
# Generated by Django 4.2.7 on 2023-12-22 20:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='issuethread',
options={'permissions': [('send_mail', 'Can send mail'), ('add_issuethread_manual', 'Can add issue thread manually')]},
),
migrations.AddField(
model_name='issuethread',
name='manually_created',
field=models.BooleanField(default=False),
),
]

View file

33
core/tickets/models.py Normal file
View file

@ -0,0 +1,33 @@
from django.db import models
from django_softdelete.models import SoftDeleteModel
from inventory.models import Event
class IssueThread(SoftDeleteModel):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
state = models.CharField(max_length=255, default='new')
assigned_to = models.CharField(max_length=255, null=True)
last_activity = models.DateTimeField(auto_now=True)
manually_created = models.BooleanField(default=False)
class Meta:
permissions = [
('send_mail', 'Can send mail'),
('add_issuethread_manual', 'Can add issue thread manually'),
]
class Comment(models.Model):
id = models.AutoField(primary_key=True)
issue_thread = models.ForeignKey(IssueThread, on_delete=models.CASCADE, related_name='comments')
comment = models.TextField()
timestamp = models.DateTimeField(auto_now_add=True)
class StateChange(models.Model):
id = models.AutoField(primary_key=True)
issue_thread = models.ForeignKey(IssueThread, on_delete=models.CASCADE, related_name='state_changes')
state = models.CharField(max_length=255)
timestamp = models.DateTimeField(auto_now_add=True)