2014-05-08 16:59:35 +00:00
|
|
|
from rest_framework import viewsets
|
|
|
|
from rest_framework.response import Response
|
|
|
|
|
2014-05-13 13:46:40 +00:00
|
|
|
from orchestra.api import router
|
2014-05-08 16:59:35 +00:00
|
|
|
from orchestra.apps.accounts.api import AccountApiMixin
|
|
|
|
|
|
|
|
from . import settings
|
|
|
|
from .models import WebApp
|
|
|
|
from .serializers import WebAppSerializer
|
|
|
|
|
|
|
|
|
|
|
|
class WebAppViewSet(AccountApiMixin, viewsets.ModelViewSet):
|
|
|
|
model = WebApp
|
|
|
|
serializer_class = WebAppSerializer
|
|
|
|
filter_fields = ('name',)
|
|
|
|
|
2014-05-13 13:46:40 +00:00
|
|
|
def metadata(self, request):
|
|
|
|
ret = super(WebAppViewSet, self).metadata(request)
|
2014-05-08 16:59:35 +00:00
|
|
|
names = [
|
|
|
|
'WEBAPPS_BASE_ROOT', 'WEBAPPS_TYPES', 'WEBAPPS_WEBAPP_OPTIONS',
|
|
|
|
'WEBAPPS_PHP_DISABLED_FUNCTIONS', 'WEBAPPS_DEFAULT_TYPE'
|
|
|
|
]
|
2014-05-13 13:46:40 +00:00
|
|
|
ret['settings'] = {
|
|
|
|
name.lower(): getattr(settings, name, None) for name in names
|
|
|
|
}
|
|
|
|
return ret
|
2014-05-08 16:59:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
router.register(r'webapps', WebAppViewSet)
|