Closed rupin closed 5 years ago
So table river_transitionapproval is tracking the history. It is definitely very convenient that all states are there whenever a new flow is created. My understanding is when a stage in a flow is completed, its status flag is changed from 0->1 and a timestamp is added in the action_date column. The object_id column holds the reference to the primary key of the model in which the statefield has been added.
Can this table be serialized for consumption through an API?
This is about right. You can use it to track history as well.
I am not really sure why you need it and what you mean by "through an API" to be honest but it is yet another Django model, you can do anything that you can do with other Django models.
I started to build views with the django rest framework. I did that for the State table and got a weird result. My serializer is as follows
from river.models import State
from rest_framework import serializers
class StateSerializer(serializers.Serializer):
class Meta:
model = State
fields = ['id', 'label']
Also, my API view is as follows
from rest_framework import generics
from workflowengine.riverserializers.StateSerializer import StateSerializer
from river.models import State
class StateList(generics.ListAPIView):
serializer_class = StateSerializer
def get_queryset(self):
return State.objects.all()
Through the Admin console, I have added 11 states inside my state table, which I have checked with pgadmin.
When i access the API through the browser, I get 11 empty sections in my API ( no error, just the data is missing).
I cant seem to understand how the 11 data points presented in the API are empty. That it presented 11 elements, but no data, which is pretty weird.
It has been quite a while since I last worked with django rest framework, but this seems to be a problem with the way you configured it with django rest framework. Because State
is yet another django model with no specialty.
I think you should use serializers.ModelSerializer
instead of serializers.Serializer
oh yeah! that worked!
If I had access to a model object, how can i know everything about the workflow? Can i access information about the workflow, specifically its history.
The API documentation talks about the current state, but more often than not, people will want to read a summary.