From fe407193c200e03070928c1e2c1a6e067d32893d Mon Sep 17 00:00:00 2001 From: coderick14 Date: Wed, 17 May 2017 15:40:18 +0530 Subject: Upgrade to Django 1.11 - Database integration yet to be tested --- .../site-packages/django/forms/__init__.py | 11 - .../site-packages/django/forms/extras/__init__.py | 3 - .../site-packages/django/forms/extras/widgets.py | 138 --- lib/python2.7/site-packages/django/forms/fields.py | 1146 ------------------ lib/python2.7/site-packages/django/forms/forms.py | 584 ---------- .../site-packages/django/forms/formsets.py | 417 ------- lib/python2.7/site-packages/django/forms/models.py | 1231 -------------------- lib/python2.7/site-packages/django/forms/util.py | 103 -- .../site-packages/django/forms/widgets.py | 869 -------------- 9 files changed, 4502 deletions(-) delete mode 100644 lib/python2.7/site-packages/django/forms/__init__.py delete mode 100644 lib/python2.7/site-packages/django/forms/extras/__init__.py delete mode 100644 lib/python2.7/site-packages/django/forms/extras/widgets.py delete mode 100644 lib/python2.7/site-packages/django/forms/fields.py delete mode 100644 lib/python2.7/site-packages/django/forms/forms.py delete mode 100644 lib/python2.7/site-packages/django/forms/formsets.py delete mode 100644 lib/python2.7/site-packages/django/forms/models.py delete mode 100644 lib/python2.7/site-packages/django/forms/util.py delete mode 100644 lib/python2.7/site-packages/django/forms/widgets.py (limited to 'lib/python2.7/site-packages/django/forms') diff --git a/lib/python2.7/site-packages/django/forms/__init__.py b/lib/python2.7/site-packages/django/forms/__init__.py deleted file mode 100644 index 2588098..0000000 --- a/lib/python2.7/site-packages/django/forms/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -""" -Django validation and HTML form handling. -""" - -from __future__ import absolute_import - -from django.core.exceptions import ValidationError -from django.forms.fields import * -from django.forms.forms import * -from django.forms.models import * -from django.forms.widgets import * diff --git a/lib/python2.7/site-packages/django/forms/extras/__init__.py b/lib/python2.7/site-packages/django/forms/extras/__init__.py deleted file mode 100644 index d801e4f..0000000 --- a/lib/python2.7/site-packages/django/forms/extras/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from __future__ import absolute_import - -from django.forms.extras.widgets import * diff --git a/lib/python2.7/site-packages/django/forms/extras/widgets.py b/lib/python2.7/site-packages/django/forms/extras/widgets.py deleted file mode 100644 index 0b96dc4..0000000 --- a/lib/python2.7/site-packages/django/forms/extras/widgets.py +++ /dev/null @@ -1,138 +0,0 @@ -""" -Extra HTML Widget classes -""" -from __future__ import unicode_literals - -import datetime -import re - -from django.forms.widgets import Widget, Select -from django.utils import datetime_safe -from django.utils.dates import MONTHS -from django.utils.encoding import force_str -from django.utils.safestring import mark_safe -from django.utils.formats import get_format -from django.utils import six -from django.conf import settings - -__all__ = ('SelectDateWidget',) - -RE_DATE = re.compile(r'(\d{4})-(\d\d?)-(\d\d?)$') - -def _parse_date_fmt(): - fmt = get_format('DATE_FORMAT') - escaped = False - output = [] - for char in fmt: - if escaped: - escaped = False - elif char == '\\': - escaped = True - elif char in 'Yy': - output.append('year') - #if not self.first_select: self.first_select = 'year' - elif char in 'bEFMmNn': - output.append('month') - #if not self.first_select: self.first_select = 'month' - elif char in 'dj': - output.append('day') - #if not self.first_select: self.first_select = 'day' - return output - -class SelectDateWidget(Widget): - """ - A Widget that splits date input into three . - """ - return self.as_widget(TextInput(), attrs, **kwargs) - - def as_textarea(self, attrs=None, **kwargs): - "Returns a string of HTML for representing this as a ', - flatatt(final_attrs), - force_text(value)) - - -class DateInput(TextInput): - def __init__(self, attrs=None, format=None): - super(DateInput, self).__init__(attrs) - if format: - self.format = format - self.manual_format = True - else: - self.format = formats.get_format('DATE_INPUT_FORMATS')[0] - self.manual_format = False - - def _format_value(self, value): - if self.is_localized and not self.manual_format: - return formats.localize_input(value) - elif hasattr(value, 'strftime'): - value = datetime_safe.new_date(value) - return value.strftime(self.format) - return value - - -class DateTimeInput(TextInput): - def __init__(self, attrs=None, format=None): - super(DateTimeInput, self).__init__(attrs) - if format: - self.format = format - self.manual_format = True - else: - self.format = formats.get_format('DATETIME_INPUT_FORMATS')[0] - self.manual_format = False - - def _format_value(self, value): - if self.is_localized and not self.manual_format: - return formats.localize_input(value) - elif hasattr(value, 'strftime'): - value = datetime_safe.new_datetime(value) - return value.strftime(self.format) - return value - - -class TimeInput(TextInput): - def __init__(self, attrs=None, format=None): - super(TimeInput, self).__init__(attrs) - if format: - self.format = format - self.manual_format = True - else: - self.format = formats.get_format('TIME_INPUT_FORMATS')[0] - self.manual_format = False - - def _format_value(self, value): - if self.is_localized and not self.manual_format: - return formats.localize_input(value) - elif hasattr(value, 'strftime'): - return value.strftime(self.format) - return value - - -# Defined at module level so that CheckboxInput is picklable (#17976) -def boolean_check(v): - return not (v is False or v is None or v == '') - - -class CheckboxInput(Widget): - def __init__(self, attrs=None, check_test=None): - super(CheckboxInput, self).__init__(attrs) - # check_test is a callable that takes a value and returns True - # if the checkbox should be checked for that value. - self.check_test = boolean_check if check_test is None else check_test - - def render(self, name, value, attrs=None): - final_attrs = self.build_attrs(attrs, type='checkbox', name=name) - if self.check_test(value): - final_attrs['checked'] = 'checked' - if not (value is True or value is False or value is None or value == ''): - # Only add the 'value' attribute if a value is non-empty. - final_attrs['value'] = force_text(value) - return format_html('', flatatt(final_attrs)) - - def value_from_datadict(self, data, files, name): - if name not in data: - # A missing value means False because HTML form submission does not - # send results for unselected checkboxes. - return False - value = data.get(name) - # Translate true and false strings to boolean values. - values = {'true': True, 'false': False} - if isinstance(value, six.string_types): - value = values.get(value.lower(), value) - return bool(value) - - -class Select(Widget): - allow_multiple_selected = False - - def __init__(self, attrs=None, choices=()): - super(Select, self).__init__(attrs) - # choices can be any iterable, but we may need to render this widget - # multiple times. Thus, collapse it into a list so it can be consumed - # more than once. - self.choices = list(choices) - - def render(self, name, value, attrs=None, choices=()): - if value is None: value = '' - final_attrs = self.build_attrs(attrs, name=name) - output = [format_html('', flatatt(final_attrs))] - options = self.render_options(choices, [value]) - if options: - output.append(options) - output.append('') - return mark_safe('\n'.join(output)) - - def render_option(self, selected_choices, option_value, option_label): - option_value = force_text(option_value) - if option_value in selected_choices: - selected_html = mark_safe(' selected="selected"') - if not self.allow_multiple_selected: - # Only allow for a single selection. - selected_choices.remove(option_value) - else: - selected_html = '' - return format_html('', - option_value, - selected_html, - force_text(option_label)) - - def render_options(self, choices, selected_choices): - # Normalize to strings. - selected_choices = set(force_text(v) for v in selected_choices) - output = [] - for option_value, option_label in chain(self.choices, choices): - if isinstance(option_label, (list, tuple)): - output.append(format_html('', force_text(option_value))) - for option in option_label: - output.append(self.render_option(selected_choices, *option)) - output.append('') - else: - 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. - """ - def __init__(self, attrs=None): - choices = (('1', ugettext_lazy('Unknown')), - ('2', ugettext_lazy('Yes')), - ('3', ugettext_lazy('No'))) - super(NullBooleanSelect, self).__init__(attrs, choices) - - def render(self, name, value, attrs=None, choices=()): - try: - value = {True: '2', False: '3', '2': '2', '3': '3'}[value] - except KeyError: - value = '1' - return super(NullBooleanSelect, self).render(name, value, attrs, choices) - - def value_from_datadict(self, data, files, name): - value = data.get(name, None) - return {'2': True, - True: True, - 'True': True, - '3': False, - 'False': False, - False: False}.get(value, None) - - -class SelectMultiple(Select): - allow_multiple_selected = True - - def render(self, name, value, attrs=None, choices=()): - if value is None: value = [] - final_attrs = self.build_attrs(attrs, name=name) - output = [format_html('') - return mark_safe('\n'.join(output)) - - def value_from_datadict(self, data, files, name): - if isinstance(data, (MultiValueDict, MergeDict)): - return data.getlist(name) - return data.get(name, None) - - -@python_2_unicode_compatible -class ChoiceInput(SubWidget): - """ - An object used by ChoiceFieldRenderer that represents a single - . - """ - input_type = None # Subclasses must define this - - def __init__(self, name, value, attrs, choice, index): - self.name = name - self.value = value - self.attrs = attrs - self.choice_value = force_text(choice[0]) - self.choice_label = force_text(choice[1]) - self.index = index - - def __str__(self): - return self.render() - - def render(self, name=None, value=None, attrs=None, choices=()): - name = name or self.name - value = value or self.value - attrs = attrs or self.attrs - if 'id' in self.attrs: - label_for = format_html(' for="{0}_{1}"', self.attrs['id'], self.index) - else: - label_for = '' - return format_html('{1} {2}', label_for, self.tag(), self.choice_label) - - def is_checked(self): - return self.value == self.choice_value - - def tag(self): - if 'id' in self.attrs: - self.attrs['id'] = '%s_%s' % (self.attrs['id'], self.index) - final_attrs = dict(self.attrs, type=self.input_type, name=self.name, value=self.choice_value) - if self.is_checked(): - final_attrs['checked'] = 'checked' - return format_html('', flatatt(final_attrs)) - - -class RadioChoiceInput(ChoiceInput): - input_type = 'radio' - - def __init__(self, *args, **kwargs): - super(RadioChoiceInput, self).__init__(*args, **kwargs) - self.value = force_text(self.value) - - -class RadioInput(RadioChoiceInput): - def __init__(self, *args, **kwargs): - msg = "RadioInput has been deprecated. Use RadioChoiceInput instead." - warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) - super(RadioInput, self).__init__(*args, **kwargs) - - -class CheckboxChoiceInput(ChoiceInput): - input_type = 'checkbox' - - def __init__(self, *args, **kwargs): - super(CheckboxChoiceInput, self).__init__(*args, **kwargs) - self.value = set(force_text(v) for v in self.value) - - def is_checked(self): - return self.choice_value in self.value - - -@python_2_unicode_compatible -class ChoiceFieldRenderer(object): - """ - An object used by RadioSelect to enable customization of radio widgets. - """ - - choice_input_class = None - - def __init__(self, name, value, attrs, choices): - self.name = name - self.value = value - self.attrs = attrs - self.choices = choices - - def __iter__(self): - for i, choice in enumerate(self.choices): - yield self.choice_input_class(self.name, self.value, self.attrs.copy(), choice, i) - - def __getitem__(self, idx): - choice = self.choices[idx] # Let the IndexError propogate - return self.choice_input_class(self.name, self.value, self.attrs.copy(), choice, idx) - - def __str__(self): - return self.render() - - def render(self): - """ - Outputs a
    for this set of choice fields. - If an id was given to the field, it is applied to the
      (each - item in the list will get an id of `$id_$i`). - """ - id_ = self.attrs.get('id', None) - start_tag = format_html('
        ', id_) if id_ else '
          ' - output = [start_tag] - for widget in self: - output.append(format_html('
        • {0}
        • ', force_text(widget))) - output.append('
        ') - return mark_safe('\n'.join(output)) - - -class RadioFieldRenderer(ChoiceFieldRenderer): - choice_input_class = RadioChoiceInput - - -class CheckboxFieldRenderer(ChoiceFieldRenderer): - choice_input_class = CheckboxChoiceInput - - -class RendererMixin(object): - renderer = None # subclasses must define this - _empty_value = None - - def __init__(self, *args, **kwargs): - # Override the default renderer if we were passed one. - renderer = kwargs.pop('renderer', None) - if renderer: - self.renderer = renderer - super(RendererMixin, self).__init__(*args, **kwargs) - - def subwidgets(self, name, value, attrs=None, choices=()): - for widget in self.get_renderer(name, value, attrs, choices): - yield widget - - def get_renderer(self, name, value, attrs=None, choices=()): - """Returns an instance of the renderer.""" - if value is None: - value = self._empty_value - final_attrs = self.build_attrs(attrs) - choices = list(chain(self.choices, choices)) - return self.renderer(name, value, final_attrs, choices) - - def render(self, name, value, attrs=None, choices=()): - return self.get_renderer(name, value, attrs, choices).render() - - def id_for_label(self, id_): - # Widgets using this RendererMixin are made of a collection of - # subwidgets, each with their own