mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 23:43:11 +01:00
Create FollowUp serializer with its Viewset and add it in urls
This commit is contained in:
parent
091a2926fa
commit
bd413837c2
@ -4,7 +4,7 @@ from django.contrib.humanize.templatetags import humanize
|
||||
from rest_framework.exceptions import ValidationError
|
||||
|
||||
from .forms import TicketForm
|
||||
from .models import Ticket, CustomField
|
||||
from .models import Ticket, CustomField, FollowUp
|
||||
from .lib import format_time_spent
|
||||
from .user import HelpdeskUser
|
||||
|
||||
@ -71,12 +71,22 @@ class DatatablesTicketSerializer(serializers.ModelSerializer):
|
||||
return obj.kbitem.title if obj.kbitem else ""
|
||||
|
||||
|
||||
class FollowUpSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = FollowUp
|
||||
fields = (
|
||||
'id', 'ticket', 'date', 'title', 'comment', 'public', 'user', 'new_status', 'message_id', 'time_spent'
|
||||
)
|
||||
|
||||
|
||||
class TicketSerializer(serializers.ModelSerializer):
|
||||
followup_set = FollowUpSerializer(many=True, read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Ticket
|
||||
fields = (
|
||||
'id', 'queue', 'title', 'description', 'resolution', 'submitter_email', 'assigned_to', 'status', 'on_hold',
|
||||
'priority', 'due_date', 'merged_to'
|
||||
'priority', 'due_date', 'merged_to', 'followup_set'
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -17,7 +17,7 @@ from rest_framework.routers import DefaultRouter
|
||||
from helpdesk.decorators import helpdesk_staff_member_required, protect_view
|
||||
from helpdesk.views import feeds, staff, public, login
|
||||
from helpdesk import settings as helpdesk_settings
|
||||
from helpdesk.views.api import TicketViewSet, CreateUserView
|
||||
from helpdesk.views.api import TicketViewSet, CreateUserView, FollowUpViewSet
|
||||
|
||||
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||
from helpdesk.views import kb
|
||||
@ -176,6 +176,7 @@ urlpatterns += [
|
||||
if helpdesk_settings.HELPDESK_ACTIVATE_API_ENDPOINT:
|
||||
router = DefaultRouter()
|
||||
router.register(r"tickets", TicketViewSet, basename="ticket")
|
||||
router.register(r"followups", FollowUpViewSet, basename="followups")
|
||||
router.register(r"users", CreateUserView, basename="user")
|
||||
urlpatterns += [re_path(r"^api/", include(router.urls))]
|
||||
|
||||
|
@ -4,8 +4,8 @@ from rest_framework.viewsets import GenericViewSet
|
||||
from rest_framework.mixins import CreateModelMixin
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from helpdesk.models import Ticket
|
||||
from helpdesk.serializers import TicketSerializer, UserSerializer
|
||||
from helpdesk.models import Ticket, FollowUp
|
||||
from helpdesk.serializers import TicketSerializer, UserSerializer, FollowUpSerializer
|
||||
|
||||
|
||||
class TicketViewSet(viewsets.ModelViewSet):
|
||||
@ -28,6 +28,15 @@ class TicketViewSet(viewsets.ModelViewSet):
|
||||
return ticket
|
||||
|
||||
|
||||
class FollowUpViewSet(viewsets.ModelViewSet):
|
||||
"""
|
||||
A viewset that provides the standard actions to handle FollowUp
|
||||
"""
|
||||
queryset = FollowUp.objects.all()
|
||||
serializer_class = FollowUpSerializer
|
||||
permission_classes = [IsAdminUser]
|
||||
|
||||
|
||||
class CreateUserView(CreateModelMixin, GenericViewSet):
|
||||
queryset = get_user_model().objects.all()
|
||||
serializer_class = UserSerializer
|
||||
|
Loading…
Reference in New Issue
Block a user