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

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)