From 649fff80f8a28def23054d9ba47a294421b0198d Mon Sep 17 00:00:00 2001 From: jedi Date: Sun, 7 Jan 2024 19:56:10 +0100 Subject: [PATCH] add tickets module --- core/core/settings.py | 1 + core/tickets/__init__.py | 0 core/tickets/migrations/0001_initial.py | 48 +++++++++++++++++++ ...0002_alter_issuethread_options_and_more.py | 22 +++++++++ core/tickets/migrations/__init__.py | 0 core/tickets/models.py | 33 +++++++++++++ 6 files changed, 104 insertions(+) create mode 100644 core/tickets/__init__.py create mode 100644 core/tickets/migrations/0001_initial.py create mode 100644 core/tickets/migrations/0002_alter_issuethread_options_and_more.py create mode 100644 core/tickets/migrations/__init__.py create mode 100644 core/tickets/models.py diff --git a/core/core/settings.py b/core/core/settings.py index 58b6635..5804218 100644 --- a/core/core/settings.py +++ b/core/core/settings.py @@ -56,6 +56,7 @@ INSTALLED_APPS = [ 'channels', 'authentication', 'files', + 'tickets', 'inventory', 'notify_sessions', ] diff --git a/core/tickets/__init__.py b/core/tickets/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/tickets/migrations/0001_initial.py b/core/tickets/migrations/0001_initial.py new file mode 100644 index 0000000..475d70c --- /dev/null +++ b/core/tickets/migrations/0001_initial.py @@ -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')), + ], + ), + ] diff --git a/core/tickets/migrations/0002_alter_issuethread_options_and_more.py b/core/tickets/migrations/0002_alter_issuethread_options_and_more.py new file mode 100644 index 0000000..3c1e4a7 --- /dev/null +++ b/core/tickets/migrations/0002_alter_issuethread_options_and_more.py @@ -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), + ), + ] diff --git a/core/tickets/migrations/__init__.py b/core/tickets/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/tickets/models.py b/core/tickets/models.py new file mode 100644 index 0000000..7130fe5 --- /dev/null +++ b/core/tickets/models.py @@ -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)