2016-10-04 17:07:17 +00:00
|
|
|
from django.contrib.auth.models import User
|
2016-10-18 20:23:10 +00:00
|
|
|
from rest_framework import serializers, viewsets
|
2016-11-01 19:11:36 +00:00
|
|
|
|
2016-10-12 22:18:37 +00:00
|
|
|
from app import models
|
2016-11-01 19:11:36 +00:00
|
|
|
from .tasks import TaskIDsSerializer
|
|
|
|
|
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
|
2016-10-22 17:11:11 +00:00
|
|
|
fields = '__all__'
|
2016-10-04 17:07:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
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()
|