Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Started attackign the next flake8 violation

  • Loading branch information...
commit 726ded5708e4e8767e69a6f6f6a039e75667ce03 1 parent a023a84
@alex alex authored
Showing with 128 additions and 4 deletions.
  1. +1 −0  django/__init__.py
  2. +1 −0  django/bin/profiling/gather_profile_stats.py
  3. +1 −0  django/bin/unique-messages.py
  4. +3 −0  django/conf/urls/__init__.py
  5. +1 −0  django/conf/urls/i18n.py
  6. +2 −0  django/conf/urls/static.py
  7. +1 −0  django/contrib/admin/actions.py
  8. +1 −0  django/contrib/admin/bin/compress.py
  9. +1 −0  django/contrib/admin/filters.py
  10. +12 −0 django/contrib/admin/helpers.py
  11. +13 −0 django/contrib/admin/templatetags/admin_list.py
  12. +3 −0  django/contrib/admin/templatetags/admin_modify.py
  13. +2 −0  django/contrib/admin/templatetags/log.py
  14. +3 −0  django/contrib/admin/utils.py
  15. +4 −0 django/contrib/admin/validation.py
  16. +15 −2 django/contrib/admin/widgets.py
  17. +1 −0  django/contrib/admindocs/middleware.py
  18. +1 −0  django/contrib/admindocs/tests/test_fields.py
  19. +5 −0 django/contrib/admindocs/utils.py
  20. +16 −0 django/contrib/admindocs/views.py
  21. +1 −0  django/contrib/auth/context_processors.py
  22. +1 −0  django/contrib/auth/handlers/modwsgi.py
  23. +1 −0  django/contrib/auth/tests/test_views.py
  24. +10 −0 django/contrib/auth/tests/urls.py
  25. +1 −0  django/contrib/auth/views.py
  26. +7 −1 django/contrib/contenttypes/generic.py
  27. +1 −0  django/contrib/contenttypes/models.py
  28. +4 −1 django/contrib/contenttypes/tests.py
  29. +1 −0  django/contrib/contenttypes/views.py
  30. +1 −0  django/contrib/flatpages/admin.py
  31. +1 −0  django/contrib/flatpages/forms.py
  32. +1 −0  django/contrib/flatpages/middleware.py
  33. +1 −0  django/contrib/flatpages/models.py
  34. +1 −0  django/contrib/flatpages/tests/test_forms.py
  35. +3 −0  django/contrib/flatpages/views.py
  36. +1 −0  django/contrib/formtools/preview.py
  37. +3 −0  django/contrib/formtools/tests/forms.py
  38. +2 −0  django/contrib/formtools/tests/tests.py
View
1  django/__init__.py
@@ -1,5 +1,6 @@
VERSION = (1, 7, 0, 'alpha', 0)
+
def get_version(*args, **kwargs):
# Don't litter django/__init__.py with all the get_version stuff.
# Only import if it's actually called.
View
1  django/bin/profiling/gather_profile_stats.py
@@ -12,6 +12,7 @@
import pstats
import sys
+
def gather_stats(p):
profiles = {}
for f in os.listdir(p):
View
1  django/bin/unique-messages.py
@@ -3,6 +3,7 @@
import os
import sys
+
def unique_messages():
basedir = None
View
3  django/conf/urls/__init__.py
@@ -13,6 +13,7 @@
handler404 = 'django.views.defaults.page_not_found'
handler500 = 'django.views.defaults.server_error'
+
def include(arg, namespace=None, app_name=None):
if isinstance(arg, tuple):
# callable returning a namespace hint
@@ -39,6 +40,7 @@ def include(arg, namespace=None, app_name=None):
return (urlconf_module, app_name, namespace)
+
def patterns(prefix, *args):
pattern_list = []
for t in args:
@@ -49,6 +51,7 @@ def patterns(prefix, *args):
pattern_list.append(t)
return pattern_list
+
def url(regex, view, kwargs=None, name=None, prefix=''):
if isinstance(view, (list, tuple)):
# For include(...) processing.
View
1  django/conf/urls/i18n.py
@@ -2,6 +2,7 @@
from django.conf.urls import patterns, url
from django.core.urlresolvers import LocaleRegexURLResolver
+
def i18n_patterns(prefix, *args):
"""
Adds the language code prefix to every URL pattern within this
View
2  django/conf/urls/static.py
@@ -1,8 +1,10 @@
import re
+
from django.conf import settings
from django.conf.urls import patterns, url
from django.core.exceptions import ImproperlyConfigured
+
def static(prefix, view='django.views.static.serve', **kwargs):
"""
Helper function to return a URL pattern for serving files in debug mode.
View
1  django/contrib/admin/actions.py
@@ -11,6 +11,7 @@
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy, ugettext as _
+
def delete_selected(modeladmin, request, queryset):
"""
Default action which deletes the selected objects.
View
1  django/contrib/admin/bin/compress.py
@@ -6,6 +6,7 @@
js_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static', 'admin', 'js')
+
def main():
usage = "usage: %prog [file1..fileN]"
description = """With no file paths given this script will automatically
View
1  django/contrib/admin/filters.py
@@ -16,6 +16,7 @@
reverse_field_path, get_limit_choices_to_from_path, prepare_lookup_value)
from django.contrib.admin.options import IncorrectLookupParameters
+
class ListFilter(object):
title = None # Human-readable title to appear in the right sidebar.
template = 'admin/filter.html'
View
12 django/contrib/admin/helpers.py
@@ -19,6 +19,7 @@
ACTION_CHECKBOX_NAME = '_selected_action'
+
class ActionForm(forms.Form):
action = forms.ChoiceField(label=_('Action:'))
select_across = forms.BooleanField(label='', required=False, initial=0,
@@ -26,6 +27,7 @@ class ActionForm(forms.Form):
checkbox = forms.CheckboxInput({'class': 'action-select'}, lambda value: False)
+
class AdminForm(object):
def __init__(self, form, fieldsets, prepopulated_fields, readonly_fields=None, model_admin=None):
self.form, self.fieldsets = form, normalize_fieldsets(fieldsets)
@@ -53,6 +55,7 @@ def _media(self):
return media
media = property(_media)
+
class Fieldset(object):
def __init__(self, form, name=None, readonly_fields=(), fields=(), classes=(),
description=None, model_admin=None):
@@ -77,6 +80,7 @@ def __iter__(self):
for field in self.fields:
yield Fieldline(self.form, field, self.readonly_fields, model_admin=self.model_admin)
+
class Fieldline(object):
def __init__(self, form, field, readonly_fields=None, model_admin=None):
self.form = form # A django.forms.Form instance
@@ -103,6 +107,7 @@ def __iter__(self):
def errors(self):
return mark_safe('\n'.join(self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields).strip('\n'))
+
class AdminField(object):
def __init__(self, form, field, is_first):
self.field = form[field] # A django.forms.BoundField instance
@@ -128,6 +133,7 @@ def label_tag(self):
def errors(self):
return mark_safe(self.field.errors.as_ul())
+
class AdminReadonlyField(object):
def __init__(self, form, field, is_first, model_admin=None):
label = label_for_field(field, form._meta.model, model_admin)
@@ -183,6 +189,7 @@ def contents(self):
result_repr = display_for_field(value, f)
return conditional_escape(result_repr)
+
class InlineAdminFormSet(object):
"""
A wrapper around an inline formset for use in the admin system.
@@ -238,6 +245,7 @@ def _media(self):
return media
media = property(_media)
+
class InlineAdminForm(AdminForm):
"""
A wrapper around an inline form for use in the admin system.
@@ -300,6 +308,7 @@ def ordering_field(self):
from django.forms.formsets import ORDERING_FIELD_NAME
return AdminField(self.form, ORDERING_FIELD_NAME, False)
+
class InlineFieldset(Fieldset):
def __init__(self, formset, *args, **kwargs):
self.formset = formset
@@ -313,6 +322,7 @@ def __iter__(self):
yield Fieldline(self.form, field, self.readonly_fields,
model_admin=self.model_admin)
+
class AdminErrorList(forms.utils.ErrorList):
"""
Stores all errors for the form/formsets in an add/change stage view.
@@ -325,6 +335,7 @@ def __init__(self, form, inline_formsets):
for errors_in_inline_form in inline_formset.errors:
self.extend(list(six.itervalues(errors_in_inline_form)))
+
def normalize_fieldsets(fieldsets):
"""
Make sure the keys in fieldset dictionaries are strings. Returns the
@@ -335,6 +346,7 @@ def normalize_fieldsets(fieldsets):
result.append((name, normalize_dictionary(options)))
return result
+
def normalize_dictionary(data_dict):
"""
Converts all the keys in "data_dict" to strings. The keys must be
View
13 django/contrib/admin/templatetags/admin_list.py
@@ -25,6 +25,7 @@
DOT = '.'
+
@register.simple_tag
def paginator_number(cl, i):
"""
@@ -40,6 +41,7 @@ def paginator_number(cl, i):
mark_safe(' class="end"' if i == cl.paginator.num_pages-1 else ''),
i+1)
+
@register.inclusion_tag('admin/pagination.html')
def pagination(cl):
"""
@@ -86,6 +88,7 @@ def pagination(cl):
'1': 1,
}
+
def result_headers(cl):
"""
Generates the list column headers.
@@ -167,11 +170,13 @@ def result_headers(cl):
"class_attrib": format_html(' class="{0}"', ' '.join(th_classes)) if th_classes else '',
}
+
def _boolean_icon(field_val):
icon_url = static('admin/img/icon-%s.gif' %
{True: 'yes', False: 'no', None: 'unknown'}[field_val])
return format_html('<img src="{0}" alt="{1}" />', icon_url, field_val)
+
def items_for_result(cl, result, form):
"""
Generates the actual list of data.
@@ -266,6 +271,7 @@ def link_in_col(is_first, field_name, cl):
if form and not form[cl.model._meta.pk.name].is_hidden:
yield format_html('<td>{0}</td>', force_text(form[cl.model._meta.pk.name]))
+
class ResultList(list):
# Wrapper class used to return items in a list_editable
# changelist, annotated with the form object for error
@@ -275,6 +281,7 @@ def __init__(self, form, *items):
self.form = form
super(ResultList, self).__init__(*items)
+
def results(cl):
if cl.formset:
for res, form in zip(cl.result_list, cl.formset.forms):
@@ -283,12 +290,14 @@ def results(cl):
for res in cl.result_list:
yield ResultList(None, items_for_result(cl, res, None))
+
def result_hidden_fields(cl):
if cl.formset:
for res, form in zip(cl.result_list, cl.formset.forms):
if form[cl.model._meta.pk.name].is_hidden:
yield mark_safe(force_text(form[cl.model._meta.pk.name]))
+
@register.inclusion_tag("admin/change_list_results.html")
def result_list(cl):
"""
@@ -305,6 +314,7 @@ def result_list(cl):
'num_sorted_fields': num_sorted_fields,
'results': list(results(cl))}
+
@register.inclusion_tag('admin/date_hierarchy.html')
def date_hierarchy(cl):
"""
@@ -382,6 +392,7 @@ def date_hierarchy(cl):
} for year in years]
}
+
@register.inclusion_tag('admin/search_form.html')
def search_form(cl):
"""
@@ -393,6 +404,7 @@ def search_form(cl):
'search_var': SEARCH_VAR
}
+
@register.simple_tag
def admin_list_filter(cl, spec):
tpl = get_template(spec.template)
@@ -402,6 +414,7 @@ def admin_list_filter(cl, spec):
'spec': spec,
}))
+
@register.inclusion_tag('admin/actions.html', takes_context=True)
def admin_actions(context):
"""
View
3  django/contrib/admin/templatetags/admin_modify.py
@@ -2,6 +2,7 @@
register = template.Library()
+
@register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)
def prepopulated_fields_js(context):
"""
@@ -19,6 +20,7 @@ def prepopulated_fields_js(context):
context.update({'prepopulated_fields': prepopulated_fields})
return context
+
@register.inclusion_tag('admin/submit_line.html', takes_context=True)
def submit_row(context):
"""
@@ -43,6 +45,7 @@ def submit_row(context):
ctx['original'] = context['original']
return ctx
+
@register.filter
def cell_count(inline_admin_form):
"""Returns the number of cells used in a tabular inline"""
View
2  django/contrib/admin/templatetags/log.py
@@ -3,6 +3,7 @@
register = template.Library()
+
class AdminLogNode(template.Node):
def __init__(self, limit, varname, user):
self.limit, self.varname, self.user = limit, varname, user
@@ -20,6 +21,7 @@ def render(self, context):
context[self.varname] = LogEntry.objects.filter(user__pk__exact=user_id).select_related('content_type', 'user')[:int(self.limit)]
return ''
+
@register.tag
def get_admin_log(parser, token):
"""
View
3  django/contrib/admin/utils.py
@@ -18,6 +18,7 @@
from django.utils.translation import ungettext
from django.core.urlresolvers import reverse, NoReverseMatch
+
def lookup_needs_distinct(opts, lookup_path):
"""
Returns True if 'distinct()' should be used to query the given lookup path.
@@ -31,6 +32,7 @@ def lookup_needs_distinct(opts, lookup_path):
return True
return False
+
def prepare_lookup_value(key, value):
"""
Returns a lookup value prepared to be used in queryset filtering.
@@ -46,6 +48,7 @@ def prepare_lookup_value(key, value):
value = True
return value
+
def quote(s):
"""
Ensure that primary key values do not confuse the admin URLs by escaping
View
4 django/contrib/admin/validation.py
@@ -410,14 +410,17 @@ def check_type(cls, attr, type_):
raise ImproperlyConfigured("'%s.%s' should be a %s."
% (cls.__name__, attr, type_.__name__))
+
def check_isseq(cls, label, obj):
if not isinstance(obj, (list, tuple)):
raise ImproperlyConfigured("'%s.%s' must be a list or tuple." % (cls.__name__, label))
+
def check_isdict(cls, label, obj):
if not isinstance(obj, dict):
raise ImproperlyConfigured("'%s.%s' must be a dictionary." % (cls.__name__, label))
+
def get_field(cls, model, label, field):
try:
return model._meta.get_field(field)
@@ -425,6 +428,7 @@ def get_field(cls, model, label, field):
raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is missing from model '%s.%s'."
% (cls.__name__, label, field, model._meta.app_label, model.__name__))
+
def fetch_attr(cls, model, label, field):
try:
return model._meta.get_field(field)
View
17 django/contrib/admin/widgets.py
@@ -49,8 +49,8 @@ def render(self, name, value, attrs=None, choices=()):
% (name, self.verbose_name.replace('"', '\\"'), int(self.is_stacked), static('admin/')))
return mark_safe(''.join(output))
-class AdminDateWidget(forms.DateInput):
+class AdminDateWidget(forms.DateInput):
@property
def media(self):
js = ["calendar.js", "admin/DateTimeShortcuts.js"]
@@ -62,8 +62,8 @@ def __init__(self, attrs=None, format=None):
final_attrs.update(attrs)
super(AdminDateWidget, self).__init__(attrs=final_attrs, format=format)
-class AdminTimeWidget(forms.TimeInput):
+class AdminTimeWidget(forms.TimeInput):
@property
def media(self):
js = ["calendar.js", "admin/DateTimeShortcuts.js"]
@@ -75,6 +75,7 @@ def __init__(self, attrs=None, format=None):
final_attrs.update(attrs)
super(AdminTimeWidget, self).__init__(attrs=final_attrs, format=format)
+
class AdminSplitDateTime(forms.SplitDateTimeWidget):
"""
A SplitDateTime Widget that has some admin-specific styling.
@@ -90,6 +91,7 @@ def format_output(self, rendered_widgets):
_('Date:'), rendered_widgets[0],
_('Time:'), rendered_widgets[1])
+
class AdminRadioFieldRenderer(RadioFieldRenderer):
def render(self):
"""Outputs a <ul> for this set of radio fields."""
@@ -98,15 +100,18 @@ def render(self):
format_html_join('\n', '<li>{0}</li>',
((force_text(w),) for w in self)))
+
class AdminRadioSelect(forms.RadioSelect):
renderer = AdminRadioFieldRenderer
+
class AdminFileWidget(forms.ClearableFileInput):
template_with_initial = ('<p class="file-upload">%s</p>'
% forms.ClearableFileInput.template_with_initial)
template_with_clear = ('<span class="clearable-file-input">%s</span>'
% forms.ClearableFileInput.template_with_clear)
+
def url_params_from_lookup_dict(lookups):
"""
Converts the type of lookups specified in a ForeignKey limit_choices_to
@@ -129,6 +134,7 @@ def url_params_from_lookup_dict(lookups):
params.update(dict(items))
return params
+
class ForeignKeyRawIdWidget(forms.TextInput):
"""
A Widget for displaying ForeignKeys in the "raw_id" interface rather than
@@ -187,6 +193,7 @@ def label_for_value(self, value):
except (ValueError, self.rel.to.DoesNotExist):
return ''
+
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
"""
A Widget for displaying ManyToMany ids in the "raw_id" interface rather than
@@ -275,6 +282,7 @@ def value_from_datadict(self, data, files, name):
def id_for_label(self, id_):
return self.widget.id_for_label(id_)
+
class AdminTextareaWidget(forms.Textarea):
def __init__(self, attrs=None):
final_attrs = {'class': 'vLargeTextField'}
@@ -282,6 +290,7 @@ def __init__(self, attrs=None):
final_attrs.update(attrs)
super(AdminTextareaWidget, self).__init__(attrs=final_attrs)
+
class AdminTextInputWidget(forms.TextInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vTextField'}
@@ -289,6 +298,7 @@ def __init__(self, attrs=None):
final_attrs.update(attrs)
super(AdminTextInputWidget, self).__init__(attrs=final_attrs)
+
class AdminEmailInputWidget(forms.EmailInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vTextField'}
@@ -296,6 +306,7 @@ def __init__(self, attrs=None):
final_attrs.update(attrs)
super(AdminEmailInputWidget, self).__init__(attrs=final_attrs)
+
class AdminURLFieldWidget(forms.URLInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vURLField'}
@@ -325,9 +336,11 @@ def __init__(self, attrs=None):
final_attrs.update(attrs)
super(AdminIntegerFieldWidget, self).__init__(attrs=final_attrs)
+
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget):
class_name = 'vBigIntegerField'
+
class AdminCommaSeparatedIntegerFieldWidget(forms.TextInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vCommaSeparatedIntegerField'}
View
1  django/contrib/admindocs/middleware.py
@@ -1,6 +1,7 @@
from django.conf import settings
from django import http
+
class XViewMiddleware(object):
"""
Adds an X-View header to internal HEAD requests -- used by the documentation system.
View
1  django/contrib/admindocs/tests/test_fields.py
@@ -11,6 +11,7 @@
class CustomField(models.Field):
description = "A custom field type"
+
class DescriptionLackingField(models.Field):
pass
View
5 django/contrib/admindocs/utils.py
@@ -16,6 +16,7 @@
else:
docutils_is_available = True
+
def trim_docstring(docstring):
"""
Uniformly trims leading/trailing whitespace from docstrings.
@@ -30,6 +31,7 @@ def trim_docstring(docstring):
trimmed = [lines[0].lstrip()] + [line[indent:].rstrip() for line in lines[1:]]
return "\n".join(trimmed).strip()
+
def parse_docstring(docstring):
"""
Parse out the parts of a docstring. Returns (title, body, metadata).
@@ -55,6 +57,7 @@ def parse_docstring(docstring):
body = "\n\n".join(parts[1:])
return title, body, metadata
+
def parse_rst(text, default_reference_context, thing_being_parsed=None):
"""
Convert the string from reST to an XHTML fragment.
@@ -92,6 +95,7 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None):
'tag': '%s/tags/#%s',
}
+
def create_reference_role(rolename, urlbase):
def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
if options is None:
@@ -102,6 +106,7 @@ def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
return [node], []
docutils.parsers.rst.roles.register_canonical_role(rolename, _role)
+
def default_reference_role(name, rawtext, text, lineno, inliner, options=None, content=None):
if options is None:
options = {}
View
16 django/contrib/admindocs/views.py
@@ -21,10 +21,12 @@
# Exclude methods starting with these strings from documentation
MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_')
+
class GenericSite(object):
domain = 'example.com'
name = 'my site'
+
@staff_member_required
def doc_index(request):
if not utils.docutils_is_available:
@@ -33,6 +35,7 @@ def doc_index(request):
'root_path': urlresolvers.reverse('admin:index'),
}, context_instance=RequestContext(request))
+
@staff_member_required
def bookmarklets(request):
admin_root = urlresolvers.reverse('admin:index')
@@ -41,6 +44,7 @@ def bookmarklets(request):
'admin_url': "%s://%s%s" % (request.scheme, request.get_host(), admin_root),
}, context_instance=RequestContext(request))
+
@staff_member_required
def template_tag_index(request):
if not utils.docutils_is_available:
@@ -76,6 +80,7 @@ def template_tag_index(request):
'tags': tags
}, context_instance=RequestContext(request))
+
@staff_member_required
def template_filter_index(request):
if not utils.docutils_is_available:
@@ -111,6 +116,7 @@ def template_filter_index(request):
'filters': filters
}, context_instance=RequestContext(request))
+
@staff_member_required
def view_index(request):
if not utils.docutils_is_available:
@@ -141,6 +147,7 @@ def view_index(request):
'views': views
}, context_instance=RequestContext(request))
+
@staff_member_required
def view_detail(request, view):
if not utils.docutils_is_available:
@@ -166,6 +173,7 @@ def view_detail(request, view):
'meta': metadata,
}, context_instance=RequestContext(request))
+
@staff_member_required
def model_index(request):
if not utils.docutils_is_available:
@@ -176,6 +184,7 @@ def model_index(request):
'models': m_list
}, context_instance=RequestContext(request))
+
@staff_member_required
def model_detail(request, app_label, model_name):
if not utils.docutils_is_available:
@@ -278,6 +287,7 @@ def model_detail(request, app_label, model_name):
'fields': fields,
}, context_instance=RequestContext(request))
+
@staff_member_required
def template_detail(request, template):
templates = []
@@ -307,10 +317,12 @@ def template_detail(request, template):
# Helper functions #
####################
+
def missing_docutils_page(request):
"""Display an error message for people without docutils"""
return render_to_response('admin_doc/missing_docutils.html')
+
def load_all_installed_template_libraries():
# Load/register all template tag libraries from installed apps.
for module_name in template.get_templatetags_modules():
@@ -329,6 +341,7 @@ def load_all_installed_template_libraries():
except template.InvalidTemplateLibrary:
pass
+
def get_return_data_type(func_name):
"""Return a somewhat-helpful data type given a function name"""
if func_name.startswith('get_'):
@@ -338,6 +351,7 @@ def get_return_data_type(func_name):
return 'Integer'
return ''
+
def get_readable_field_data_type(field):
"""Returns the description for a given field type, if it exists,
Fields' descriptions can contain format strings, which will be interpolated
@@ -345,6 +359,7 @@ def get_readable_field_data_type(field):
return field.description % field.__dict__
+
def extract_views_from_urlpatterns(urlpatterns, base=''):
"""
Return a list of views from a list of urlpatterns.
@@ -371,6 +386,7 @@ def extract_views_from_urlpatterns(urlpatterns, base=''):
named_group_matcher = re.compile(r'\(\?P(<\w+>).+?\)')
non_named_group_matcher = re.compile(r'\(.*?\)')
+
def simplify_regex(pattern):
"""
Clean up urlpattern regexes into something somewhat readable by Mere Humans:
View
1  django/contrib/auth/context_processors.py
@@ -1,6 +1,7 @@
# PermWrapper and PermLookupDict proxy the permissions system into objects that
# the template system can understand.
+
class PermLookupDict(object):
def __init__(self, user, app_label):
self.user, self.app_label = user, app_label
View
1  django/contrib/auth/handlers/modwsgi.py
@@ -27,6 +27,7 @@ def check_password(environ, username, password):
finally:
db.close_old_connections()
+
def groups_for_user(environ, username):
"""
Authorizes a user based on groups
View
1  django/contrib/auth/tests/test_views.py
@@ -711,6 +711,7 @@ def test_security_check(self, password='password'):
"%s should be allowed" % good_url)
self.confirm_logged_out()
+
@skipIfCustomUser
@override_settings(
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
View
10 django/contrib/auth/tests/urls.py
@@ -10,11 +10,13 @@
from django.template import Template, RequestContext
from django.views.decorators.cache import never_cache
+
class CustomRequestAuthenticationForm(AuthenticationForm):
def __init__(self, request, *args, **kwargs):
assert isinstance(request, HttpRequest)
super(CustomRequestAuthenticationForm, self).__init__(request, *args, **kwargs)
+
@never_cache
def remote_user_auth_view(request):
"Dummy view for remote user tests"
@@ -22,6 +24,7 @@ def remote_user_auth_view(request):
c = RequestContext(request, {})
return HttpResponse(t.render(c))
+
def auth_processor_no_attr_access(request):
render_to_response('context_processors/auth_attrs_no_access.html',
RequestContext(request, {}, processors=[context_processors.auth]))
@@ -29,32 +32,39 @@ def auth_processor_no_attr_access(request):
return render_to_response('context_processors/auth_attrs_test_access.html',
{'session_accessed': request.session.accessed})
+
def auth_processor_attr_access(request):
render_to_response('context_processors/auth_attrs_access.html',
RequestContext(request, {}, processors=[context_processors.auth]))
return render_to_response('context_processors/auth_attrs_test_access.html',
{'session_accessed': request.session.accessed})
+
def auth_processor_user(request):
return render_to_response('context_processors/auth_attrs_user.html',
RequestContext(request, {}, processors=[context_processors.auth]))
+
def auth_processor_perms(request):
return render_to_response('context_processors/auth_attrs_perms.html',
RequestContext(request, {}, processors=[context_processors.auth]))
+
def auth_processor_perm_in_perms(request):
return render_to_response('context_processors/auth_attrs_perm_in_perms.html',
RequestContext(request, {}, processors=[context_processors.auth]))
+
def auth_processor_messages(request):
info(request, "Message 1")
return render_to_response('context_processors/auth_attrs_messages.html',
RequestContext(request, {}, processors=[context_processors.auth]))
+
def userpage(request):
pass
+
def custom_request_auth_login(request):
return login(request, authentication_form=CustomRequestAuthenticationForm)
View
1  django/contrib/auth/views.py
@@ -234,6 +234,7 @@ def password_reset_confirm(request, uidb64=None, token=None,
return TemplateResponse(request, template_name, context,
current_app=current_app)
+
def password_reset_complete(request,
template_name='registration/password_reset_complete.html',
current_app=None, extra_context=None):
View
8 django/contrib/contenttypes/generic.py
@@ -154,6 +154,7 @@ def __set__(self, instance, value):
setattr(instance, self.fk_field, fk)
setattr(instance, self.cache_attr, value)
+
class GenericRelation(ForeignObject):
"""Provides an accessor to generic related objects (e.g. comments)"""
@@ -293,6 +294,7 @@ def __set__(self, instance, value):
for obj in value:
manager.add(obj)
+
def create_generic_related_manager(superclass):
"""
Factory function for a manager that subclasses 'superclass' (which is a
@@ -390,11 +392,12 @@ def create(self, **kwargs):
return GenericRelatedObjectManager
-class GenericRel(ForeignObjectRel):
+class GenericRel(ForeignObjectRel):
def __init__(self, field, to, related_name=None, limit_choices_to=None):
super(GenericRel, self).__init__(field, to, related_name, limit_choices_to)
+
class BaseGenericInlineFormSet(BaseModelFormSet):
"""
A formset for generic inline objects to a parent.
@@ -475,6 +478,7 @@ def generic_inlineformset_factory(model, form=ModelForm,
FormSet.for_concrete_model = for_concrete_model
return FormSet
+
class GenericInlineModelAdmin(InlineModelAdmin):
ct_field = "content_type"
ct_fk_field = "object_id"
@@ -516,8 +520,10 @@ def get_formset(self, request, obj=None, **kwargs):
return generic_inlineformset_factory(self.model, **defaults)
+
class GenericStackedInline(GenericInlineModelAdmin):
template = 'admin/edit_inline/stacked.html'
+
class GenericTabularInline(GenericInlineModelAdmin):
template = 'admin/edit_inline/tabular.html'
View
1  django/contrib/contenttypes/models.py
@@ -3,6 +3,7 @@
from django.utils.encoding import smart_text, force_text
from django.utils.encoding import python_2_unicode_compatible
+
class ContentTypeManager(models.Manager):
# Cache to avoid re-looking up ContentType objects all over the place.
View
5 django/contrib/contenttypes/tests.py
@@ -15,10 +15,12 @@
class ConcreteModel(models.Model):
name = models.CharField(max_length=10)
+
class ProxyModel(ConcreteModel):
class Meta:
proxy = True
+
@python_2_unicode_compatible
class FooWithoutUrl(models.Model):
"""
@@ -39,6 +41,7 @@ class FooWithUrl(FooWithoutUrl):
def get_absolute_url(self):
return "/users/%s/" % urlquote(self.name)
+
class FooWithBrokenAbsoluteUrl(FooWithoutUrl):
"""
Fake model defining a ``get_absolute_url`` method containing an error
@@ -47,8 +50,8 @@ class FooWithBrokenAbsoluteUrl(FooWithoutUrl):
def get_absolute_url(self):
return "/users/%s/" % self.unknown_field
-class ContentTypesTests(TestCase):
+class ContentTypesTests(TestCase):
def setUp(self):
self.old_Site_meta_installed = Site._meta.installed
ContentType.objects.clear_cache()
View
1  django/contrib/contenttypes/views.py
@@ -6,6 +6,7 @@
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext as _
+
def shortcut(request, content_type_id, object_id):
"""
Redirect to an object's page based on a content-type ID and an object ID.
View
1  django/contrib/flatpages/admin.py
@@ -3,6 +3,7 @@
from django.utils.translation import ugettext_lazy as _
from django.contrib.flatpages.forms import FlatpageForm
+
class FlatPageAdmin(admin.ModelAdmin):
form = FlatpageForm
fieldsets = (
View
1  django/contrib/flatpages/forms.py
@@ -3,6 +3,7 @@
from django.contrib.flatpages.models import FlatPage
from django.utils.translation import ugettext, ugettext_lazy as _
+
class FlatpageForm(forms.ModelForm):
url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$',
help_text = _("Example: '/about/contact/'. Make sure to have leading"
View
1  django/contrib/flatpages/middleware.py
@@ -2,6 +2,7 @@
from django.http import Http404
from django.conf import settings
+
class FlatpageFallbackMiddleware(object):
def process_response(self, request, response):
if response.status_code != 404:
View
1  django/contrib/flatpages/models.py
@@ -6,6 +6,7 @@
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import iri_to_uri, python_2_unicode_compatible
+
@python_2_unicode_compatible
class FlatPage(models.Model):
url = models.CharField(_('URL'), max_length=100, db_index=True)
View
1  django/contrib/flatpages/tests/test_forms.py
@@ -7,6 +7,7 @@
from django.test.utils import override_settings
from django.utils import translation
+
@override_settings(SITE_ID=1)
class FlatpageAdminFormTests(TestCase):
fixtures = ['example_site']
View
3  django/contrib/flatpages/views.py
@@ -17,6 +17,8 @@
# or a redirect is required for authentication, the 404 needs to be returned
# without any CSRF checks. Therefore, we only
# CSRF protect the internal implementation.
+
+
def flatpage(request, url):
"""
Public interface to the flat page view.
@@ -44,6 +46,7 @@ def flatpage(request, url):
raise
return render_flatpage(request, f)
+
@csrf_protect
def render_flatpage(request, f):
"""
View
1  django/contrib/formtools/preview.py
@@ -10,6 +10,7 @@
AUTO_ID = 'formtools_%s' # Each form here uses this as its auto_id parameter.
+
class FormPreview(object):
preview_template = 'formtools/preview.html'
form_template = 'formtools/form.html'
View
3  django/contrib/formtools/tests/forms.py
@@ -1,15 +1,18 @@
from django import forms
+
class TestForm(forms.Form):
field1 = forms.CharField()
field1_ = forms.CharField()
bool1 = forms.BooleanField(required=False)
date1 = forms.DateField(required=False)
+
class HashTestForm(forms.Form):
name = forms.CharField()
bio = forms.CharField()
+
class HashTestBlankForm(forms.Form):
name = forms.CharField(required=False)
bio = forms.CharField(required=False)
View
2  django/contrib/formtools/tests/tests.py
@@ -19,6 +19,7 @@
success_string = "Done was called!"
success_string_encoded = success_string.encode()
+
class TestFormPreview(preview.FormPreview):
def get_context(self, request, form):
context = super(TestFormPreview, self).get_context(request, form)
@@ -31,6 +32,7 @@ def get_initial(self, request):
def done(self, request, cleaned_data):
return http.HttpResponse(success_string)
+
@override_settings(
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(upath(__file__)), 'templates'),
Please sign in to comment.
Something went wrong with that request. Please try again.