diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/rest.py | 6 | ||||
| -rw-r--r-- | ishtar_common/static/js/ishtar.js | 11 | ||||
| -rw-r--r-- | ishtar_common/templates/blocks/DataTables-tabs.html | 4 | ||||
| -rw-r--r-- | ishtar_common/templates/blocks/DataTables.html | 3 | ||||
| -rw-r--r-- | ishtar_common/urls.py | 2 | ||||
| -rw-r--r-- | ishtar_common/views_item.py | 6 | ||||
| -rw-r--r-- | ishtar_common/wizards.py | 2 | 
7 files changed, 24 insertions, 10 deletions
| diff --git a/ishtar_common/rest.py b/ishtar_common/rest.py index e2e8ac581..2d3cefffd 100644 --- a/ishtar_common/rest.py +++ b/ishtar_common/rest.py @@ -53,9 +53,11 @@ class SearchAPIView(APIView):              request.GET._mutable = True              request.GET["search_vector"] = query              request.GET._mutable = False -        response = _get_item(request) +        data_type = "json" +        if request.GET.get("data_type", None): +            data_type = request.GET.get("data_type") +        response = _get_item(request, data_type=data_type)          return response -        # return Response({})  class FacetAPIView(APIView): diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 91273b50c..8a8cbb8e9 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -1190,7 +1190,8 @@ var get_hover_div = function(table_cols, data){      return hover;  }; -var _gallery_submit_search = function(image_page, query_vars, name, source){ +var _gallery_submit_search = function(image_page, query_vars, name, source, extra){ +	if (!extra) extra = "";      if (image_page) {          current_image_page = image_page;      } else { @@ -1198,16 +1199,16 @@ var _gallery_submit_search = function(image_page, query_vars, name, source){      }      $('.modal-progress').modal('show');      var data = search_get_query_data(query_vars, name); -    var nb_select = jQuery("#id_" + name + "-length_image").val(); +    var nb_select = jQuery("#id_" + name + "-length_image" + extra).val();      if (!nb_select) nb_select = 10;      var url = source + "json-image?length=" + nb_select + "&submited=1&" + data;      $.getJSON(url, function(data) {          var timestamp = Math.floor(Date.now() / 1000); -        var gallery_id = "gallery-" + timestamp; -        $("#tab-content-gallery-" + name).html( +        var gallery_id = "gallery-" + timestamp + extra; +        $("#content-gallery-" + name + extra).html(              render_gallery(data, name, nb_select, gallery_id)); -        $("#id_" + name + "-length_image").change(gallery_submit_search); +        $("#id_" + name + "-length_image" + extra).change(gallery_submit_search);          register_image_gallery(gallery_id);          $('.card[data-toggle="tooltip"]').tooltip();          if ($('.modal-progress').length > 0){ diff --git a/ishtar_common/templates/blocks/DataTables-tabs.html b/ishtar_common/templates/blocks/DataTables-tabs.html index f83850572..c7d50fdda 100644 --- a/ishtar_common/templates/blocks/DataTables-tabs.html +++ b/ishtar_common/templates/blocks/DataTables-tabs.html @@ -41,6 +41,10 @@    {% if gallery %}<div class="tab-pane"         id="tab-content-gallery-{{name}}" role="tabpanel"         aria-labelledby="tab-gallery-{{name}}"> +    <div id="content-gallery-{{name}}" class="sources sources-default"></div> +    {% if external_sources %}{% for source_id, source_label, source_url in external_sources %} +    <div id="content-gallery-{{name}}-{{source_id}}" class="sources sources-{{source_id}}"></div> +    {% endfor %}{% endif %}    </div>{% endif %}    {% if use_map %}<div class="tab-pane"         id="tab-content-map-{{name}}" role="tabpanel" diff --git a/ishtar_common/templates/blocks/DataTables.html b/ishtar_common/templates/blocks/DataTables.html index 91e55579e..3d1b817a8 100644 --- a/ishtar_common/templates/blocks/DataTables.html +++ b/ishtar_common/templates/blocks/DataTables.html @@ -83,6 +83,9 @@ var selItems_{{sname}} = new Array();  {% if gallery %}  gallery_submit_search = function(image_page){ +    {% if external_sources %}{% for source_id, source_label, source_url in external_sources %} +    _gallery_submit_search(image_page, query_vars, "{{name}}", "{{source_url}}", "-{{source_id}}"); +    {% endfor %}{% endif %}      return _gallery_submit_search(image_page, query_vars, "{{name}}", "{{source}}");  };  {% endif %} diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index 9fa0d59f0..8f7255d4e 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -314,7 +314,7 @@ urlpatterns += [          name="get-by-importer",      ),      url( -        r"search-external/(?P<model>[a-z-]+)/(?P<external_source_id>\d+)/", +        r"search-external/(?P<model>[a-z-]+)/(?P<external_source_id>\d+)/(?P<data_type>[a-z-]+)?",          views_item.get_distant_item,          name="search-external"      ), diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 0c766e82e..7ddfa179a 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -2352,7 +2352,8 @@ def get_item(  def get_distant_item(          request,          model, -        external_source_id +        external_source_id, +        data_type=None      ):      # TODO: check permissions      try: @@ -2364,6 +2365,9 @@ def get_distant_item(      url += reverse(f"api-search-{model}")      params = {k: v for k, v in dict(request.GET).items() if not k.startswith("columns")}      params["submited"] = 1 +    params["data_type"] = "json" +    if data_type: +        params["data_type"] = data_type      try:          response = requests.get(              url, diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index dff2bf2c5..34ed05e13 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -136,7 +136,7 @@ class IshtarWizard(NamedUrlWizardView):                      url = reverse("search-external", args=[base_model_name, src_id])                      context["external_sources"].append((src_id, lbl, url)) -        form.fields["pk"].widget.external_sources = context["external_sources"] +            form.fields["pk"].widget.external_sources = context["external_sources"]          open_item_id = self.request.GET.get("open_item", None)          if open_item_id and self.model and getattr(self.model, "SHOW_URL", None): | 
