Fixed #15061 -- Removed a redundant method implementation in the class-based ModelFormMixin, and did some PEP8 cleanup. Thanks to rasca for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15341 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2011-01-27 03:14:20 +00:00
parent 1f5309a99e
commit 461f01b7a6
4 changed files with 10 additions and 10 deletions

View File

@ -8,6 +8,7 @@ from django.utils.decorators import classonlymethod
logger = getLogger('django.request')
class View(object):
"""
Intentionally simple parent class for all views. Only implements

View File

@ -212,8 +212,6 @@ class BaseDateListView(MultipleObjectMixin, DateMixin, View):
return date_list
def get_context_data(self, **kwargs):
"""
Get the context. Must return a Context (or subclass) instance.
@ -240,7 +238,7 @@ class BaseArchiveIndexView(BaseDateListView):
date_list = self.get_date_list(qs, 'year')
if date_list:
object_list = qs.order_by('-'+self.get_date_field())
object_list = qs.order_by('-' + self.get_date_field())
else:
object_list = qs.none()
@ -327,7 +325,6 @@ class BaseMonthArchiveView(YearMixin, MonthMixin, BaseDateListView):
})
class MonthArchiveView(MultipleObjectTemplateResponseMixin, BaseMonthArchiveView):
"""
List of objects published in a given year.
@ -416,7 +413,6 @@ class BaseDayArchiveView(YearMixin, MonthMixin, DayMixin, BaseDateListView):
})
class DayArchiveView(MultipleObjectTemplateResponseMixin, BaseDayArchiveView):
"""
List of objects published on a given day.
@ -477,7 +473,6 @@ class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailV
return super(BaseDetailView, self).get_object(queryset=qs)
class DateDetailView(SingleObjectTemplateResponseMixin, BaseDateDetailView):
"""
Detail view of a single object on a single date; this differs from the
@ -498,6 +493,7 @@ def _date_from_string(year, year_format, month, month_format, day='', day_format
except ValueError:
raise Http404(u"Invalid date string '%s' given format '%s'" % (datestr, format))
def _month_bounds(date):
"""
Helper: return the first and last days of the month for the given date.
@ -510,6 +506,7 @@ def _month_bounds(date):
return first_day, last_day
def _get_next_prev_month(generic_view, naive_result, is_previous, use_first_day):
"""
Helper: Get the next or the previous valid date. The idea is to allow
@ -582,6 +579,7 @@ def _get_next_prev_month(generic_view, naive_result, is_previous, use_first_day)
else:
return None
def _date_lookup_for_field(field, date):
"""
Get the lookup kwargs for looking up a date against a given Field. If the
@ -597,4 +595,3 @@ def _date_lookup_for_field(field, date):
return {'%s__range' % field.name: date_range}
else:
return {field.name: date}

View File

@ -102,9 +102,6 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
self.object = form.save()
return super(ModelFormMixin, self).form_valid(form)
def form_invalid(self, form):
return self.render_to_response(self.get_context_data(form=form))
def get_context_data(self, **kwargs):
context = kwargs
if self.object:
@ -169,6 +166,7 @@ class BaseCreateView(ModelFormMixin, ProcessFormView):
def put(self, *args, **kwargs):
return self.post(*args, **kwargs)
class CreateView(SingleObjectTemplateResponseMixin, BaseCreateView):
"""
View for creating an new object instance,
@ -227,6 +225,7 @@ class DeletionMixin(object):
raise ImproperlyConfigured(
"No URL to redirect to. Provide a success_url.")
class BaseDeleteView(DeletionMixin, BaseDetailView):
"""
Base view for deleting an object.
@ -234,6 +233,7 @@ class BaseDeleteView(DeletionMixin, BaseDetailView):
Using this base class requires subclassing to provide a response mixin.
"""
class DeleteView(SingleObjectTemplateResponseMixin, BaseDeleteView):
"""
View for deleting an object retrieved with `self.get_object()`,

View File

@ -119,6 +119,7 @@ class BaseListView(MultipleObjectMixin, View):
context = self.get_context_data(object_list=self.object_list)
return self.render_to_response(context)
class MultipleObjectTemplateResponseMixin(TemplateResponseMixin):
template_name_suffix = '_list'
@ -139,6 +140,7 @@ class MultipleObjectTemplateResponseMixin(TemplateResponseMixin):
return names
class ListView(MultipleObjectTemplateResponseMixin, BaseListView):
"""
Render some list of objects, set by `self.model` or `self.queryset`.