bloodhound-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Martin <gary.mar...@physics.org>
Subject Re: svn commit: r1843805 - in /bloodhound/branches/bh_core_experimental/trackers: models.py serializers.py urls.py
Date Sun, 14 Oct 2018 15:44:12 GMT
Hi everyone,

Last night I merged code that was worked on last month from the pyconuk sprints culminating
in this commit. The significant changes from this were:

 * adding django-rest-framework [1]
 * adding django rest swagger [2]
 * activation and registering the Ticket and ChangeEvent models with the admin site
 * adding a new set of views:
   * schema_view/ (the view of the api generated by swagger)
   * field/ (a view to list and create ticket fields)
   * ticket/ (a view to list and create tickets)
   * ticket/<uuid:id> (a view of a specific ticket)
   * ticket/<uuid:id>/event/ (a view to show ticket change events for a given ticket)

Cheers,
    Gary

[1] https://www.django-rest-framework.org/
[2] https://django-rest-swagger.readthedocs.io/

On Sun, 14 Oct 2018, at 1:23 AM, gjm@apache.org wrote:
> Author: gjm
> Date: Sun Oct 14 00:23:31 2018
> New Revision: 1843805
> 
> URL: http://svn.apache.org/viewvc?rev=1843805&view=rev
> Log:
> Attempt to add links to api output for ticket list
> 
> Modified:
>     bloodhound/branches/bh_core_experimental/trackers/models.py
>     bloodhound/branches/bh_core_experimental/trackers/serializers.py
>     bloodhound/branches/bh_core_experimental/trackers/urls.py
> 
> Modified: bloodhound/branches/bh_core_experimental/trackers/models.py
> URL: 
> http://svn.apache.org/viewvc/bloodhound/branches/bh_core_experimental/trackers/models.py?rev=1843805&r1=1843804&r2=1843805&view=diff
> ==============================================================================
> --- bloodhound/branches/bh_core_experimental/trackers/models.py 
> (original)
> +++ bloodhound/branches/bh_core_experimental/trackers/models.py Sun Oct 
> 14 00:23:31 2018
> @@ -21,6 +21,7 @@ import logging
>  import uuid
>  
>  from django.db import models
> +from django.urls import reverse
>  
>  logger = logging.getLogger(__name__)
>  
> @@ -37,6 +38,9 @@ class Ticket(ModelCommon):
>      title = models.CharField(max_length=200, null=True)
>      description = models.TextField(null=True)
>  
> +    def api_url(self):
> +        return reverse('ticket_view', args=(self.id,))
> +
>      def last_update(self):
>          last_event = self.changeevent_set.order_by('created').last()
>          return self.created if last_event is None else last_event.created
> 
> Modified: bloodhound/branches/bh_core_experimental/trackers/
> serializers.py
> URL: 
> http://svn.apache.org/viewvc/bloodhound/branches/bh_core_experimental/trackers/serializers.py?rev=1843805&r1=1843804&r2=1843805&view=diff
> ==============================================================================
> --- bloodhound/branches/bh_core_experimental/trackers/serializers.py 
> (original)
> +++ bloodhound/branches/bh_core_experimental/trackers/serializers.py Sun 
> Oct 14 00:23:31 2018
> @@ -1,20 +1,25 @@
>  from rest_framework import serializers
> -from trackers.models import Ticket, TicketField, ChangeEvent
> +from trackers import models
>  
>  
>  class TicketSerializer(serializers.ModelSerializer):
> +    api_url = serializers.SerializerMethodField()
> +
>      class Meta:
> -        model = Ticket
> +        model = models.Ticket
>          fields = '__all__'
>  
> +    def get_api_url(self, obj):
> +        return self.context['request'].build_absolute_uri(obj.api_url())
> +
>  
>  class TicketFieldSerializer(serializers.ModelSerializer):
>      class Meta:
> -        model = TicketField
> +        model = models.TicketField
>          fields = '__all__'
>  
>  
>  class ChangeEventSerializer(serializers.ModelSerializer):
>      class Meta:
> -        model = ChangeEvent
> +        model = models.ChangeEvent
>          fields = '__all__'
> 
> Modified: bloodhound/branches/bh_core_experimental/trackers/urls.py
> URL: 
> http://svn.apache.org/viewvc/bloodhound/branches/bh_core_experimental/trackers/urls.py?rev=1843805&r1=1843804&r2=1843805&view=diff
> ==============================================================================
> --- bloodhound/branches/bh_core_experimental/trackers/urls.py (original)
> +++ bloodhound/branches/bh_core_experimental/trackers/urls.py Sun Oct 14 
> 00:23:31 2018
> @@ -23,6 +23,6 @@ urlpatterns = [
>      path('schema_view/', views.schema_view),
>      path('field/', views.TicketFieldListCreate.as_view()),
>      path('ticket/', views.TicketListCreate.as_view()),
> -    path('ticket/<uuid:id>', views.TicketViewUpdate.as_view()),
> +    path('ticket/<uuid:id>', views.TicketViewUpdate.as_view(), 
> name='ticket_view'),
>      path('ticket/<uuid:id>/event/', 
> views.ChangeEventListCreate.as_view()),
>  ]
> 
> 

Mime
View raw message