From 76dd805262b06c89cae24a32c22da079f8ae6c5a Mon Sep 17 00:00:00 2001 From: jedi Date: Wed, 6 Dec 2023 04:51:47 +0100 Subject: [PATCH] stash --- core/tickets/api_v2.py | 4 +- ...002_alter_comment_issue_thread_and_more.py | 24 ---------- ...d_to_issuethread_last_activity_and_more.py | 45 +++++++++++++++++++ core/tickets/models.py | 4 ++ core/tickets/tests/v2/test_tickets.py | 4 ++ web/src/components/Navbar.vue | 3 +- web/src/store/index.js | 13 +++++- web/src/views/Tickets.vue | 3 ++ 8 files changed, 72 insertions(+), 28 deletions(-) delete mode 100644 core/tickets/migrations/0002_alter_comment_issue_thread_and_more.py create mode 100644 core/tickets/migrations/0002_issuethread_assigned_to_issuethread_last_activity_and_more.py diff --git a/core/tickets/api_v2.py b/core/tickets/api_v2.py index e013ed6..441d417 100644 --- a/core/tickets/api_v2.py +++ b/core/tickets/api_v2.py @@ -8,8 +8,8 @@ class IssueSerializer(serializers.ModelSerializer): class Meta: model = IssueThread - fields = ('id', 'timeline') - read_only_fields = ('id', 'timeline') + fields = ('id', 'timeline', 'name', 'state', 'assigned_to', 'last_activity') + read_only_fields = ('id', 'timeline', 'last_activity') @staticmethod def get_timeline(obj): diff --git a/core/tickets/migrations/0002_alter_comment_issue_thread_and_more.py b/core/tickets/migrations/0002_alter_comment_issue_thread_and_more.py deleted file mode 100644 index 021ccfe..0000000 --- a/core/tickets/migrations/0002_alter_comment_issue_thread_and_more.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 4.2.7 on 2023-12-06 03:34 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('tickets', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='comment', - name='issue_thread', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='tickets.issuethread'), - ), - migrations.AlterField( - model_name='statechange', - name='issue_thread', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state_changes', to='tickets.issuethread'), - ), - ] diff --git a/core/tickets/migrations/0002_issuethread_assigned_to_issuethread_last_activity_and_more.py b/core/tickets/migrations/0002_issuethread_assigned_to_issuethread_last_activity_and_more.py new file mode 100644 index 0000000..fc30eb0 --- /dev/null +++ b/core/tickets/migrations/0002_issuethread_assigned_to_issuethread_last_activity_and_more.py @@ -0,0 +1,45 @@ +# Generated by Django 4.2.7 on 2023-12-06 03:53 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('tickets', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='issuethread', + name='assigned_to', + field=models.CharField(max_length=255, null=True), + ), + migrations.AddField( + model_name='issuethread', + name='last_activity', + field=models.DateTimeField(auto_now=True), + ), + migrations.AddField( + model_name='issuethread', + name='name', + field=models.CharField(default='unnamed issue', max_length=255), + preserve_default=False, + ), + migrations.AddField( + model_name='issuethread', + name='state', + field=models.CharField(default='new', max_length=255), + ), + migrations.AlterField( + model_name='comment', + name='issue_thread', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='tickets.issuethread'), + ), + migrations.AlterField( + model_name='statechange', + name='issue_thread', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state_changes', to='tickets.issuethread'), + ), + ] diff --git a/core/tickets/models.py b/core/tickets/models.py index 6a3810e..5751288 100644 --- a/core/tickets/models.py +++ b/core/tickets/models.py @@ -6,6 +6,10 @@ 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) class Comment(models.Model): diff --git a/core/tickets/tests/v2/test_tickets.py b/core/tickets/tests/v2/test_tickets.py index 23395de..52a6384 100644 --- a/core/tickets/tests/v2/test_tickets.py +++ b/core/tickets/tests/v2/test_tickets.py @@ -50,6 +50,10 @@ class IssueApiTest(TestCase): self.assertEqual(response.status_code, 200) self.assertEqual(len(response.json()), 1) self.assertEqual(response.json()[0]['id'], issue.id) + self.assertEqual(response.json()[0]['name'], issue.name) + self.assertEqual(response.json()[0]['state'], issue.state) + self.assertEqual(response.json()[0]['assigned_to'], issue.assigned_to) + self.assertEqual(response.json()[0]['last_activity'], issue.last_activity.strftime('%Y-%m-%dT%H:%M:%S.%fZ')) self.assertEqual(len(response.json()[0]['timeline']), 4) self.assertEqual(response.json()[0]['timeline'][0]['type'], 'mail') self.assertEqual(response.json()[0]['timeline'][1]['type'], 'state') diff --git a/web/src/components/Navbar.vue b/web/src/components/Navbar.vue index 9a9a101..7b3f67a 100644 --- a/web/src/components/Navbar.vue +++ b/web/src/components/Navbar.vue @@ -112,7 +112,7 @@ export default { }; -