From 5411821e3b8d1427ee63a5914aed1088c04cc1ed Mon Sep 17 00:00:00 2001 From: Anton Samarchyan Date: Tue, 24 Jan 2017 15:31:57 -0500 Subject: [PATCH] Refs #27656 -- Updated django.contrib docstring verb style according to PEP 257. --- django/contrib/admin/decorators.py | 2 +- django/contrib/admin/filters.py | 14 +- django/contrib/admin/helpers.py | 4 +- django/contrib/admin/models.py | 4 +- django/contrib/admin/options.py | 54 ++++--- django/contrib/admin/sites.py | 42 +++--- .../contrib/admin/templatetags/admin_list.py | 23 +-- .../admin/templatetags/admin_modify.py | 6 +- django/contrib/admin/templatetags/log.py | 2 +- django/contrib/admin/tests.py | 29 ++-- django/contrib/admin/utils.py | 23 +-- django/contrib/admin/views/main.py | 13 +- django/contrib/admin/widgets.py | 2 +- django/contrib/admindocs/middleware.py | 8 +- django/contrib/admindocs/views.py | 9 +- django/contrib/auth/__init__.py | 22 +-- django/contrib/auth/admin.py | 2 +- django/contrib/auth/backends.py | 26 ++-- django/contrib/auth/context_processors.py | 4 +- django/contrib/auth/forms.py | 10 +- django/contrib/auth/handlers/modwsgi.py | 8 +- django/contrib/auth/hashers.py | 41 +++-- django/contrib/auth/management/__init__.py | 4 +- django/contrib/auth/middleware.py | 4 +- django/contrib/auth/mixins.py | 13 +- django/contrib/auth/models.py | 40 +++-- django/contrib/auth/tokens.py | 2 +- django/contrib/auth/views.py | 15 +- django/contrib/contenttypes/forms.py | 2 +- .../contenttypes/management/__init__.py | 2 +- django/contrib/contenttypes/models.py | 12 +- .../flatpages/templatetags/flatpages.py | 15 +- django/contrib/gis/admin/options.py | 2 +- django/contrib/gis/admin/widgets.py | 5 +- .../contrib/gis/db/backends/base/adapter.py | 3 +- django/contrib/gis/db/backends/base/models.py | 22 +-- .../gis/db/backends/base/operations.py | 11 +- .../contrib/gis/db/backends/oracle/adapter.py | 14 +- .../contrib/gis/db/backends/oracle/models.py | 4 +- .../gis/db/backends/oracle/operations.py | 8 +- .../gis/db/backends/postgis/adapter.py | 2 +- .../gis/db/backends/postgis/introspection.py | 4 +- .../contrib/gis/db/backends/postgis/models.py | 4 +- .../gis/db/backends/postgis/operations.py | 16 +- .../gis/db/backends/spatialite/adapter.py | 2 +- .../gis/db/backends/spatialite/models.py | 4 +- .../gis/db/backends/spatialite/operations.py | 16 +- django/contrib/gis/db/models/fields.py | 17 +-- django/contrib/gis/db/models/lookups.py | 6 +- django/contrib/gis/db/models/proxy.py | 18 +-- django/contrib/gis/feeds.py | 4 +- django/contrib/gis/forms/fields.py | 10 +- django/contrib/gis/forms/widgets.py | 2 +- django/contrib/gis/gdal/datasource.py | 8 +- django/contrib/gis/gdal/driver.py | 10 +- django/contrib/gis/gdal/envelope.py | 26 ++-- django/contrib/gis/gdal/error.py | 2 +- django/contrib/gis/gdal/feature.py | 26 ++-- django/contrib/gis/gdal/field.py | 35 +++-- django/contrib/gis/gdal/geometries.py | 140 +++++++++--------- django/contrib/gis/gdal/geomtype.py | 12 +- django/contrib/gis/gdal/layer.py | 37 +++-- django/contrib/gis/gdal/libgdal.py | 8 +- .../contrib/gis/gdal/prototypes/errcheck.py | 14 +- .../contrib/gis/gdal/prototypes/generation.py | 12 +- django/contrib/gis/gdal/prototypes/srs.py | 6 +- django/contrib/gis/gdal/raster/band.py | 14 +- django/contrib/gis/gdal/raster/source.py | 22 +-- django/contrib/gis/gdal/srs.py | 69 +++++---- django/contrib/gis/geoip2/base.py | 2 +- django/contrib/gis/geos/collections.py | 13 +- django/contrib/gis/geos/coordseq.py | 32 ++-- django/contrib/gis/geos/factory.py | 2 +- django/contrib/gis/geos/geometry.py | 133 +++++++++-------- django/contrib/gis/geos/io.py | 4 +- django/contrib/gis/geos/libgeos.py | 6 +- django/contrib/gis/geos/linestring.py | 20 +-- django/contrib/gis/geos/point.py | 26 ++-- django/contrib/gis/geos/polygon.py | 28 ++-- .../contrib/gis/geos/prototypes/coordseq.py | 4 +- .../contrib/gis/geos/prototypes/errcheck.py | 4 +- django/contrib/gis/geos/prototypes/geom.py | 4 +- django/contrib/gis/geos/prototypes/io.py | 8 +- .../contrib/gis/geos/prototypes/threadsafe.py | 8 +- django/contrib/gis/measure.py | 6 +- django/contrib/gis/shortcuts.py | 8 +- django/contrib/gis/sitemaps/kml.py | 6 +- django/contrib/gis/sitemaps/views.py | 2 +- django/contrib/gis/utils/layermapping.py | 38 +++-- django/contrib/gis/utils/ogrinfo.py | 2 +- django/contrib/gis/utils/ogrinspect.py | 4 +- django/contrib/gis/utils/srs.py | 4 +- .../contrib/humanize/templatetags/humanize.py | 14 +- django/contrib/messages/api.py | 33 ++--- django/contrib/messages/context_processors.py | 3 +- django/contrib/messages/middleware.py | 6 +- django/contrib/messages/storage/base.py | 25 ++-- django/contrib/messages/storage/cookie.py | 24 +-- django/contrib/messages/storage/fallback.py | 6 +- django/contrib/messages/storage/session.py | 6 +- django/contrib/messages/utils.py | 2 +- django/contrib/messages/views.py | 2 +- django/contrib/sessions/backends/base.py | 35 +++-- django/contrib/sessions/backends/cached_db.py | 4 +- django/contrib/sessions/backends/db.py | 9 +- django/contrib/sessions/backends/file.py | 2 +- .../sessions/backends/signed_cookies.py | 21 ++- django/contrib/sitemaps/__init__.py | 2 +- django/contrib/sites/models.py | 10 +- django/contrib/sites/requests.py | 6 +- django/contrib/sites/shortcuts.py | 2 +- django/contrib/staticfiles/finders.py | 24 ++- django/contrib/staticfiles/handlers.py | 9 +- .../management/commands/collectstatic.py | 8 +- .../management/commands/runserver.py | 5 +- django/contrib/staticfiles/testing.py | 2 +- django/contrib/staticfiles/utils.py | 2 +- django/contrib/syndication/views.py | 10 +- 118 files changed, 819 insertions(+), 889 deletions(-) diff --git a/django/contrib/admin/decorators.py b/django/contrib/admin/decorators.py index 1a0d9812250..0c2e35c2b21 100644 --- a/django/contrib/admin/decorators.py +++ b/django/contrib/admin/decorators.py @@ -1,6 +1,6 @@ def register(*models, site=None): """ - Registers the given model(s) classes and wrapped ModelAdmin class with + Register the given model(s) classes and wrapped ModelAdmin class with admin site: @register(Author) diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py index 1b056e07e1c..f0d476ea36e 100644 --- a/django/contrib/admin/filters.py +++ b/django/contrib/admin/filters.py @@ -33,13 +33,13 @@ class ListFilter: def has_output(self): """ - Returns True if some choices would be output for this filter. + Return True if some choices would be output for this filter. """ raise NotImplementedError('subclasses of ListFilter must provide a has_output() method') def choices(self, changelist): """ - Returns choices ready to be output in the template. + Return choices ready to be output in the template. `changelist` is the ChangeList to be displayed. """ @@ -47,13 +47,13 @@ class ListFilter: def queryset(self, request, queryset): """ - Returns the filtered queryset. + Return the filtered queryset. """ raise NotImplementedError('subclasses of ListFilter must provide a queryset() method') def expected_parameters(self): """ - Returns the list of parameter names that are expected from the + Return the list of parameter names that are expected from the request's query string and that will be used by this filter. """ raise NotImplementedError('subclasses of ListFilter must provide an expected_parameters() method') @@ -82,9 +82,9 @@ class SimpleListFilter(ListFilter): def value(self): """ - Returns the value (in string format) provided in the request's - query string for this filter, if any. If the value wasn't provided then - returns None. + Return the value (in string format) provided in the request's + query string for this filter, if any, or None if the value wasn't + provided. """ return self.used_parameters.get(self.parameter_name) diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py index dc150c67009..bc1fb5e8bd4 100644 --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -377,9 +377,7 @@ class InlineFieldset(Fieldset): class AdminErrorList(forms.utils.ErrorList): - """ - Stores all errors for the form/formsets in an add/change stage view. - """ + """Store errors for the form/formsets in an add/change view.""" def __init__(self, form, inline_formsets): super().__init__() diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py index e3483a85b27..507b1d873ef 100644 --- a/django/contrib/admin/models.py +++ b/django/contrib/admin/models.py @@ -129,12 +129,12 @@ class LogEntry(models.Model): return self.change_message def get_edited_object(self): - "Returns the edited object represented by this log entry" + """Return the edited object represented by this log entry.""" return self.content_type.get_object_for_this_type(pk=self.object_id) def get_admin_url(self): """ - Returns the admin URL to edit the object represented by this log entry. + Return the admin URL to edit the object represented by this log entry. """ if self.content_type and self.object_id: url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index ba7e36c8c2a..c9f5ff42c1f 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -200,7 +200,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass): """ If the ModelAdmin specifies ordering, the queryset should respect that ordering. Otherwise don't specify the queryset, let the field decide - (returns None in that case). + (return None in that case). """ related_admin = self.admin_site._registry.get(db_field.remote_field.model) if related_admin is not None: @@ -321,7 +321,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass): def get_queryset(self, request): """ - Returns a QuerySet of all model instances that can be edited by the + Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view. """ qs = self.model._default_manager.get_queryset() @@ -384,7 +384,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass): def to_field_allowed(self, request, to_field): """ - Returns True if the model associated with this admin should be + Return True if the model associated with this admin should be allowed to be referenced by the specified field. """ opts = self.model._meta @@ -429,7 +429,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass): def has_add_permission(self, request): """ - Returns True if the given request has permission to add an object. + Return True if the given request has permission to add an object. Can be overridden by the user in subclasses. """ opts = self.opts @@ -438,7 +438,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass): def has_change_permission(self, request, obj=None): """ - Returns True if the given request has permission to change the given + Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. @@ -453,7 +453,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass): def has_delete_permission(self, request, obj=None): """ - Returns True if the given request has permission to change the given + Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. @@ -468,7 +468,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass): def has_module_permission(self, request): """ - Returns True if the given request has any permission in the given + Return True if the given request has any permission in the given app label. Can be overridden by the user in subclasses. In such case it should @@ -481,7 +481,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass): class ModelAdmin(BaseModelAdmin): - "Encapsulates all admin options and functionality for a given model." + """Encapsulate all admin options and functionality for a given model.""" list_display = ('__str__',) list_display_links = () @@ -585,7 +585,7 @@ class ModelAdmin(BaseModelAdmin): def get_model_perms(self, request): """ - Returns a dict of all perms for this model. This dict has the keys + Return a dict of all perms for this model. This dict has the keys ``add``, ``change``, and ``delete`` mapping to the True/False for each of those actions. """ @@ -603,7 +603,7 @@ class ModelAdmin(BaseModelAdmin): def get_form(self, request, obj=None, **kwargs): """ - Returns a Form class for use in the admin add view. This is used by + Return a Form class for use in the admin add view. This is used by add_view and change_view. """ if 'fields' in kwargs: @@ -650,15 +650,15 @@ class ModelAdmin(BaseModelAdmin): def get_changelist(self, request, **kwargs): """ - Returns the ChangeList class for use on the changelist page. + Return the ChangeList class for use on the changelist page. """ from django.contrib.admin.views.main import ChangeList return ChangeList def get_object(self, request, object_id, from_field=None): """ - Returns an instance matching the field and value provided, the primary - key is used if no field is provided. Returns ``None`` if no match is + Return an instance matching the field and value provided, the primary + key is used if no field is provided. Return ``None`` if no match is found or the object_id fails validation. """ queryset = self.get_queryset(request) @@ -672,7 +672,7 @@ class ModelAdmin(BaseModelAdmin): def get_changelist_form(self, request, **kwargs): """ - Returns a Form class for use in the Formset on the changelist page. + Return a Form class for use in the Formset on the changelist page. """ defaults = { "formfield_callback": partial(self.formfield_for_dbfield, request=request), @@ -685,7 +685,7 @@ class ModelAdmin(BaseModelAdmin): def get_changelist_formset(self, request, **kwargs): """ - Returns a FormSet class for use on the changelist page if list_editable + Return a FormSet class for use on the changelist page if list_editable is used. """ defaults = { @@ -699,7 +699,7 @@ class ModelAdmin(BaseModelAdmin): def get_formsets_with_inlines(self, request, obj=None): """ - Yields formsets and the corresponding inlines. + Yield formsets and the corresponding inlines. """ for inline in self.get_inline_instances(request, obj): yield inline.get_formset(request, obj), inline @@ -861,28 +861,28 @@ class ModelAdmin(BaseModelAdmin): def get_list_filter(self, request): """ - Returns a sequence containing the fields to be displayed as filters in + Return a sequence containing the fields to be displayed as filters in the right sidebar of the changelist page. """ return self.list_filter def get_list_select_related(self, request): """ - Returns a list of fields to add to the select_related() part of the + Return a list of fields to add to the select_related() part of the changelist items query. """ return self.list_select_related def get_search_fields(self, request): """ - Returns a sequence containing the fields to be searched whenever + Return a sequence containing the fields to be searched whenever somebody submits a search query. """ return self.search_fields def get_search_results(self, request, queryset, search_term): """ - Returns a tuple containing a queryset to implement the search, + Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates. """ # Apply keyword searches. @@ -915,7 +915,7 @@ class ModelAdmin(BaseModelAdmin): def get_preserved_filters(self, request): """ - Returns the preserved filters querystring. + Return the preserved filters querystring. """ match = request.resolver_match if self.preserve_filters and match: @@ -1038,7 +1038,7 @@ class ModelAdmin(BaseModelAdmin): def response_add(self, request, obj, post_url_continue=None): """ - Determines the HttpResponse for the add_view stage. + Determine the HttpResponse for the add_view stage. """ opts = obj._meta pk_value = obj._get_pk_val() @@ -1117,7 +1117,7 @@ class ModelAdmin(BaseModelAdmin): def response_change(self, request, obj): """ - Determines the HttpResponse for the change_view stage. + Determine the HttpResponse for the change_view stage. """ if IS_POPUP_VAR in request.POST: @@ -1296,9 +1296,8 @@ class ModelAdmin(BaseModelAdmin): def response_delete(self, request, obj_display, obj_id): """ - Determines the HttpResponse for the delete_view stage. + Determine the HttpResponse for the delete_view stage. """ - opts = self.model._meta if IS_POPUP_VAR in request.POST: @@ -1372,8 +1371,7 @@ class ModelAdmin(BaseModelAdmin): def get_changeform_initial_data(self, request): """ - Get the initial form data. - Unless overridden, this populates from the GET params. + Get the initial form data from the request's GET params. """ initial = dict(request.GET.items()) for k in initial: @@ -1869,7 +1867,7 @@ class InlineModelAdmin(BaseModelAdmin): return self.max_num def get_formset(self, request, obj=None, **kwargs): - """Returns a BaseInlineFormSet class for use in admin add/change views.""" + """Return a BaseInlineFormSet class for use in admin add/change views.""" if 'fields' in kwargs: fields = kwargs.pop('fields') else: diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index 414c7ab9835..a95bdd7a2ec 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -82,17 +82,17 @@ class AdminSite: def register(self, model_or_iterable, admin_class=None, **options): """ - Registers the given model(s) with the given admin class. + Register the given model(s) with the given admin class. The model(s) should be Model classes, not instances. - If an admin class isn't given, it will use ModelAdmin (the default - admin options). If keyword arguments are given -- e.g., list_display -- - they'll be applied as options to the admin class. + If an admin class isn't given, use ModelAdmin (the default admin + options). If keyword arguments are given -- e.g., list_display -- + apply them as options to the admin class. - If a model is already registered, this will raise AlreadyRegistered. + If a model is already registered, raise AlreadyRegistered. - If a model is abstract, this will raise ImproperlyConfigured. + If a model is abstract, raise ImproperlyConfigured. """ if not admin_class: admin_class = ModelAdmin @@ -125,9 +125,9 @@ class AdminSite: def unregister(self, model_or_iterable): """ - Unregisters the given model(s). + Unregister the given model(s). - If a model isn't already registered, this will raise NotRegistered. + If a model isn't already registered, raise NotRegistered. """ if isinstance(model_or_iterable, ModelBase): model_or_iterable = [model_or_iterable] @@ -152,14 +152,14 @@ class AdminSite: def disable_action(self, name): """ - Disable a globally-registered action. Raises KeyError for invalid names. + Disable a globally-registered action. Raise KeyError for invalid names. """ del self._actions[name] def get_action(self, name): """ Explicitly get a registered global action whether it's enabled or - not. Raises KeyError for invalid names. + not. Raise KeyError for invalid names. """ return self._global_actions[name] @@ -180,7 +180,7 @@ class AdminSite: def has_permission(self, request): """ - Returns True if the given HttpRequest has permission to view + Return True if the given HttpRequest has permission to view *at least one* page in the admin site. """ return request.user.is_active and request.user.is_staff @@ -280,7 +280,7 @@ class AdminSite: def each_context(self, request): """ - Returns a dictionary of variables to put in the template context for + Return a dictionary of variables to put in the template context for *every* page in the admin site. For sites running on a subpath, use the SCRIPT_NAME value if site_url @@ -298,7 +298,7 @@ class AdminSite: def password_change(self, request, extra_context=None): """ - Handles the "change password" task -- both form display and validation. + Handle the "change password" task -- both form display and validation. """ from django.contrib.admin.forms import AdminPasswordChangeForm from django.contrib.auth.views import PasswordChangeView @@ -315,7 +315,7 @@ class AdminSite: def password_change_done(self, request, extra_context=None): """ - Displays the "success" page after a password change. + Display the "success" page after a password change. """ from django.contrib.auth.views import PasswordChangeDoneView defaults = { @@ -328,7 +328,7 @@ class AdminSite: def i18n_javascript(self, request, extra_context=None): """ - Displays the i18n JavaScript that the Django admin requires. + Display the i18n JavaScript that the Django admin requires. `extra_context` is unused but present for consistency with the other admin views. @@ -338,7 +338,7 @@ class AdminSite: @never_cache def logout(self, request, extra_context=None): """ - Logs out the user for the given HttpRequest. + Log out the user for the given HttpRequest. This should *not* assume the user is already logged in. """ @@ -360,7 +360,7 @@ class AdminSite: @never_cache def login(self, request, extra_context=None): """ - Displays the login form for the given HttpRequest. + Display the login form for the given HttpRequest. """ if request.method == 'GET' and self.has_permission(request): # Already logged-in, redirect to admin index @@ -393,8 +393,8 @@ class AdminSite: def _build_app_dict(self, request, label=None): """ - Builds the app dictionary. Takes an optional label parameters to filter - models of a specific app. + Build the app dictionary. The optional `label` parameter filters models + of a specific app. """ app_dict = {} @@ -458,7 +458,7 @@ class AdminSite: def get_app_list(self, request): """ - Returns a sorted list of all the installed apps that have been + Return a sorted list of all the installed apps that have been registered in this site. """ app_dict = self._build_app_dict(request) @@ -475,7 +475,7 @@ class AdminSite: @never_cache def index(self, request, extra_context=None): """ - Displays the main admin index page, which lists all of the installed + Display the main admin index page, which lists all of the installed apps that have been registered in this site. """ app_list = self.get_app_list(request) diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 81b533436d0..62bbbccbed3 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -29,7 +29,7 @@ DOT = '.' @register.simple_tag def paginator_number(cl, i): """ - Generates an individual page index link in a paginated list. + Generate an individual page index link in a paginated list. """ if i == DOT: return '... ' @@ -45,7 +45,7 @@ def paginator_number(cl, i): @register.inclusion_tag('admin/pagination.html') def pagination(cl): """ - Generates the series of links to the pages in a paginated list. + Generate the series of links to the pages in a paginated list. """ paginator, page_num = cl.paginator, cl.page_num @@ -91,7 +91,7 @@ def pagination(cl): def result_headers(cl): """ - Generates the list column headers. + Generate the list column headers. """ ordering_field_columns = cl.get_ordering_field_columns() for i, field_name in enumerate(cl.list_display): @@ -195,7 +195,7 @@ def _coerce_field_name(field_name, field_index): def items_for_result(cl, result, form): """ - Generates the actual list of data. + Generate the actual list of data. """ def link_in_col(is_first, field_name, cl): @@ -285,10 +285,11 @@ def items_for_result(cl, result, form): class ResultList(list): - # Wrapper class used to return items in a list_editable - # changelist, annotated with the form object for error - # reporting purposes. Needed to maintain backwards - # compatibility with existing admin templates. + """ + Wrapper class used to return items in a list_editable changelist, annotated + with the form object for error reporting purposes. Needed to maintain + backwards compatibility with existing admin templates. + """ def __init__(self, form, *items): self.form = form super().__init__(*items) @@ -313,7 +314,7 @@ def result_hidden_fields(cl): @register.inclusion_tag("admin/change_list_results.html") def result_list(cl): """ - Displays the headers and data list together + Display the headers and data list together. """ headers = list(result_headers(cl)) num_sorted_fields = 0 @@ -330,7 +331,7 @@ def result_list(cl): @register.inclusion_tag('admin/date_hierarchy.html') def date_hierarchy(cl): """ - Displays the date hierarchy for date drill-down functionality. + Display the date hierarchy for date drill-down functionality. """ if cl.date_hierarchy: field_name = cl.date_hierarchy @@ -409,7 +410,7 @@ def date_hierarchy(cl): @register.inclusion_tag('admin/search_form.html') def search_form(cl): """ - Displays a search form for searching the list. + Display a search form for searching the list. """ return { 'cl': cl, diff --git a/django/contrib/admin/templatetags/admin_modify.py b/django/contrib/admin/templatetags/admin_modify.py index 32e63f08a54..50ec00bb25b 100644 --- a/django/contrib/admin/templatetags/admin_modify.py +++ b/django/contrib/admin/templatetags/admin_modify.py @@ -9,7 +9,7 @@ register = template.Library() @register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True) def prepopulated_fields_js(context): """ - Creates a list of prepopulated_fields that should render Javascript for + Create a list of prepopulated_fields that should render Javascript for the prepopulated fields for both the admin form and inlines. """ prepopulated_fields = [] @@ -42,7 +42,7 @@ def prepopulated_fields_js(context): @register.inclusion_tag('admin/submit_line.html', takes_context=True) def submit_row(context): """ - Displays the row of buttons for delete and save. + Display the row of buttons for delete and save. """ change = context['change'] is_popup = context['is_popup'] @@ -68,7 +68,7 @@ def submit_row(context): @register.filter def cell_count(inline_admin_form): - """Returns the number of cells used in a tabular inline""" + """Return the number of cells used in a tabular inline.""" count = 1 # Hidden cell with hidden 'id' field for fieldset in inline_admin_form: # Loop through all the fields (one per cell) diff --git a/django/contrib/admin/templatetags/log.py b/django/contrib/admin/templatetags/log.py index 427cb9521f4..08c2345e7cb 100644 --- a/django/contrib/admin/templatetags/log.py +++ b/django/contrib/admin/templatetags/log.py @@ -26,7 +26,7 @@ class AdminLogNode(template.Node): @register.tag def get_admin_log(parser, token): """ - Populates a template variable with the admin log for the given criteria. + Populate a template variable with the admin log for the given criteria. Usage:: diff --git a/django/contrib/admin/tests.py b/django/contrib/admin/tests.py index 7043ed80b84..ad6736f7715 100644 --- a/django/contrib/admin/tests.py +++ b/django/contrib/admin/tests.py @@ -25,10 +25,10 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase): def wait_until(self, callback, timeout=10): """ - Helper function that blocks the execution of the tests until the - specified callback returns a value that is not falsy. This function can - be called, for example, after clicking a link or submitting a form. - See the other public methods that call this function for more details. + Block the execution of the tests until the specified callback returns a + value that is not falsy. This method can be called, for example, after + clicking a link or submitting a form. See the other public methods that + call this function for more details. """ from selenium.webdriver.support.wait import WebDriverWait WebDriverWait(self.selenium, timeout).until(callback) @@ -42,7 +42,7 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase): def wait_for(self, css_selector, timeout=10): """ - Helper function that blocks until a CSS selector is found on the page. + Block until a CSS selector is found on the page. """ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec @@ -53,7 +53,7 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase): def wait_for_text(self, css_selector, text, timeout=10): """ - Helper function that blocks until the text is found in the CSS selector. + Block until the text is found in the CSS selector. """ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec @@ -65,7 +65,7 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase): def wait_for_value(self, css_selector, text, timeout=10): """ - Helper function that blocks until the value is found in the CSS selector. + Block until the value is found in the CSS selector. """ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec @@ -113,7 +113,7 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase): def admin_login(self, username, password, login_url='/admin/'): """ - Helper function to log into the admin. + Log in to the admin. """ self.selenium.get('%s%s' % (self.live_server_url, login_url)) username_input = self.selenium.find_element_by_name('username') @@ -127,16 +127,15 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase): def get_css_value(self, selector, attribute): """ - Helper function that returns the value for the CSS attribute of an - DOM element specified by the given selector. Uses the jQuery that ships - with Django. + Return the value for the CSS attribute of a DOM element specified by + the given selector. Uses the jQuery that ships with Django. """ return self.selenium.execute_script( 'return django.jQuery("%s").css("%s")' % (selector, attribute)) def get_select_option(self, selector, value): """ - Returns the