Ticket #15061: ticket15061.patch

File ticket15061.patch, 5.0 KB (added by rasca, 4 years ago)

remove duplicate code and pep8 whitelines fix

  • django/views/generic/base.py

    diff --git a/django/views/generic/base.py b/django/views/generic/base.py
    index 5e69a8d..7f60ff0 100644
    a b from django.utils.decorators import classonlymethod 
    88
    99logger = getLogger('django.request')
    1010
     11
    1112class View(object):
    1213    """
    1314    Intentionally simple parent class for all views. Only implements
  • django/views/generic/dates.py

    diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py
    index c9e486b..2dd8883 100644
    a b class BaseDateListView(MultipleObjectMixin, DateMixin, View): 
    212212
    213213        return date_list
    214214
    215 
    216 
    217215    def get_context_data(self, **kwargs):
    218216        """
    219217        Get the context. Must return a Context (or subclass) instance.
    class BaseArchiveIndexView(BaseDateListView): 
    240238        date_list = self.get_date_list(qs, 'year')
    241239
    242240        if date_list:
    243             object_list = qs.order_by('-'+self.get_date_field())
     241            object_list = qs.order_by('-' + self.get_date_field())
    244242        else:
    245243            object_list = qs.none()
    246244
    class BaseMonthArchiveView(YearMixin, MonthMixin, BaseDateListView): 
    327325        })
    328326
    329327
    330 
    331328class MonthArchiveView(MultipleObjectTemplateResponseMixin, BaseMonthArchiveView):
    332329    """
    333330    List of objects published in a given year.
    class BaseDayArchiveView(YearMixin, MonthMixin, DayMixin, BaseDateListView): 
    416413        })
    417414
    418415
    419 
    420416class DayArchiveView(MultipleObjectTemplateResponseMixin, BaseDayArchiveView):
    421417    """
    422418    List of objects published on a given day.
    class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailV 
    477473        return super(BaseDetailView, self).get_object(queryset=qs)
    478474
    479475
    480 
    481476class DateDetailView(SingleObjectTemplateResponseMixin, BaseDateDetailView):
    482477    """
    483478    Detail view of a single object on a single date; this differs from the
    def _date_from_string(year, year_format, month, month_format, day='', day_format 
    498493    except ValueError:
    499494        raise Http404(u"Invalid date string '%s' given format '%s'" % (datestr, format))
    500495
     496
    501497def _month_bounds(date):
    502498    """
    503499    Helper: return the first and last days of the month for the given date.
    def _month_bounds(date): 
    510506
    511507    return first_day, last_day
    512508
     509
    513510def _get_next_prev_month(generic_view, naive_result, is_previous, use_first_day):
    514511    """
    515512    Helper: Get the next or the previous valid date. The idea is to allow
    def _get_next_prev_month(generic_view, naive_result, is_previous, use_first_day) 
    582579    else:
    583580        return None
    584581
     582
    585583def _date_lookup_for_field(field, date):
    586584    """
    587585    Get the lookup kwargs for looking up a date against a given Field. If the
    def _date_lookup_for_field(field, date): 
    597595        return {'%s__range' % field.name: date_range}
    598596    else:
    599597        return {field.name: date}
    600 
  • django/views/generic/edit.py

    diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
    index 931a2d3..33a3127 100644
    a b class ModelFormMixin(FormMixin, SingleObjectMixin): 
    102102        self.object = form.save()
    103103        return super(ModelFormMixin, self).form_valid(form)
    104104
    105     def form_invalid(self, form):
    106         return self.render_to_response(self.get_context_data(form=form))
    107 
    108105    def get_context_data(self, **kwargs):
    109106        context = kwargs
    110107        if self.object:
    class BaseCreateView(ModelFormMixin, ProcessFormView): 
    169166    def put(self, *args, **kwargs):
    170167        return self.post(*args, **kwargs)
    171168
     169
    172170class CreateView(SingleObjectTemplateResponseMixin, BaseCreateView):
    173171    """
    174172    View for creating an new object instance,
    class DeletionMixin(object): 
    227225            raise ImproperlyConfigured(
    228226                "No URL to redirect to. Provide a success_url.")
    229227
     228
    230229class BaseDeleteView(DeletionMixin, BaseDetailView):
    231230    """
    232231    Base view for deleting an object.
    class BaseDeleteView(DeletionMixin, BaseDetailView): 
    234233    Using this base class requires subclassing to provide a response mixin.
    235234    """
    236235
     236
    237237class DeleteView(SingleObjectTemplateResponseMixin, BaseDeleteView):
    238238    """
    239239    View for deleting an object retrieved with `self.get_object()`,
  • django/views/generic/list.py

    diff --git a/django/views/generic/list.py b/django/views/generic/list.py
    index 7b817a5..9f1c8aa 100644
    a b class BaseListView(MultipleObjectMixin, View): 
    119119        context = self.get_context_data(object_list=self.object_list)
    120120        return self.render_to_response(context)
    121121
     122
    122123class MultipleObjectTemplateResponseMixin(TemplateResponseMixin):
    123124    template_name_suffix = '_list'
    124125
    class MultipleObjectTemplateResponseMixin(TemplateResponseMixin): 
    139140
    140141        return names
    141142
     143
    142144class ListView(MultipleObjectTemplateResponseMixin, BaseListView):
    143145    """
    144146    Render some list of objects, set by `self.model` or `self.queryset`.
Back to Top