New Ticket

TICKET_CREATE privileges are required to perform this operation. You don't have the required permissions



Login Close

Changeset 5ff4a05


Ignore:
Timstamp:
Oct 14, 2018 12:23:31 AM (2 months ago)
Author:
Gary Martin <gjm@…>
Branches:
bh_core_experimental
Parents:
e810572
Message:

Attempt to add links to api output for ticket list

git-svn-id: https://svn.apache.org/repos/asf/bloodhound/branches/bh_core_experimental@1843805 13f79535-47bb-0310-9956-ffa450edef68

Location:
trackers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trackers/models.py

    re810572 r5ff4a05  
    2222 
    2323from django.db import models 
     24from django.urls import reverse 
    2425 
    2526logger = logging.getLogger(__name__) 
     
    3738    title = models.CharField(max_length=200, null=True) 
    3839    description = models.TextField(null=True) 
     40 
     41    def api_url(self): 
     42        return reverse('ticket_view', args=(self.id,)) 
    3943 
    4044    def last_update(self): 
  • trackers/serializers.py

    re810572 r5ff4a05  
    11from rest_framework import serializers 
    2 from trackers.models import Ticket, TicketField, ChangeEvent 
     2from trackers import models 
    33 
    44 
    55class TicketSerializer(serializers.ModelSerializer): 
     6    api_url = serializers.SerializerMethodField() 
     7 
    68    class Meta: 
    7         model = Ticket 
     9        model = models.Ticket 
    810        fields = '__all__' 
     11 
     12    def get_api_url(self, obj): 
     13        return self.context['request'].build_absolute_uri(obj.api_url()) 
    914 
    1015 
    1116class TicketFieldSerializer(serializers.ModelSerializer): 
    1217    class Meta: 
    13         model = TicketField 
     18        model = models.TicketField 
    1419        fields = '__all__' 
    1520 
     
    1722class ChangeEventSerializer(serializers.ModelSerializer): 
    1823    class Meta: 
    19         model = ChangeEvent 
     24        model = models.ChangeEvent 
    2025        fields = '__all__' 
  • trackers/urls.py

    re810572 r5ff4a05  
    2424    path('field/', views.TicketFieldListCreate.as_view()), 
    2525    path('ticket/', views.TicketListCreate.as_view()), 
    26     path('ticket/<uuid:id>', views.TicketViewUpdate.as_view()), 
     26    path('ticket/<uuid:id>', views.TicketViewUpdate.as_view(), name='ticket_view'), 
    2727    path('ticket/<uuid:id>/event/', views.ChangeEventListCreate.as_view()), 
    2828] 
Note: See TracChangeset for help on using the changeset viewer.