From 98cbf0fc732e5326408bb8a920d7fad2950e064c Mon Sep 17 00:00:00 2001 From: jedi Date: Tue, 18 Jun 2024 16:43:23 +0200 Subject: [PATCH] stash --- core/tickets/migrations/0012_shippingcode.py | 25 ------ core/tickets/tests/v2/test_shipping_codes.py | 41 --------- web/src/components/TimelineShippingCode.vue | 91 -------------------- web/src/store.js | 21 +---- 4 files changed, 2 insertions(+), 176 deletions(-) delete mode 100644 core/tickets/migrations/0012_shippingcode.py delete mode 100644 core/tickets/tests/v2/test_shipping_codes.py delete mode 100644 web/src/components/TimelineShippingCode.vue diff --git a/core/tickets/migrations/0012_shippingcode.py b/core/tickets/migrations/0012_shippingcode.py deleted file mode 100644 index b38d901..0000000 --- a/core/tickets/migrations/0012_shippingcode.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 4.2.7 on 2024-06-15 17:37 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('tickets', '0011_issuethread_related_items'), - ] - - operations = [ - migrations.CreateModel( - name='ShippingCode', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('code', models.CharField(max_length=255)), - ('type', models.CharField(max_length=255)), - ('timestamp', models.DateTimeField(auto_now_add=True)), - ('used_at', models.DateTimeField(null=True)), - ('issue_thread', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='shipping_codes', to='tickets.issuethread')), - ], - ), - ] diff --git a/core/tickets/tests/v2/test_shipping_codes.py b/core/tickets/tests/v2/test_shipping_codes.py deleted file mode 100644 index 2115e50..0000000 --- a/core/tickets/tests/v2/test_shipping_codes.py +++ /dev/null @@ -1,41 +0,0 @@ -from datetime import datetime, timedelta - -from django.test import TestCase, Client - -from authentication.models import ExtendedUser -from mail.models import Email, EmailAttachment -from tickets.models import IssueThread, StateChange, Comment, ShippingCode -from django.contrib.auth.models import Permission -from knox.models import AuthToken - - -class ShippingCodeApiTest(TestCase): - - def setUp(self): - super().setUp() - self.user = ExtendedUser.objects.create_user('testuser', 'test', 'test') - self.user.user_permissions.add(*Permission.objects.all()) - self.user.save() - self.token = AuthToken.objects.create(user=self.user) - self.client = Client(headers={'Authorization': 'Token ' + self.token[1]}) - - def test_issues_empty(self): - response = self.client.get('/api/2/shipping_codes/') - self.assertEqual(response.status_code, 200) - self.assertEqual(response.json(), []) - - def test_issues_list(self): - ShippingCode.objects.create(code='1234', type='2kg-eu') - response = self.client.get('/api/2/shipping_codes/') - self.assertEqual(response.status_code, 200) - self.assertEqual(response.json()[0]['code'], '1234') - self.assertEqual(response.json()[0]['used_at'], None) - self.assertEqual(response.json()[0]['issue_thread'], None) - self.assertEqual(response.json()[0]['type'], '2kg-eu') - - def test_issues_create(self): - response = self.client.post('/api/2/shipping_codes/', {'code': '1234', 'type': '2kg-eu'}) - self.assertEqual(response.status_code, 201) - self.assertEqual(response.json()['code'], '1234') - self.assertEqual(response.json()['used_at'], None) - self.assertEqual(response.json()['issue_thread'], None) diff --git a/web/src/components/TimelineShippingCode.vue b/web/src/components/TimelineShippingCode.vue deleted file mode 100644 index 5529422..0000000 --- a/web/src/components/TimelineShippingCode.vue +++ /dev/null @@ -1,91 +0,0 @@ - - - - - \ No newline at end of file diff --git a/web/src/store.js b/web/src/store.js index e21456d..fccdfb1 100644 --- a/web/src/store.js +++ b/web/src/store.js @@ -20,7 +20,7 @@ const store = createStore({ groups: [], state_options: [], messageTemplates: [], - messageTemplatesVariables: [], + messageTemplateVariables: [], shippingVouchers: [], lastEvent: '37C3', @@ -60,15 +60,6 @@ const store = createStore({ '10kg-eu': '10kg Paket (EU)', }, test: ['foo', 'bar', 'baz'], - - shippingCodeTypes: { - '2kg-de': '2kg Paket (DE)', - '5kg-de': '5kg Paket (DE)', - '10kg-de': '10kg Paket (DE)', - '2kg-eu': '2kg Paket (EU)', - '5kg-eu': '5kg Paket (EU)', - '10kg-eu': '10kg Paket (EU)', - } }, getters: { route: state => router.currentRoute.value, @@ -479,6 +470,7 @@ const store = createStore({ dispatch('fetchMessageTemplates'); } }, + async fetchShippingVouchers({commit, state}) { if (!state.user.token) return; if (state.fetchedData.shippingVouchers > Date.now() - 1000 * 60 * 60 * 24) return; @@ -489,7 +481,6 @@ const store = createStore({ }, async createShippingVoucher({dispatch, state}, code) { const {data, success} = await http.post('/2/shipping_vouchers/', code, state.user.token); - if (data && success) { state.fetchedData.shippingVouchers = 0; dispatch('fetchShippingVouchers'); } @@ -504,14 +495,6 @@ const store = createStore({ state.fetchedData.shippingVouchers = 0; state.fetchedData.tickets = 0; await Promise.all([dispatch('loadTickets'), dispatch('fetchShippingVouchers')]); - } - }, - async createShippingCode({dispatch, state}, code) { - const {data, success} = await http.post('/2/shipping_codes/', code, state.user.token); - if (data && success) { - dispatch('fetchShippingCodes'); - } - } }, plugins: [ persistentStatePlugin({ // TODO change remember to some kind of enable field