How to use the orchestra.api.router.register function in orchestra

To help you get started, we’ve selected a few orchestra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glic3rinu / django-orchestra / orchestra / contrib / mailboxes / api.py View on Github external
from .serializers import AddressSerializer, MailboxSerializer


class AddressViewSet(LogApiMixin, AccountApiMixin, viewsets.ModelViewSet):
    queryset = Address.objects.select_related('domain').prefetch_related('mailboxes').all()
    serializer_class = AddressSerializer
    filter_fields = ('domain', 'mailboxes__name')


class MailboxViewSet(LogApiMixin, SetPasswordApiMixin, AccountApiMixin, viewsets.ModelViewSet):
    queryset = Mailbox.objects.prefetch_related('addresses__domain').all()
    serializer_class = MailboxSerializer


router.register(r'mailboxes', MailboxViewSet)
router.register(r'addresses', AddressViewSet)
github glic3rinu / django-orchestra / orchestra / apps / webapps / api.py View on Github external
serializer_class = WebAppSerializer
    filter_fields = ('name',)
    
    def metadata(self, request):
        ret = super(WebAppViewSet, self).metadata(request)
        names = [
            'WEBAPPS_BASE_ROOT', 'WEBAPPS_TYPES', 'WEBAPPS_WEBAPP_OPTIONS',
            'WEBAPPS_PHP_DISABLED_FUNCTIONS', 'WEBAPPS_DEFAULT_TYPE'
        ]
        ret['settings'] = {
            name.lower(): getattr(settings, name, None) for name in names
        }
        return ret


router.register(r'webapps', WebAppViewSet)
github glic3rinu / django-orchestra / orchestra / contrib / payments / api.py View on Github external
from .models import PaymentSource, Transaction
from .serializers import PaymentSourceSerializer, TransactionSerializer


class PaymentSourceViewSet(LogApiMixin, AccountApiMixin, viewsets.ModelViewSet):
    serializer_class = PaymentSourceSerializer
    queryset = PaymentSource.objects.all()


class TransactionViewSet(LogApiMixin, viewsets.ModelViewSet):
    serializer_class = TransactionSerializer
    queryset = Transaction.objects.all()


router.register(r'payment-sources', PaymentSourceViewSet)
router.register(r'transactions', TransactionViewSet)
github glic3rinu / django-orchestra / orchestra / contrib / websites / api.py View on Github external
class WebsiteViewSet(LogApiMixin, AccountApiMixin, viewsets.ModelViewSet):
    queryset = Website.objects.prefetch_related('domains', 'content_set__webapp', 'directives').all()
    serializer_class = WebsiteSerializer
    filter_fields = ('name', 'domains__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)
github glic3rinu / django-orchestra / orchestra / contrib / databases / api.py View on Github external
class DatabaseViewSet(LogApiMixin, AccountApiMixin, viewsets.ModelViewSet):
    queryset = Database.objects.prefetch_related('users').all()
    serializer_class = DatabaseSerializer
    filter_fields = ('name',)


class DatabaseUserViewSet(LogApiMixin, AccountApiMixin, SetPasswordApiMixin, viewsets.ModelViewSet):
    queryset = DatabaseUser.objects.prefetch_related('databases').all()
    serializer_class = DatabaseUserSerializer
    filter_fields = ('username',)


router.register(r'databases', DatabaseViewSet)
router.register(r'databaseusers', DatabaseUserViewSet)
github glic3rinu / django-orchestra / orchestra / apps / websites / api.py View on Github external
class WebsiteViewSet(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)
github glic3rinu / django-orchestra / orchestra / contrib / contacts / api.py View on Github external
from rest_framework import viewsets

from orchestra.api import router, LogApiMixin
from orchestra.contrib.accounts.api import AccountApiMixin

from .models import Contact
from .serializers import ContactSerializer


class ContactViewSet(LogApiMixin, AccountApiMixin, viewsets.ModelViewSet):
    queryset = Contact.objects.all()
    serializer_class = ContactSerializer


router.register(r'contacts', ContactViewSet)
github glic3rinu / django-orchestra / orchestra / contrib / issues / api.py View on Github external
qs = super(TicketViewSet, self).get_queryset()
        qs = qs.select_related('creator', 'queue')
        qs = qs.prefetch_related('messages__author')
        return qs.filter(creator=self.request.user)


class QueueViewSet(LogApiMixin,
                   mixins.ListModelMixin,
                   mixins.RetrieveModelMixin,
                   viewsets.GenericViewSet):
    queryset = Queue.objects.all()
    serializer_class = QueueSerializer


router.register(r'tickets', TicketViewSet)
router.register(r'ticket-queues', QueueViewSet)
github glic3rinu / django-orchestra / orchestra / contrib / mailboxes / api.py View on Github external
from .models import Address, Mailbox
from .serializers import AddressSerializer, MailboxSerializer


class AddressViewSet(LogApiMixin, AccountApiMixin, viewsets.ModelViewSet):
    queryset = Address.objects.select_related('domain').prefetch_related('mailboxes').all()
    serializer_class = AddressSerializer
    filter_fields = ('domain', 'mailboxes__name')


class MailboxViewSet(LogApiMixin, SetPasswordApiMixin, AccountApiMixin, viewsets.ModelViewSet):
    queryset = Mailbox.objects.prefetch_related('addresses__domain').all()
    serializer_class = MailboxSerializer


router.register(r'mailboxes', MailboxViewSet)
router.register(r'addresses', AddressViewSet)