django-orchestra/orchestra/contrib/websites/api.py
2015-04-05 18:02:36 +00:00

26 lines
743 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):
model = Website
serializer_class = WebsiteSerializer
filter_fields = ('name',)
def metadata(self, request):
ret = super(WebsiteViewSet, self).metadata(request)
names = ['WEBSITES_OPTIONS', 'WEBSITES_PORT_CHOICES']
ret['settings'] = {
name.lower(): getattr(settings, name, None) for name in names
}
return ret
router.register(r'websites', WebsiteViewSet)