Commit 8d341c4f authored by Anze Vavpetic's avatar Anze Vavpetic

added serializers and views for connections, inputs and outputs

parent 7fc8de0a
......@@ -5,9 +5,12 @@ from workflows import api_views
router = routers.DefaultRouter()
router.register(r'workflows', api_views.WorkflowViewSet)
router.register(r'widgets', api_views.WidgetViewSet)
router.register(r'connections', api_views.ConnectionViewSet)
router.register(r'inputs', api_views.InputViewSet)
router.register(r'outputs', api_views.OutputViewSet)
urlpatterns = patterns('',
url(r'^', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
)
\ No newline at end of file
)
from workflows.models import Workflow, Widget
from workflows.models import *
from rest_framework import viewsets, mixins
from rest_framework.views import APIView
from rest_framework.response import Response
from workflows.serializers import WorkflowSerializer, WidgetSerializer, WorkflowListSerializer
from workflows.serializers import *
from rest_framework import filters
class WorkflowViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows workflows to be viewed or edited.
......@@ -33,3 +34,36 @@ class WidgetViewSet(viewsets.ModelViewSet):
def get_queryset(self):
return Widget.objects.filter(workflow__user=self.request.user)
class ConnectionViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows connections to be viewed or edited.
"""
serializer_class = ConnectionSerializer
model = Connection
def get_queryset(self):
return Connection.objects.filter(workflow__user=self.request.user)
class InputViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows widget inputs to be viewed or edited.
"""
serializer_class = InputSerializer
model = Input
def get_queryset(self):
return Input.objects.filter(widget__workflow__user=self.request.user)
class OutputViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows widget outputs to be viewed or edited.
"""
serializer_class = OutputSerializer
model = Output
def get_queryset(self):
return Output.objects.filter(widget__workflow__user=self.request.user)
......@@ -895,6 +895,7 @@ class Input(models.Model):
('text','Single line'),
('textarea','Multi line text'),
('select', 'Select box'),
('file', 'File field')
)
parameter_type = models.CharField(max_length=50,choices=PARAMETER_CHOICES,blank=True,null=True)
order = models.PositiveIntegerField(default=1)
......
from workflows.models import Workflow, Widget
from workflows.models import Workflow, Widget, Connection, Input, Output, Option
from rest_framework import serializers
#from rest_framework.reverse import reverse
......@@ -6,16 +6,32 @@ from rest_framework import serializers
class WidgetSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Widget
fields = ('id', 'workflow', 'x', 'y', 'name', 'finished', 'error',
'running', 'interaction_waiting', 'type', 'progress')
class WorkflowListSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Workflow
fields = ('id', 'name', 'public', 'description', 'url')
class WorkflowSerializer(serializers.HyperlinkedModelSerializer):
widgets = WidgetSerializer(many=True,read_only=True)
class Meta:
model = Workflow
fields = ('id', 'name', 'public', 'description', 'widgets', 'url')
class ConnectionSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Connection
class InputSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Input
exclude = ('value',)
class OutputSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Output
exclude = ('value',)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment