django-orchestra-test/orchestra/contrib/websites/api.py
2015-04-23 19:46:23 +00:00

26 lines
843 B
Python

from rest_framework import viewsets
from orchestra.api import router, LogApiMixin
from orchestra.contrib.accounts.api import AccountApiMixin
from . import settings
from .models import Website
from .serializers import WebsiteSerializer
class WebsiteViewSet(LogApiMixin, AccountApiMixin, viewsets.ModelViewSet):
queryset = Website.objects.prefetch_related('domains', 'content_set__webapp', 'directives').all()
serializer_class = WebsiteSerializer
filter_fields = ('name',)
def options(self, request):
metadata = super(WebsiteViewSet, self).options(request)
names = ['WEBSITES_OPTIONS', 'WEBSITES_PORT_CHOICES']
metadata.data['settings'] = {
name.lower(): getattr(settings, name, None) for name in names
}
return metadata
router.register(r'websites', WebsiteViewSet)