Loading django/forms/widgets.py +13 −1 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ class Media(object): getattr(combined, 'add_' + name)(getattr(other, '_' + name, None)) return combined def media_property(cls): def _media(self): # Get the media property of the superclass, if it exists Loading Loading @@ -131,6 +132,7 @@ def media_property(cls): return base return property(_media) class MediaDefiningClass(type): """ Metaclass for classes that can have media definitions. Loading Loading @@ -162,6 +164,7 @@ class SubWidget(object): args.append(self.choices) return self.parent_widget.render(*args) class Widget(six.with_metaclass(MediaDefiningClass)): is_hidden = False # Determines whether this corresponds to an <input type="hidden">. needs_multipart_form = False # Determines does this widget need multipart form Loading Loading @@ -224,6 +227,7 @@ class Widget(six.with_metaclass(MediaDefiningClass)): """ return id_ class Input(Widget): """ Base class for all <input> widgets (except type='checkbox' and Loading Loading @@ -279,10 +283,12 @@ class PasswordInput(TextInput): value = None return super(PasswordInput, self).render(name, value, attrs) class HiddenInput(Input): input_type = 'hidden' is_hidden = True class MultipleHiddenInput(HiddenInput): """ A widget that handles <input type="hidden"> for fields that have a list Loading Loading @@ -313,6 +319,7 @@ class MultipleHiddenInput(HiddenInput): return data.getlist(name) return data.get(name, None) class FileInput(Input): input_type = 'file' needs_multipart_form = True Loading @@ -327,6 +334,7 @@ class FileInput(Input): FILE_INPUT_CONTRADICTION = object() class ClearableFileInput(FileInput): initial_text = ugettext_lazy('Currently') input_text = ugettext_lazy('Change') Loading Loading @@ -380,6 +388,7 @@ class ClearableFileInput(FileInput): upload = super(ClearableFileInput, self).value_from_datadict(data, files, name) if not self.is_required and CheckboxInput().value_from_datadict( data, files, self.clear_checkbox_name(name)): if upload: # If the user contradicts themselves (uploads a new file AND # checks the "clear" checkbox), we return a unique marker Loading @@ -389,6 +398,7 @@ class ClearableFileInput(FileInput): return False return upload class Textarea(Widget): def __init__(self, attrs=None): # The 'rows' and 'cols' attributes are required for HTML correctness. Loading Loading @@ -515,6 +525,7 @@ class Select(Widget): output.append(self.render_option(selected_choices, option_value, option_label)) return '\n'.join(output) class NullBooleanSelect(Select): """ A Select Widget intended to be used with NullBooleanField. Loading Loading @@ -849,6 +860,7 @@ class SplitDateTimeWidget(MultiWidget): return [value.date(), value.time().replace(microsecond=0)] return [None, None] class SplitHiddenDateTimeWidget(SplitDateTimeWidget): """ A Widget that splits datetime input into two <input type="hidden"> inputs. Loading setup.cfg +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh [flake8] exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/* ignore=E124,E125,E127,E128,E226,E251,E302,E501,E261,W601 ignore=E124,E125,E127,E128,E226,E251,E501,E261,W601 [metadata] license-file = LICENSE Loading tests/multiple_database/tests.py +21 −15 Original line number Diff line number Diff line Loading @@ -50,7 +50,8 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Pro Django" should exist on default database') self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.using('other').get, title="Pro Django" ) Loading @@ -61,7 +62,8 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Dive into Python" should exist on default database') self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.using('other').get, title="Dive into Python" ) Loading @@ -84,11 +86,13 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Pro Django" should exist on other database') self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.get, title="Pro Django" ) self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.using('default').get, title="Pro Django" ) Loading @@ -98,11 +102,13 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Dive into Python" should exist on other database') self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.get, title="Dive into Python" ) self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.using('default').get, title="Dive into Python" ) Loading tests/mutually_referential/models.py +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ class Parent(models.Model): # Use a simple string for forward declarations. bestchild = models.ForeignKey("Child", null=True, related_name="favoured_by") class Child(models.Model): name = models.CharField(max_length=100) Loading tests/nested_foreign_keys/models.py +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ class Event(models.Model): class Screening(Event): movie = models.ForeignKey(Movie) class ScreeningNullFK(Event): movie = models.ForeignKey(Movie, null=True) Loading @@ -24,5 +25,6 @@ class ScreeningNullFK(Event): class Package(models.Model): screening = models.ForeignKey(Screening, null=True) class PackageNullFK(models.Model): screening = models.ForeignKey(ScreeningNullFK, null=True) Loading
django/forms/widgets.py +13 −1 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ class Media(object): getattr(combined, 'add_' + name)(getattr(other, '_' + name, None)) return combined def media_property(cls): def _media(self): # Get the media property of the superclass, if it exists Loading Loading @@ -131,6 +132,7 @@ def media_property(cls): return base return property(_media) class MediaDefiningClass(type): """ Metaclass for classes that can have media definitions. Loading Loading @@ -162,6 +164,7 @@ class SubWidget(object): args.append(self.choices) return self.parent_widget.render(*args) class Widget(six.with_metaclass(MediaDefiningClass)): is_hidden = False # Determines whether this corresponds to an <input type="hidden">. needs_multipart_form = False # Determines does this widget need multipart form Loading Loading @@ -224,6 +227,7 @@ class Widget(six.with_metaclass(MediaDefiningClass)): """ return id_ class Input(Widget): """ Base class for all <input> widgets (except type='checkbox' and Loading Loading @@ -279,10 +283,12 @@ class PasswordInput(TextInput): value = None return super(PasswordInput, self).render(name, value, attrs) class HiddenInput(Input): input_type = 'hidden' is_hidden = True class MultipleHiddenInput(HiddenInput): """ A widget that handles <input type="hidden"> for fields that have a list Loading Loading @@ -313,6 +319,7 @@ class MultipleHiddenInput(HiddenInput): return data.getlist(name) return data.get(name, None) class FileInput(Input): input_type = 'file' needs_multipart_form = True Loading @@ -327,6 +334,7 @@ class FileInput(Input): FILE_INPUT_CONTRADICTION = object() class ClearableFileInput(FileInput): initial_text = ugettext_lazy('Currently') input_text = ugettext_lazy('Change') Loading Loading @@ -380,6 +388,7 @@ class ClearableFileInput(FileInput): upload = super(ClearableFileInput, self).value_from_datadict(data, files, name) if not self.is_required and CheckboxInput().value_from_datadict( data, files, self.clear_checkbox_name(name)): if upload: # If the user contradicts themselves (uploads a new file AND # checks the "clear" checkbox), we return a unique marker Loading @@ -389,6 +398,7 @@ class ClearableFileInput(FileInput): return False return upload class Textarea(Widget): def __init__(self, attrs=None): # The 'rows' and 'cols' attributes are required for HTML correctness. Loading Loading @@ -515,6 +525,7 @@ class Select(Widget): output.append(self.render_option(selected_choices, option_value, option_label)) return '\n'.join(output) class NullBooleanSelect(Select): """ A Select Widget intended to be used with NullBooleanField. Loading Loading @@ -849,6 +860,7 @@ class SplitDateTimeWidget(MultiWidget): return [value.date(), value.time().replace(microsecond=0)] return [None, None] class SplitHiddenDateTimeWidget(SplitDateTimeWidget): """ A Widget that splits datetime input into two <input type="hidden"> inputs. Loading
setup.cfg +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh [flake8] exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/* ignore=E124,E125,E127,E128,E226,E251,E302,E501,E261,W601 ignore=E124,E125,E127,E128,E226,E251,E501,E261,W601 [metadata] license-file = LICENSE Loading
tests/multiple_database/tests.py +21 −15 Original line number Diff line number Diff line Loading @@ -50,7 +50,8 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Pro Django" should exist on default database') self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.using('other').get, title="Pro Django" ) Loading @@ -61,7 +62,8 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Dive into Python" should exist on default database') self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.using('other').get, title="Dive into Python" ) Loading @@ -84,11 +86,13 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Pro Django" should exist on other database') self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.get, title="Pro Django" ) self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.using('default').get, title="Pro Django" ) Loading @@ -98,11 +102,13 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Dive into Python" should exist on other database') self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.get, title="Dive into Python" ) self.assertRaises(Book.DoesNotExist, self.assertRaises( Book.DoesNotExist, Book.objects.using('default').get, title="Dive into Python" ) Loading
tests/mutually_referential/models.py +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ class Parent(models.Model): # Use a simple string for forward declarations. bestchild = models.ForeignKey("Child", null=True, related_name="favoured_by") class Child(models.Model): name = models.CharField(max_length=100) Loading
tests/nested_foreign_keys/models.py +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ class Event(models.Model): class Screening(Event): movie = models.ForeignKey(Movie) class ScreeningNullFK(Event): movie = models.ForeignKey(Movie, null=True) Loading @@ -24,5 +25,6 @@ class ScreeningNullFK(Event): class Package(models.Model): screening = models.ForeignKey(Screening, null=True) class PackageNullFK(models.Model): screening = models.ForeignKey(ScreeningNullFK, null=True)