Projet

Général

Profil

0001-data-add-cell-get_ajax_url-method-66956.patch

Valentin Deniaud, 05 juillet 2022 11:08

Télécharger (3,1 ko)

Voir les différences:

Subject: [PATCH 1/2] data: add cell get_ajax_url method (#66956)

 combo/apps/dashboard/templates/combo/dashboardcell.html | 2 +-
 combo/data/models.py                                    | 7 +++++++
 combo/public/templates/combo/placeholder.html           | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)
combo/apps/dashboard/templates/combo/dashboardcell.html
3 3
{% for tile in tiles %}
4 4
{% with cell=tile.cell %}
5 5
<div class="cell {{ cell.css_class_names }} {% if cell.slug %}{{cell.slug}}{% endif %}"
6
     data-ajax-cell-url="{{ site_base }}{% url 'combo-public-ajax-page-cell' page_pk=cell.page.id cell_reference=cell.get_reference %}"
6
     data-ajax-cell-url="{{ site_base }}{{ cell.get_ajax_url }}"
7 7
     data-ajax-cell-loading-message="{{ cell.loading_message }}"
8 8
     data-ajax-cell-error-message="{% trans "Loading error" %}"
9 9
     {% if cell.ajax_refresh %}
combo/data/models.py
54 54
    engines,
55 55
)
56 56
from django.test.client import RequestFactory
57
from django.urls import reverse
57 58
from django.utils import timezone
58 59
from django.utils.encoding import force_text, smart_bytes
59 60
from django.utils.html import strip_tags
......
862 863
    def get_additional_label(self):
863 864
        return ''
864 865

  
866
    def get_ajax_url(self):
867
        return reverse(
868
            'combo-public-ajax-page-cell',
869
            kwargs={'page_pk': self.page_id, 'cell_reference': self.get_reference()},
870
        )
871

  
865 872
    def get_manager_visibility_css_class(self):
866 873
        if self.public:
867 874
            return 'visibility-all' if not self.restricted_to_unlogged else ''
combo/public/templates/combo/placeholder.html
8 8
{% for cell in cells %}
9 9
<div class="cell {{ cell.css_class_names }} {{ cell.asset_css_classes }}{% if cell.slug %} {{cell.slug}}{% endif %}{% if cell|shown_because_admin:request %} shown-because-admin{% endif %}"
10 10
     {% if cell.slug and cell.use_slug_as_id %}id="{{ cell.slug }}"{% endif %}
11
     data-ajax-cell-url="{{ site_base }}{% url 'combo-public-ajax-page-cell' page_pk=cell.page_id cell_reference=cell.get_reference %}"
11
     data-ajax-cell-url="{{ site_base }}{{ cell.get_ajax_url }}"
12 12
     data-ajax-cell-loading-message="{{ cell.loading_message }}"
13 13
     data-ajax-cell-error-message="{% trans "Loading error" %}"
14 14
     {% if cell.ajax_refresh %}data-ajax-cell-refresh="{{ cell.ajax_refresh }}"{% endif %}
15
-