aboutsummaryrefslogtreecommitdiffstats
path: root/main/py-django-oscar/0003-Update-the-custom-form-widgets-for-Django-1.11.patch
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-08-10 23:01:42 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-08-10 23:01:42 +0300
commitd2a295f9bd96a6317173f1d38f79907a8373ef52 (patch)
tree96b08fc05147395cf00adae66dbf2b99360109cb /main/py-django-oscar/0003-Update-the-custom-form-widgets-for-Django-1.11.patch
parentc2c616e5b0ba47f2936116cfc41ba270a1e4170b (diff)
downloadaports-d2a295f9bd96a6317173f1d38f79907a8373ef52.tar.bz2
aports-d2a295f9bd96a6317173f1d38f79907a8373ef52.tar.xz
main/py-django-oscar: upgrade to 1.5
Diffstat (limited to 'main/py-django-oscar/0003-Update-the-custom-form-widgets-for-Django-1.11.patch')
-rw-r--r--main/py-django-oscar/0003-Update-the-custom-form-widgets-for-Django-1.11.patch131
1 files changed, 0 insertions, 131 deletions
diff --git a/main/py-django-oscar/0003-Update-the-custom-form-widgets-for-Django-1.11.patch b/main/py-django-oscar/0003-Update-the-custom-form-widgets-for-Django-1.11.patch
deleted file mode 100644
index 0dbef929ff..0000000000
--- a/main/py-django-oscar/0003-Update-the-custom-form-widgets-for-Django-1.11.patch
+++ /dev/null
@@ -1,131 +0,0 @@
-From bf41f12337554af742148e1d04427974c3ed33fc Mon Sep 17 00:00:00 2001
-From: Michael van Tellingen <michael@mvantellingen.nl>
-Date: Thu, 6 Apr 2017 17:04:19 +0200
-Subject: [PATCH 3/8] Update the custom form widgets for Django 1.11
-
-In Django 1.11 the widgets are rendered with templates instead of
-python code. Update the code for this change
----
- src/oscar/apps/customer/abstract_models.py | 5 ++---
- src/oscar/forms/widgets.py | 28 ++++++++++++++++++++--------
- 2 files changed, 22 insertions(+), 11 deletions(-)
-
-diff --git a/src/oscar/apps/customer/abstract_models.py b/src/oscar/apps/customer/abstract_models.py
-index 9a6c5ee..055fda3 100644
---- a/src/oscar/apps/customer/abstract_models.py
-+++ b/src/oscar/apps/customer/abstract_models.py
-@@ -6,7 +6,7 @@ from django.contrib.auth import models as auth_models
- from django.core.urlresolvers import reverse
- from django.core.validators import RegexValidator
- from django.db import models
--from django.template import Template, TemplateDoesNotExist
-+from django.template import Context, TemplateDoesNotExist, engines
- from django.template.loader import get_template
- from django.utils import six, timezone
- from django.utils.encoding import python_2_unicode_compatible
-@@ -222,7 +222,7 @@ class AbstractCommunicationEventType(models.Model):
- field = getattr(self, attr_name, None)
- if field is not None:
- # Template content is in a model field
-- templates[name] = Template(field)
-+ templates[name] = engines['django'].from_string(field)
- else:
- # Model field is empty - look for a file template
- template_name = getattr(self, "%s_file" % attr_name) % code
-@@ -238,7 +238,6 @@ class AbstractCommunicationEventType(models.Model):
- settings, 'OSCAR_STATIC_BASE_URL', None)
-
- messages = {}
-- ctx = {}
- for name, template in templates.items():
- messages[name] = template.render(ctx) if template else ''
-
-diff --git a/src/oscar/forms/widgets.py b/src/oscar/forms/widgets.py
-index 5b374cf..cdeb6b9 100644
---- a/src/oscar/forms/widgets.py
-+++ b/src/oscar/forms/widgets.py
-@@ -1,5 +1,6 @@
- import re
-
-+import django
- from django import forms
- from django.core.files.uploadedfile import InMemoryUploadedFile
- from django.forms.utils import flatatt
-@@ -23,7 +24,7 @@ class ImageInput(FileInput):
- template_name = 'partials/image_input_widget.html'
- attrs = {'accept': 'image/*'}
-
-- def render(self, name, value, attrs=None):
-+ def render(self, name, value, attrs=None, renderer=None):
- """
- Render the ``input`` field based on the defined ``template_name``. The
- image URL is take from *value* and is provided to the template as
-@@ -33,7 +34,15 @@ class ImageInput(FileInput):
- If *value* contains no valid image URL an empty string will be provided
- in the context.
- """
-- final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
-+ extra_attrs = {
-+ 'type': self.input_type,
-+ 'name': name,
-+ }
-+ if django.VERSION < (1, 11):
-+ final_attrs = self.build_attrs(attrs, **extra_attrs)
-+ else:
-+ final_attrs = self.build_attrs(attrs, extra_attrs=extra_attrs)
-+
- if not value or isinstance(value, InMemoryUploadedFile):
- # can't display images that aren't stored
- image_url = ''
-@@ -163,7 +172,7 @@ class TimePickerInput(DateTimeWidgetMixin, forms.TimeInput):
- """
- format_key = 'TIME_INPUT_FORMATS'
-
-- def render(self, name, value, attrs=None):
-+ def render(self, name, value, attrs=None, renderer=None):
- format = self.get_format()
- input = super(TimePickerInput, self).render(
- name, value, self.gett_attrs(attrs, format))
-@@ -192,7 +201,7 @@ class DatePickerInput(DateTimeWidgetMixin, forms.DateInput):
- """
- format_key = 'DATE_INPUT_FORMATS'
-
-- def render(self, name, value, attrs=None):
-+ def render(self, name, value, attrs=None, renderer=None):
- format = self.get_format()
- input = super(DatePickerInput, self).render(
- name, value, self.gett_attrs(attrs, format))
-@@ -235,7 +244,7 @@ class DateTimePickerInput(DateTimeWidgetMixin, forms.DateTimeInput):
- if not include_seconds and self.format:
- self.format = re.sub(':?%S', '', self.format)
-
-- def render(self, name, value, attrs=None):
-+ def render(self, name, value, attrs=None, renderer=None):
- format = self.get_format()
- input = super(DateTimePickerInput, self).render(
- name, value, self.gett_attrs(attrs, format))
-@@ -314,15 +323,18 @@ class RemoteSelect(forms.Widget):
- else:
- return six.text_type(value)
-
-- def render(self, name, value, attrs=None, choices=()):
-- attrs = self.build_attrs(attrs, **{
-+ def render(self, name, value, attrs=None, renderer=None):
-+ attrs = {} if attrs is None else attrs
-+
-+ extra_attrs = {
- 'type': 'hidden',
- 'name': name,
- 'data-ajax-url': self.lookup_url,
- 'data-multiple': 'multiple' if self.is_multiple else '',
- 'value': self.format_value(value),
- 'data-required': 'required' if self.is_required else '',
-- })
-+ }
-+ attrs = self.build_attrs(attrs, extra_attrs=extra_attrs)
- return mark_safe(u'<input %s>' % flatatt(attrs))
-
-
---
-2.9.4
-