django-orchestra-test/orchestra/contrib/databases/api.py

24 lines
848 B
Python
Raw Normal View History

2014-05-08 16:59:35 +00:00
from rest_framework import viewsets
2015-04-05 18:02:36 +00:00
from orchestra.api import router, SetPasswordApiMixin, LogApiMixin
2015-04-05 10:46:24 +00:00
from orchestra.contrib.accounts.api import AccountApiMixin
2014-05-08 16:59:35 +00:00
from .models import Database, DatabaseUser
from .serializers import DatabaseSerializer, DatabaseUserSerializer
2015-04-05 18:02:36 +00:00
class DatabaseViewSet(LogApiMixin, AccountApiMixin, viewsets.ModelViewSet):
2015-04-23 19:46:23 +00:00
queryset = Database.objects.prefetch_related('users').all()
2014-05-08 16:59:35 +00:00
serializer_class = DatabaseSerializer
filter_fields = ('name',)
2015-04-05 18:02:36 +00:00
class DatabaseUserViewSet(LogApiMixin, AccountApiMixin, SetPasswordApiMixin, viewsets.ModelViewSet):
2015-04-23 19:46:23 +00:00
queryset = DatabaseUser.objects.prefetch_related('databases').all()
2014-05-08 16:59:35 +00:00
serializer_class = DatabaseUserSerializer
filter_fields = ('username',)
router.register(r'databases', DatabaseViewSet)
router.register(r'databaseusers', DatabaseUserViewSet)