stash
This commit is contained in:
parent
59988aa6c0
commit
98cbf0fc73
4 changed files with 2 additions and 176 deletions
|
@ -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')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -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)
|
|
@ -1,91 +0,0 @@
|
|||
<template>
|
||||
<div class="timeline-item-description">
|
||||
<i class="avatar | small">
|
||||
<font-awesome-icon icon="user"/>
|
||||
</i>
|
||||
<span><a href="#">$USER</a> has claimed sipping code
|
||||
<ClipboardButton class="btn btn-primary badge badge-pill" title="Copy shipping code to clipboard" :payload="item.code">{{ item.code }}
|
||||
<font-awesome-icon icon="clipboard"/>
|
||||
</ClipboardButton> of type <span class="badge badge-pill badge-secondary">{{ item.code_type }}</span> for this ticket at <time
|
||||
:datetime="timestamp">{{ timestamp }}</time>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {mapState} from "vuex";
|
||||
import ClipboardButton from "@/components/inputs/ClipboardButton.vue";
|
||||
|
||||
export default {
|
||||
name: 'TimelineShippingCode',
|
||||
components: {ClipboardButton},
|
||||
props: {
|
||||
'item': {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['state_options']),
|
||||
'timestamp': function () {
|
||||
return new Date(this.item.timestamp).toLocaleString();
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
|
||||
.timeline-item-description {
|
||||
display: flex;
|
||||
padding-top: 6px;
|
||||
gap: 8px;
|
||||
color: var(--gray);
|
||||
|
||||
img {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
/*color: var(--c-grey-500);*/
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
outline: 0; /* Don't actually do this */
|
||||
color: var(--info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
aspect-ratio: 1 / 1;
|
||||
flex-shrink: 0;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
|
||||
&.small {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
img {
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue