Skip to content

Commit b825b80

Browse files
committed
Merge branch 'releases/2.3'
2 parents 361fe66 + 0007a12 commit b825b80

26 files changed

+37
-403
lines changed

.travis.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,24 @@ services:
66
language: python
77

88
python:
9-
- 2.7
109
- 3.6
1110
- 3.7
11+
- 3.8
1212

1313
env:
14-
- DJANGOVER=django110
15-
- DJANGOVER=django111
16-
- DJANGOVER=django20
1714
- DJANGOVER=django21
1815
- DJANGOVER=django22
16+
- DJANGOVER=django30
1917

2018
install:
2119
- pip install tox
2220

2321
matrix:
2422
exclude:
25-
- python: 2.7
26-
env: DJANGOVER=django20
27-
- python: 2.7
23+
- python: 3.8
2824
env: DJANGOVER=django21
29-
- python: 2.7
25+
- python: 3.8
3026
env: DJANGOVER=django22
31-
- python: 3.6
32-
env: DJANGOVER=django110
33-
- python: 3.7
34-
env: DJANGOVER=django110
35-
- python: 3.7
36-
env: DJANGOVER=django111
37-
- python: 3.7
38-
env: DJANGOVER=django20
3927

4028
before_script:
4129
- export CHROME_BIN=chromium-browser

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Contributors are listed in alphabetical order by GitHub login.
3737
* [Thomas Fillon (thomasfillon)](https://github.com/thomasfillon)[1+](https://github.com/jrief/django-angular/commits?author=thomasfillon)/[1+](https://github.com/jrief/django-angular/issues?q=author%3Athomasfillon)
3838
* [Tino de Bruijn (tino)](https://github.com/tino)[1+](https://github.com/jrief/django-angular/commits?author=tino)/[1+](https://github.com/jrief/django-angular/issues?q=author%3Atino)
3939
* [Ulrich Wagner (viaregio)](https://github.com/viaregio)[3+](https://github.com/jrief/django-angular/commits?author=viaregio)/[2+](https://github.com/jrief/django-angular/issues?q=author%3Aviaregio)
40+
* [Oshosanya Michael (oshosanya)](https://github.com/oshosanya)
4041

4142
Numbers link to commits/issues.
4243
For simplicity, this file is maintained only in English.

djng/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
31
"""
42
See PEP 386 (https://www.python.org/dev/peps/pep-0386/)
53
@@ -20,6 +18,6 @@
2018
13. git push
2119
"""
2220

23-
__version__ = '2.2.4'
21+
__version__ = '2.3'
2422

2523
default_app_config = 'djng.app_config.DjangoAngularConfig'

djng/app_config.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.apps import AppConfig
52

63

74
class DjangoAngularConfig(AppConfig):
85
name = 'djng'
96

107
def ready(self):
11-
from django import VERSION
128
from django.forms.widgets import RadioSelect
139

1410
def id_for_label(self, id_, index=None):
1511
if id_ and index and self.add_id_index:
1612
id_ = '%s_%s' % (id_, index)
1713
return id_
1814

19-
if VERSION >= (1, 11):
20-
RadioSelect.id_for_label = id_for_label
21-
15+
RadioSelect.id_for_label = id_for_label

djng/app_settings.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
4-
51
class AppSettings(object):
62
def _setting(self, name, default=None):
73
from django.conf import settings

djng/core/urlresolvers.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
31
from inspect import isclass
42

5-
from django.utils import six
63
from django.urls import (get_resolver, get_urlconf, resolve, reverse, NoReverseMatch)
74
from django.core.exceptions import ImproperlyConfigured
85

@@ -38,7 +35,7 @@ def get_all_remote_methods(resolver=None, ns_prefix=''):
3835
resolver = get_resolver(get_urlconf())
3936
result = {}
4037
for name in resolver.reverse_dict.keys():
41-
if not isinstance(name, six.string_types):
38+
if not isinstance(name, str):
4239
continue
4340
try:
4441
url = reverse(ns_prefix + name)

djng/forms/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from django.forms.forms import DeclarativeFieldsMetaclass, BaseForm
33
from django.forms.models import BaseModelForm, ModelFormMetaclass
4-
from django.utils import six
54
from .angular_base import BaseFieldsModifierMetaclass, NgFormBaseMixin
65
from .angular_model import NgModelFormMixin
76
from .angular_validation import NgFormValidationMixin
@@ -11,7 +10,7 @@ class NgDeclarativeFieldsMetaclass(BaseFieldsModifierMetaclass, DeclarativeField
1110
pass
1211

1312

14-
class NgForm(six.with_metaclass(NgDeclarativeFieldsMetaclass, NgFormBaseMixin, BaseForm)):
13+
class NgForm(NgFormBaseMixin, BaseForm, metaclass=NgDeclarativeFieldsMetaclass):
1514
"""
1615
Convenience class to be used instead of Django's internal ``forms.Form`` when declaring
1716
a form to be used with AngularJS.
@@ -22,7 +21,7 @@ class NgModelFormMetaclass(BaseFieldsModifierMetaclass, ModelFormMetaclass):
2221
pass
2322

2423

25-
class NgModelForm(six.with_metaclass(NgModelFormMetaclass, NgFormBaseMixin, BaseModelForm)):
24+
class NgModelForm(NgFormBaseMixin, BaseModelForm, metaclass=NgModelFormMetaclass):
2625
"""
2726
Convenience class to be used instead of Django's internal ``forms.ModelForm`` when declaring
2827
a model form to be used with AngularJS.

djng/forms/angular_base.py

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
4-
import json
51
from base64 import b64encode
6-
7-
try:
8-
from collections import UserList
9-
except ImportError: # Python 2
10-
from UserList import UserList
11-
2+
from collections import UserList
3+
import json
124
import warnings
135

14-
from django import VERSION as DJANGO_VERSION
156
from django.forms import forms
167
from django.http import QueryDict
17-
from django.utils import six
18-
try:
19-
from importlib import import_module
20-
except ImportError:
21-
from django.utils.importlib import import_module
228
from django.utils.html import format_html, format_html_join, escape, conditional_escape
23-
from django.utils.encoding import python_2_unicode_compatible, force_text
9+
from django.utils.encoding import force_text
2410
from django.utils.module_loading import import_string
2511
from django.utils.safestring import mark_safe, SafeText, SafeData
2612
from django.core.exceptions import ValidationError, ImproperlyConfigured
@@ -35,7 +21,6 @@ class SafeTuple(SafeData, tuple):
3521
"""
3622

3723

38-
@python_2_unicode_compatible
3924
class TupleErrorList(UserList, list):
4025
"""
4126
A list of errors, which in contrast to Django's ErrorList, can contain a tuple for each item.
@@ -209,12 +194,11 @@ def as_widget(self, widget=None, attrs=None, only_initial=False):
209194
if not widget:
210195
widget = self.field.widget
211196

212-
if DJANGO_VERSION > (1, 10):
213-
# so that we can refer to the field when building the rendering context
214-
widget._field = self.field
215-
# Make sure that NgWidgetMixin is not already part of the widget's bases so it doesn't get added twice.
216-
if not isinstance(widget, NgWidgetMixin):
217-
widget.__class__ = type(widget.__class__.__name__, (NgWidgetMixin, widget.__class__), {})
197+
# so that we can refer to the field when building the rendering context
198+
widget._field = self.field
199+
# Make sure that NgWidgetMixin is not already part of the widget's bases so it doesn't get added twice.
200+
if not isinstance(widget, NgWidgetMixin):
201+
widget.__class__ = type(widget.__class__.__name__, (NgWidgetMixin, widget.__class__), {})
218202
return super(NgBoundField, self).as_widget(widget, attrs, only_initial)
219203

220204
def build_widget_attrs(self, attrs, widget=None):
@@ -297,15 +281,11 @@ def __init__(self, *args, **kwargs):
297281
try:
298282
form_name = self.form_name
299283
except AttributeError:
300-
# if form_name is unset, then generate a pseudo unique name, based upon the class name
301-
form_name = b64encode(six.b(self.__class__.__name__)).rstrip(six.b('='))
302-
if six.PY3:
303-
form_name = form_name.decode('utf-8')
284+
# if form_name is unset, generate a pseudo unique name, based upon the class name
285+
form_name = b64encode(self.__class__.__name__.encode()).rstrip(b'=').decode('utf-8')
304286
self.form_name = kwargs.pop('form_name', form_name)
305287
error_class = kwargs.pop('error_class', TupleErrorList)
306288
kwargs.setdefault('error_class', error_class)
307-
if DJANGO_VERSION < (1, 11):
308-
self.convert_widgets()
309289
super(NgFormBaseMixin, self).__init__(*args, **kwargs)
310290
if isinstance(self.data, QueryDict):
311291
self.data = self.rectify_multipart_form_data(self.data.copy())
@@ -364,19 +344,6 @@ def update_widget_attrs(self, bound_field, attrs):
364344
attrs.update({'class': widget_classes})
365345
return attrs
366346

367-
def convert_widgets(self):
368-
"""
369-
During form initialization, some widgets have to be replaced by a counterpart suitable to
370-
be rendered the AngularJS way.
371-
"""
372-
warnings.warn("Will be removed after dropping support for Django-1.10", PendingDeprecationWarning)
373-
widgets_module = getattr(self, 'widgets_module', 'djng.widgets')
374-
for field in self.base_fields.values():
375-
if hasattr(field, 'get_converted_widget'):
376-
new_widget = field.get_converted_widget(widgets_module)
377-
if new_widget:
378-
field.widget = new_widget
379-
380347
def rectify_multipart_form_data(self, data):
381348
"""
382349
If a widget was converted and the Form data was submitted through a multipart request,

djng/forms/angular_model.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.forms.utils import ErrorDict
52
from django.utils.html import format_html
63
from djng.forms.angular_base import NgFormBaseMixin, SafeTuple

djng/forms/angular_validation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
31
from django.forms import widgets
42
from django.utils.html import format_html
53
from django.utils.encoding import force_text

0 commit comments

Comments
 (0)