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

26 lines
778 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, 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 . import settings
from .models import Website
from .serializers import WebsiteSerializer
2015-04-05 18:02:36 +00:00
class WebsiteViewSet(LogApiMixin, AccountApiMixin, viewsets.ModelViewSet):
2015-04-23 14:34:04 +00:00
queryset = Website.objects.all()
2014-05-08 16:59:35 +00:00
serializer_class = WebsiteSerializer
filter_fields = ('name',)
2015-04-23 14:34:04 +00:00
def options(self, request):
metadata = super(WebsiteViewSet, self).options(request)
2014-05-08 16:59:35 +00:00
names = ['WEBSITES_OPTIONS', 'WEBSITES_PORT_CHOICES']
2015-04-23 14:34:04 +00:00
metadata.data['settings'] = {
2014-05-13 13:46:40 +00:00
name.lower(): getattr(settings, name, None) for name in names
}
2015-04-23 14:34:04 +00:00
return metadata
2014-05-08 16:59:35 +00:00
router.register(r'websites', WebsiteViewSet)