From 4931027d901e856b1474a52211bf7615c76cd8ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20B=C3=B6hm?= Date: Thu, 8 Aug 2019 14:14:54 +0200 Subject: [PATCH 1/3] Adjust Django versions to >= 1.11, < 2.2.99. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 43d9bc11..0aee9e53 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,7 @@ "sphinx-me >= 0.1.2", "unidecode", "django-email-extras >= 0.2", - "django >= 1.8, < 2.2", + "django >= 1.11, < 2.2.99", "future <= 0.15.0", ], classifiers = [ From ac4520884ef0752c6088fbf75986d105c38729a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20B=C3=B6hm?= Date: Fri, 9 Aug 2019 13:02:34 +0200 Subject: [PATCH 2/3] Make safe admin_links for Django 2. --- forms_builder/example_project/settings.py | 1 + forms_builder/forms/models.py | 10 ++++------ forms_builder/forms/tests.py | 12 ++++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/forms_builder/example_project/settings.py b/forms_builder/example_project/settings.py index 27190666..767f6515 100644 --- a/forms_builder/example_project/settings.py +++ b/forms_builder/example_project/settings.py @@ -78,6 +78,7 @@ 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.staticfiles', + 'django.contrib.messages', 'forms_builder.forms', ) diff --git a/forms_builder/forms/models.py b/forms_builder/forms/models.py index 73c6ae3b..59b6d6bf 100644 --- a/forms_builder/forms/models.py +++ b/forms_builder/forms/models.py @@ -2,6 +2,7 @@ from django import VERSION as DJANGO_VERSION from django.contrib.sites.models import Site +from django.utils.html import format_html_join try: from django.urls import reverse @@ -142,16 +143,13 @@ def get_absolute_url(self): return reverse("form_detail", kwargs={"slug": self.slug}) def admin_links(self): - kw = {"args": (self.id,)} - links = [ + kw = {"args": (self.id, )} + return format_html_join("\n", "
{0}
", ( (_("View form on site"), self.get_absolute_url()), (_("Filter entries"), reverse("admin:form_entries", **kw)), (_("View all entries"), reverse("admin:form_entries_show", **kw)), (_("Export all entries"), reverse("admin:form_entries_export", **kw)), - ] - for i, (text, url) in enumerate(links): - links[i] = "%s" % (url, ugettext(text)) - return "
".join(links) + )) admin_links.allow_tags = True admin_links.short_description = "" diff --git a/forms_builder/forms/tests.py b/forms_builder/forms/tests.py index ace512b0..817f1179 100644 --- a/forms_builder/forms/tests.py +++ b/forms_builder/forms/tests.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +from django.utils.safestring import SafeText from django.conf import settings from django.contrib.auth.models import User, AnonymousUser from django.contrib.sites.models import Site @@ -239,3 +240,14 @@ def test_input_dropdown_required_with_default(self): """, html=True) + + def test_admin_link(self): + form = Form.objects.create(title="Test") + content = form.admin_links() + self.assertIsInstance(content, SafeText) + self.assertInHTML(content, """ +
View form on site
+
Filter entries
+
View all entries
+
Export all entries
+ """) From a11c067474cde5039dc9c021271db95067bd75fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20B=C3=B6hm?= Date: Fri, 9 Aug 2019 14:33:15 +0200 Subject: [PATCH 3/3] Add DJANGO_VERSION 2.2.x into travis config. --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4bf3634e..32ad431d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ env: - DJANGO_VERSION=https://github.com/django/django/archive/stable/1.11.x.zip - DJANGO_VERSION=https://github.com/django/django/archive/stable/2.0.x.zip - DJANGO_VERSION=https://github.com/django/django/archive/stable/2.1.x.zip + - DJANGO_VERSION=https://github.com/django/django/archive/stable/2.2.x.zip python: - "2.7" - "3.4" @@ -17,8 +18,12 @@ matrix: env: DJANGO_VERSION=https://github.com/django/django/archive/stable/2.0.x.zip - python: "2.7" env: DJANGO_VERSION=https://github.com/django/django/archive/stable/2.1.x.zip + - python: "2.7" + env: DJANGO_VERSION=https://github.com/django/django/archive/stable/2.2.x.zip - python: "3.4" env: DJANGO_VERSION=https://github.com/django/django/archive/stable/2.1.x.zip + - python: "3.4" + env: DJANGO_VERSION=https://github.com/django/django/archive/stable/2.2.x.zip install: - pip install $DJANGO_VERSION - pip install .