2016-10-04 17:07:17 +00:00
|
|
|
from django.contrib.auth.models import User
|
2016-10-07 23:07:47 +00:00
|
|
|
from rest_framework import serializers, viewsets, filters
|
2016-10-12 22:18:37 +00:00
|
|
|
from rest_framework.response import Response
|
|
|
|
from rest_framework.decorators import detail_route
|
|
|
|
from app import models
|
|
|
|
from .tasks import TaskIDsSerializer, TaskSerializer
|
2016-10-04 17:07:17 +00:00
|
|
|
|
2016-10-12 22:18:37 +00:00
|
|
|
class ProjectSerializer(serializers.ModelSerializer):
|
2016-10-04 17:07:17 +00:00
|
|
|
owner = serializers.PrimaryKeyRelatedField(queryset=User.objects.all())
|
2016-10-12 22:18:37 +00:00
|
|
|
tasks = TaskIDsSerializer(many=True)
|
2016-10-04 17:07:17 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = models.Project
|
|
|
|
|
|
|
|
|
|
|
|
class ProjectViewSet(viewsets.ModelViewSet):
|
|
|
|
"""
|
2016-10-12 22:18:37 +00:00
|
|
|
Projects the current user has access to. Projects are the building blocks
|
|
|
|
of processing. Each project can have zero or more tasks associated with it.
|
|
|
|
Users can fine tune the permissions on projects, including whether users/groups have
|
|
|
|
access to view, add, change or delete them.<br/><br/>
|
|
|
|
- /api/projects/<projectId>/tasks : list all tasks belonging to a project<br/>
|
|
|
|
- /api/projects/<projectId>/tasks/<taskId> : get task details
|
2016-10-04 17:07:17 +00:00
|
|
|
"""
|
2016-10-11 22:08:01 +00:00
|
|
|
filter_fields = ('id', 'owner', 'name')
|
2016-10-07 23:07:47 +00:00
|
|
|
serializer_class = ProjectSerializer
|
2016-10-04 17:07:17 +00:00
|
|
|
queryset = models.Project.objects.all()
|