diff --git a/combo/apps/wcs/models.py b/combo/apps/wcs/models.py index ff425ba3..613f054c 100644 --- a/combo/apps/wcs/models.py +++ b/combo/apps/wcs/models.py @@ -18,7 +18,6 @@ import collections import copy import logging -import urllib.parse from django.conf import settings from django.contrib.postgres.fields import JSONField @@ -139,20 +138,20 @@ class WcsFormCell(CellBase): populate_cache() def get_cell_extra_context(self, context): - request = context.get('request') - context = super().get_cell_extra_context(context) - context['slug'] = self.formdef_reference.split(':')[-1] - context['title'] = self.cached_title - context['url'] = self.cached_url - if not is_a_bot(request): - context['url'] += 'tryauth?cancelurl=%s' % urllib.parse.quote(request.build_absolute_uri()) + extra_context = super().get_cell_extra_context(context) + extra_context['slug'] = self.formdef_reference.split(':')[-1] + extra_context['title'] = self.cached_title + extra_context['url'] = self.cached_url + extra_context['request_is_a_bot'] = is_a_bot(context.get('request')) + extra_context['is_form'] = True + if self.cached_json: - context['description'] = mark_safe(self.cached_json.get('description', '')) - context['css_classes'] = get_formdef_css_classes(self.cached_json) + extra_context['description'] = mark_safe(self.cached_json.get('description', '')) + extra_context['css_classes'] = get_formdef_css_classes(self.cached_json) for attribute in self.cached_json: if attribute not in context: - context[attribute] = self.cached_json.get(attribute) - return context + extra_context[attribute] = self.cached_json.get(attribute) + return extra_context def get_additional_label(self): if not self.cached_title: diff --git a/combo/apps/wcs/templates/combo/wcs/form.html b/combo/apps/wcs/templates/combo/wcs/form.html index a70c5f22..ccbc67cb 100644 --- a/combo/apps/wcs/templates/combo/wcs/form.html +++ b/combo/apps/wcs/templates/combo/wcs/form.html @@ -1,9 +1,5 @@ {% block cell-content %} -
{{ title }} -{% if description %} -
-{{ description }} -
-{% endif %} +
+{% include "combo/wcs/form_link_fragment.html" %}
{% endblock %} diff --git a/combo/apps/wcs/templates/combo/wcs/form_link_fragment.html b/combo/apps/wcs/templates/combo/wcs/form_link_fragment.html index b5bf08eb..0c850e4e 100644 --- a/combo/apps/wcs/templates/combo/wcs/form_link_fragment.html +++ b/combo/apps/wcs/templates/combo/wcs/form_link_fragment.html @@ -1,7 +1,14 @@ +{% firstof form.url url as form_url %} +{% firstof form.title title as form_title %} +{% autoescape off %} +{% firstof form.description description as form_description %} +{% endautoescape %} + + {% block form-link-pre %}{% endblock %} -{% block form-link-title %}{{ form.title }}{% endblock %} -{% if form.description %} -
{% block form-link-description %}{{ form.description|safe }}{% endblock %}
+{% block form-link-title %}{{ form_title }}{% endblock %} +{% if form_description %} +
{% block form-link-description %}{{ form_description|safe }}{% endblock %}
{% endif %} {% block form-link-post %}{% endblock %} diff --git a/combo/apps/wcs/templates/combo/wcs/forms_of_category.html b/combo/apps/wcs/templates/combo/wcs/forms_of_category.html index fd206cc1..26d9a7c9 100644 --- a/combo/apps/wcs/templates/combo/wcs/forms_of_category.html +++ b/combo/apps/wcs/templates/combo/wcs/forms_of_category.html @@ -15,7 +15,7 @@ {% block cell-top-content %}{% endblock cell-top-content %}