def get_exampleservice(self, o):
        if not o.provider_service:
            return None

        exampleservice = ExampleService.get_service_objects().filter(id=o.provider_service.id)

        if not exampleservice:
            return None

        return exampleservice[0]
Beispiel #2
0
    def get_exampleservice(self, o):
        if not o.provider_service:
            return None

        exampleservice = ExampleService.get_service_objects().filter(id=o.provider_service.id)

        if not exampleservice:
            return None

        return exampleservice[0]
Beispiel #3
0
class ExampleTenantSerializer(PlusModelSerializer):
        id = ReadOnlyField()
        provider_service = serializers.PrimaryKeyRelatedField(queryset=ExampleService.get_service_objects().all(), default=get_default_example_service)
        tenant_message = serializers.CharField(required=False)
        backend_status = ReadOnlyField()

        humanReadableName = serializers.SerializerMethodField("getHumanReadableName")

        class Meta:
            model = ExampleTenant
            fields = ('humanReadableName', 'id', 'provider_service', 'tenant_message', 'backend_status')

        def getHumanReadableName(self, obj):
            return obj.__unicode__()
Beispiel #4
0
class ExampleServiceViewSet(XOSViewSet):
    base_name = "exampleservice"
    method_name = "exampleservice"
    method_kind = "viewset"
    queryset = ExampleService.get_service_objects().all()
    serializer_class = ExampleServiceSerializer

    @classmethod
    def get_urlpatterns(self, api_path="^"):
        patterns = super(ExampleServiceViewSet,
                         self).get_urlpatterns(api_path=api_path)

        return patterns

    def list(self, request):
        object_list = self.filter_queryset(self.get_queryset())

        serializer = self.get_serializer(object_list, many=True)

        return Response(serializer.data)
Beispiel #5
0
def get_default_example_service():
    example_services = ExampleService.get_service_objects().all()
    if example_services:
        return example_services[0]
    return None
Beispiel #6
0
def get_default_example_service():
    example_services = ExampleService.get_service_objects().all()
    if example_services:
        return example_services[0]
    return None