Ejemplo n.º 1
0
Archivo: views.py Proyecto: ypid/netbox
class InterfaceViewSet(ModelViewSet):
    queryset = Interface.objects.filter(
        virtual_machine__isnull=False).order_by(
            'virtual_machine',
            CollateAsChar('_name')).prefetch_related('virtual_machine', 'tags')
    serializer_class = serializers.InterfaceSerializer
    filterset_class = filters.InterfaceFilterSet

    def get_serializer_class(self):
        request = self.get_serializer_context()['request']
        if request.query_params.get('brief', False):
            # Override get_serializer_for_model(), which will return the DCIM NestedInterfaceSerializer
            return serializers.NestedInterfaceSerializer
        return serializers.InterfaceSerializer
Ejemplo n.º 2
0
 class Meta:
     verbose_name = 'interface'
     ordering = ('virtual_machine', CollateAsChar('_name'))
     unique_together = ('virtual_machine', 'name')
Ejemplo n.º 3
0
 class Meta:
     ordering = ('device', CollateAsChar('_name'))
     unique_together = ('device', 'name')
Ejemplo n.º 4
0
 class Meta:
     # TODO: ordering and unique_together should include virtual_machine
     ordering = ('device', CollateAsChar('_name'))
     unique_together = ('device', 'name')