This commit is contained in:
j3d1 2024-06-15 18:04:43 +02:00
parent da075d162f
commit 473b80d171
5 changed files with 53 additions and 4 deletions

View file

@ -13,8 +13,8 @@ from core.settings import MAIL_DOMAIN
from mail.models import Email from mail.models import Email
from mail.protocol import send_smtp, make_reply, collect_references from mail.protocol import send_smtp, make_reply, collect_references
from notify_sessions.models import SystemEvent from notify_sessions.models import SystemEvent
from tickets.models import IssueThread, Comment, STATE_CHOICES from tickets.models import IssueThread, Comment, STATE_CHOICES, ShippingCode
from tickets.serializers import IssueSerializer, CommentSerializer from tickets.serializers import IssueSerializer, CommentSerializer, ShippingCodeSerializer
class IssueViewSet(viewsets.ModelViewSet): class IssueViewSet(viewsets.ModelViewSet):
@ -22,6 +22,11 @@ class IssueViewSet(viewsets.ModelViewSet):
queryset = IssueThread.objects.all() queryset = IssueThread.objects.all()
class ShippingCodeViewSet(viewsets.ModelViewSet):
serializer_class = ShippingCodeSerializer
queryset = ShippingCode.objects.all()
@api_view(['POST']) @api_view(['POST'])
@permission_classes([IsAuthenticated]) @permission_classes([IsAuthenticated])
@permission_required('tickets.add_issuethread', raise_exception=True) @permission_required('tickets.add_issuethread', raise_exception=True)
@ -113,6 +118,7 @@ def add_comment(request, pk):
router = routers.SimpleRouter() router = routers.SimpleRouter()
router.register(r'tickets', IssueViewSet, basename='issues') router.register(r'tickets', IssueViewSet, basename='issues')
router.register(r'shipping_codes', ShippingCodeViewSet, basename='shipping_codes')
urlpatterns = ([ urlpatterns = ([
re_path(r'^tickets/(?P<pk>\d+)/reply/$', reply, name='reply'), re_path(r'^tickets/(?P<pk>\d+)/reply/$', reply, name='reply'),

View file

@ -136,3 +136,14 @@ class ItemRelation(models.Model):
def __str__(self): def __str__(self):
return str(self.issue_thread) + ' related to ' + str(self.item) return str(self.issue_thread) + ' related to ' + str(self.item)
class ShippingCode(models.Model):
id = models.AutoField(primary_key=True)
issue_thread = models.ForeignKey(IssueThread, on_delete=models.CASCADE, related_name='shipping_codes', null=True)
code = models.CharField(max_length=255)
timestamp = models.DateTimeField(auto_now_add=True)
used_at = models.DateTimeField(null=True)
def __str__(self):
return str(self.issue_thread) + ' shipping code ' + self.code

View file

@ -2,7 +2,7 @@ from rest_framework import serializers
from authentication.models import ExtendedUser from authentication.models import ExtendedUser
from mail.api_v2 import AttachmentSerializer from mail.api_v2 import AttachmentSerializer
from tickets.models import IssueThread, Comment, STATE_CHOICES from tickets.models import IssueThread, Comment, STATE_CHOICES, ShippingCode
from inventory.serializers import ItemSerializer from inventory.serializers import ItemSerializer
@ -29,6 +29,13 @@ class StateSerializer(serializers.Serializer):
return obj['value'] return obj['value']
class ShippingCodeSerializer(serializers.Serializer):
class Meta:
model = ShippingCode
fields = ('id', 'code', 'timestamp', 'issue_thread', 'used_at')
read_only_fields = ('id', 'timestamp', 'used_at')
class IssueSerializer(serializers.ModelSerializer): class IssueSerializer(serializers.ModelSerializer):
timeline = serializers.SerializerMethodField() timeline = serializers.SerializerMethodField()
last_activity = serializers.SerializerMethodField() last_activity = serializers.SerializerMethodField()

View file

@ -1,6 +1,31 @@
<template> <template>
<div class="row"> <div class="row">
<div class="col-lg-3 col-xl-2"> <div class="col-lg-3 col-xl-2">
<!--div class="card bg-dark text-light mb-2" id="filters">
<div class="card-body">
<h5 class="card-title text-info">Sort & Filter</h5>
<div class="form-group" v-for="(column, index) in columns" :key="index">
<label>{{ column }}</label>
<div class="input-group">
<div class="input-group-prepend">
<button
:class="[ 'btn', column === sortBy ? 'btn-outline-info' : 'btn-outline-secondary' ]"
type="button"
@click="toggleSort(column)">
<font-awesome-icon :icon="getSortIcon(column)"/>
</button>
</div>
<input
type="text"
class="form-control"
placeholder="filter"
:value="filters[column]"
@input="changeFilter(column, $event.target.value)"
>
</div>
</div>
</div>
</div-->
</div> </div>
<div class="col-lg-9 col-xl-8"> <div class="col-lg-9 col-xl-8">
<div class="w-100" <div class="w-100"

View file

@ -21,7 +21,7 @@ const store = createStore({
state_options: [], state_options: [],
messageTemplates: [], messageTemplates: [],
messageTemplateVariables: [], messageTemplateVariables: [],
shippingCodes: null, shippingCodes: [],
lastEvent: '37C3', lastEvent: '37C3',
lastUsed: {}, lastUsed: {},