diff --git a/_modules/apis_core/apis_entities/api_views.html b/_modules/apis_core/apis_entities/api_views.html index 3b6329af8..1b67e4b21 100644 --- a/_modules/apis_core/apis_entities/api_views.html +++ b/_modules/apis_core/apis_entities/api_views.html @@ -91,10 +91,14 @@

Source code for apis_core.apis_entities.api_views

 from django.shortcuts import redirect
+from django.db.models import Q
 from rest_framework.views import APIView
 from rest_framework.exceptions import NotFound
+from rest_framework.generics import ListAPIView
 
 from apis_core.apis_metainfo.models import RootObject
+from apis_core.apis_entities.serializers import MinimalEntitySerializer
+from apis_core.apis_entities.utils import get_entity_classes
 
 
 
@@ -110,6 +114,24 @@

Source code for apis_core.apis_entities.api_views

raise NotFound
+ + +
+[docs] +class ListEntityGeneric(ListAPIView): + serializer_class = MinimalEntitySerializer + +
+[docs] + def get_queryset(self): + entities = get_entity_classes() + entities = [entity._meta.model_name for entity in entities] + q = Q() + for entity in entities: + q |= Q(**{f"{entity}__isnull": False}) + return RootObject.objects_inheritance.select_subclasses().filter(q)
+
+
diff --git a/_modules/apis_core/apis_entities/serializers.html b/_modules/apis_core/apis_entities/serializers.html new file mode 100644 index 000000000..98b861a42 --- /dev/null +++ b/_modules/apis_core/apis_entities/serializers.html @@ -0,0 +1,140 @@ + + + + + + apis_core.apis_entities.serializers — APIS 1.0 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + + +
  • +
  • +
+
+
+
+
+ +

Source code for apis_core.apis_entities.serializers

+from rest_framework import serializers
+from apis_core.generic.serializers import GenericHyperlinkedIdentityField
+
+
+
+[docs] +class MinimalEntitySerializer(serializers.Serializer): + uri = GenericHyperlinkedIdentityField( + view_name="apis_core:generic:genericmodelapi-detail" + ) + name = serializers.SerializerMethodField(method_name="get_name") + +
+[docs] + def get_name(self, object): + return str(object)
+
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/_modules/apis_core/apis_entities/utils.html b/_modules/apis_core/apis_entities/utils.html new file mode 100644 index 000000000..318e88549 --- /dev/null +++ b/_modules/apis_core/apis_entities/utils.html @@ -0,0 +1,131 @@ + + + + + + apis_core.apis_entities.utils — APIS 1.0 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + + +
  • +
  • +
+
+
+
+
+ +

Source code for apis_core.apis_entities.utils

+from django.apps import apps
+from apis_core.apis_entities.models import AbstractEntity
+
+
+
+[docs] +def get_entity_classes(): + return list(filter(lambda x: issubclass(x, AbstractEntity), apps.get_models()))
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/_modules/index.html b/_modules/index.html index a854b4ce7..9d9bd5c63 100644 --- a/_modules/index.html +++ b/_modules/index.html @@ -98,10 +98,12 @@

All modules for which code is available

  • apis_core.apis_entities.filtersets
  • apis_core.apis_entities.forms
  • apis_core.apis_entities.models
  • +
  • apis_core.apis_entities.serializers
  • apis_core.apis_entities.tables
  • apis_core.apis_entities.test_api
  • apis_core.apis_entities.test_models
  • apis_core.apis_entities.urls
  • +
  • apis_core.apis_entities.utils
  • apis_core.apis_entities.views
  • apis_core.apis_metainfo.api_renderers
  • apis_core.apis_metainfo.apps
  • diff --git a/_sources/modules/apis_core.apis_entities.rst.txt b/_sources/modules/apis_core.apis_entities.rst.txt index 9568b29ff..659e68161 100644 --- a/_sources/modules/apis_core.apis_entities.rst.txt +++ b/_sources/modules/apis_core.apis_entities.rst.txt @@ -89,6 +89,14 @@ apis\_core.apis\_entities.models module :undoc-members: :show-inheritance: +apis\_core.apis\_entities.serializers module +-------------------------------------------- + +.. automodule:: apis_core.apis_entities.serializers + :members: + :undoc-members: + :show-inheritance: + apis\_core.apis\_entities.signals module ---------------------------------------- @@ -137,6 +145,14 @@ apis\_core.apis\_entities.urls module :undoc-members: :show-inheritance: +apis\_core.apis\_entities.utils module +-------------------------------------- + +.. automodule:: apis_core.apis_entities.utils + :members: + :undoc-members: + :show-inheritance: + apis\_core.apis\_entities.views module -------------------------------------- diff --git a/genindex.html b/genindex.html index 76691bc6e..c7137a265 100644 --- a/genindex.html +++ b/genindex.html @@ -229,6 +229,13 @@

    A

    +
  • + apis_core.apis_entities.serializers + +
  • @@ -271,6 +278,13 @@

    A

  • +
  • + apis_core.apis_entities.utils + +
  • @@ -469,6 +483,8 @@

    A

  • module
  • + + - -
  • get_entity_class_of_name() (in module apis_core.utils.caching)
  • - - +
  • apis_core.apis_entities.apps module
  • +
  • apis_core.apis_entities.serializers module +
  • apis_core.apis_entities.signals module
  • apis_core.apis_entities.tables module