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

24 lines
719 B
Python
Raw Normal View History

2014-05-08 16:59:35 +00:00
from rest_framework import viewsets
from orchestra.api import router, SetPasswordApiMixin
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
class DatabaseViewSet(AccountApiMixin, viewsets.ModelViewSet):
model = Database
serializer_class = DatabaseSerializer
filter_fields = ('name',)
class DatabaseUserViewSet(AccountApiMixin, SetPasswordApiMixin, viewsets.ModelViewSet):
model = DatabaseUser
serializer_class = DatabaseUserSerializer
filter_fields = ('username',)
router.register(r'databases', DatabaseViewSet)
router.register(r'databaseusers', DatabaseUserViewSet)