1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Refs #33476 -- Reformatted code with Black.

This commit is contained in:
django-bot
2022-02-03 20:24:19 +01:00
committed by Mariusz Felisiak
parent f68fa8b45d
commit 9c19aff7c7
1992 changed files with 139577 additions and 96284 deletions

View File

@@ -13,7 +13,7 @@ from ..models import I18nTestModel, TestModel
class SimpleSitemap(Sitemap):
changefreq = "never"
priority = 0.5
location = '/location/'
location = "/location/"
lastmod = date.today()
def items(self):
@@ -33,7 +33,7 @@ class SimpleI18nSitemap(Sitemap):
i18n = True
def items(self):
return I18nTestModel.objects.order_by('pk').all()
return I18nTestModel.objects.order_by("pk").all()
class AlternatesI18nSitemap(SimpleI18nSitemap):
@@ -41,7 +41,7 @@ class AlternatesI18nSitemap(SimpleI18nSitemap):
class LimitedI18nSitemap(AlternatesI18nSitemap):
languages = ['en', 'es']
languages = ["en", "es"]
class XDefaultI18nSitemap(AlternatesI18nSitemap):
@@ -51,7 +51,7 @@ class XDefaultI18nSitemap(AlternatesI18nSitemap):
class EmptySitemap(Sitemap):
changefreq = "never"
priority = 0.5
location = '/location/'
location = "/location/"
class FixedLastmodSitemap(SimpleSitemap):
@@ -61,7 +61,7 @@ class FixedLastmodSitemap(SimpleSitemap):
class FixedLastmodMixedSitemap(Sitemap):
changefreq = "never"
priority = 0.5
location = '/location/'
location = "/location/"
loop = 0
def items(self):
@@ -85,7 +85,8 @@ class TimezoneSiteMap(SimpleSitemap):
class CallableLastmodPartialSitemap(Sitemap):
"""Not all items have `lastmod`."""
location = '/location/'
location = "/location/"
def items(self):
o1 = TestModel()
@@ -99,7 +100,8 @@ class CallableLastmodPartialSitemap(Sitemap):
class CallableLastmodFullSitemap(Sitemap):
"""All items have `lastmod`."""
location = '/location/'
location = "/location/"
def items(self):
o1 = TestModel()
@@ -115,7 +117,7 @@ class CallableLastmodFullSitemap(Sitemap):
class GetLatestLastmodNoneSiteMap(Sitemap):
changefreq = "never"
priority = 0.5
location = '/location/'
location = "/location/"
def items(self):
return [object()]
@@ -137,216 +139,292 @@ def testmodelview(request, id):
simple_sitemaps = {
'simple': SimpleSitemap,
"simple": SimpleSitemap,
}
simple_i18n_sitemaps = {
'i18n': SimpleI18nSitemap,
"i18n": SimpleI18nSitemap,
}
alternates_i18n_sitemaps = {
'i18n-alternates': AlternatesI18nSitemap,
"i18n-alternates": AlternatesI18nSitemap,
}
limited_i18n_sitemaps = {
'i18n-limited': LimitedI18nSitemap,
"i18n-limited": LimitedI18nSitemap,
}
xdefault_i18n_sitemaps = {
'i18n-xdefault': XDefaultI18nSitemap,
"i18n-xdefault": XDefaultI18nSitemap,
}
simple_sitemaps_not_callable = {
'simple': SimpleSitemap(),
"simple": SimpleSitemap(),
}
simple_sitemaps_paged = {
'simple': SimplePagedSitemap,
"simple": SimplePagedSitemap,
}
empty_sitemaps = {
'empty': EmptySitemap,
"empty": EmptySitemap,
}
fixed_lastmod_sitemaps = {
'fixed-lastmod': FixedLastmodSitemap,
"fixed-lastmod": FixedLastmodSitemap,
}
fixed_lastmod_mixed_sitemaps = {
'fixed-lastmod-mixed': FixedLastmodMixedSitemap,
"fixed-lastmod-mixed": FixedLastmodMixedSitemap,
}
sitemaps_lastmod_mixed_ascending = {
'no-lastmod': EmptySitemap,
'lastmod': FixedLastmodSitemap,
"no-lastmod": EmptySitemap,
"lastmod": FixedLastmodSitemap,
}
sitemaps_lastmod_mixed_descending = {
'lastmod': FixedLastmodSitemap,
'no-lastmod': EmptySitemap,
"lastmod": FixedLastmodSitemap,
"no-lastmod": EmptySitemap,
}
sitemaps_lastmod_ascending = {
'date': DateSiteMap,
'datetime': FixedLastmodSitemap,
'datetime-newer': FixedNewerLastmodSitemap,
"date": DateSiteMap,
"datetime": FixedLastmodSitemap,
"datetime-newer": FixedNewerLastmodSitemap,
}
sitemaps_lastmod_descending = {
'datetime-newer': FixedNewerLastmodSitemap,
'datetime': FixedLastmodSitemap,
'date': DateSiteMap,
"datetime-newer": FixedNewerLastmodSitemap,
"datetime": FixedLastmodSitemap,
"date": DateSiteMap,
}
generic_sitemaps = {
'generic': GenericSitemap({'queryset': TestModel.objects.order_by('pk').all()}),
"generic": GenericSitemap({"queryset": TestModel.objects.order_by("pk").all()}),
}
get_latest_lastmod_none_sitemaps = {
'get-latest-lastmod-none': GetLatestLastmodNoneSiteMap,
"get-latest-lastmod-none": GetLatestLastmodNoneSiteMap,
}
get_latest_lastmod_sitemaps = {
'get-latest-lastmod': GetLatestLastmodSiteMap,
"get-latest-lastmod": GetLatestLastmodSiteMap,
}
latest_lastmod_timezone_sitemaps = {
'latest-lastmod-timezone': TimezoneSiteMap,
"latest-lastmod-timezone": TimezoneSiteMap,
}
generic_sitemaps_lastmod = {
'generic': GenericSitemap({
'queryset': TestModel.objects.order_by('pk').all(),
'date_field': 'lastmod',
}),
"generic": GenericSitemap(
{
"queryset": TestModel.objects.order_by("pk").all(),
"date_field": "lastmod",
}
),
}
callable_lastmod_partial_sitemap = {
'callable-lastmod': CallableLastmodPartialSitemap,
"callable-lastmod": CallableLastmodPartialSitemap,
}
callable_lastmod_full_sitemap = {
'callable-lastmod': CallableLastmodFullSitemap,
"callable-lastmod": CallableLastmodFullSitemap,
}
urlpatterns = [
path('simple/index.xml', views.index, {'sitemaps': simple_sitemaps}),
path('simple-paged/index.xml', views.index, {'sitemaps': simple_sitemaps_paged}),
path('simple-not-callable/index.xml', views.index, {'sitemaps': simple_sitemaps_not_callable}),
path("simple/index.xml", views.index, {"sitemaps": simple_sitemaps}),
path("simple-paged/index.xml", views.index, {"sitemaps": simple_sitemaps_paged}),
path(
'simple/custom-index.xml', views.index,
{'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap_index.xml'}),
path(
'simple/custom-lastmod-index.xml', views.index,
{'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap_lastmod_index.xml'},
"simple-not-callable/index.xml",
views.index,
{"sitemaps": simple_sitemaps_not_callable},
),
path(
'simple/sitemap-<section>.xml', views.sitemap,
{'sitemaps': simple_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
path(
'simple/sitemap.xml', views.sitemap,
{'sitemaps': simple_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
path(
'simple/i18n.xml', views.sitemap,
{'sitemaps': simple_i18n_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
path(
'alternates/i18n.xml', views.sitemap,
{'sitemaps': alternates_i18n_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
path(
'limited/i18n.xml', views.sitemap,
{'sitemaps': limited_i18n_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
path(
'x-default/i18n.xml', views.sitemap,
{'sitemaps': xdefault_i18n_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
path(
'simple/custom-sitemap.xml', views.sitemap,
{'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap.xml'},
name='django.contrib.sitemaps.views.sitemap'),
path(
'empty/sitemap.xml', views.sitemap,
{'sitemaps': empty_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
path(
'lastmod/sitemap.xml', views.sitemap,
{'sitemaps': fixed_lastmod_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
path(
'lastmod-mixed/sitemap.xml', views.sitemap,
{'sitemaps': fixed_lastmod_mixed_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
path(
'lastmod/date-sitemap.xml', views.sitemap,
{'sitemaps': {'date-sitemap': DateSiteMap}},
name='django.contrib.sitemaps.views.sitemap'),
path(
'lastmod/tz-sitemap.xml', views.sitemap,
{'sitemaps': {'tz-sitemap': TimezoneSiteMap}},
name='django.contrib.sitemaps.views.sitemap'),
path(
'lastmod-sitemaps/mixed-ascending.xml', views.sitemap,
{'sitemaps': sitemaps_lastmod_mixed_ascending},
name='django.contrib.sitemaps.views.sitemap'),
path(
'lastmod-sitemaps/mixed-descending.xml', views.sitemap,
{'sitemaps': sitemaps_lastmod_mixed_descending},
name='django.contrib.sitemaps.views.sitemap'),
path(
'lastmod-sitemaps/ascending.xml', views.sitemap,
{'sitemaps': sitemaps_lastmod_ascending},
name='django.contrib.sitemaps.views.sitemap'),
path(
'lastmod-sitemaps/descending.xml', views.sitemap,
{'sitemaps': sitemaps_lastmod_descending},
name='django.contrib.sitemaps.views.sitemap'),
path(
'lastmod/get-latest-lastmod-none-sitemap.xml', views.index,
{'sitemaps': get_latest_lastmod_none_sitemaps},
name='django.contrib.sitemaps.views.index',
"simple/custom-index.xml",
views.index,
{"sitemaps": simple_sitemaps, "template_name": "custom_sitemap_index.xml"},
),
path(
'lastmod/get-latest-lastmod-sitemap.xml', views.index,
{'sitemaps': get_latest_lastmod_sitemaps},
name='django.contrib.sitemaps.views.index',
"simple/custom-lastmod-index.xml",
views.index,
{
"sitemaps": simple_sitemaps,
"template_name": "custom_sitemap_lastmod_index.xml",
},
),
path(
'lastmod/latest-lastmod-timezone-sitemap.xml', views.index,
{'sitemaps': latest_lastmod_timezone_sitemaps},
name='django.contrib.sitemaps.views.index',
"simple/sitemap-<section>.xml",
views.sitemap,
{"sitemaps": simple_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
'generic/sitemap.xml', views.sitemap,
{'sitemaps': generic_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
"simple/sitemap.xml",
views.sitemap,
{"sitemaps": simple_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
'generic-lastmod/sitemap.xml', views.sitemap,
{'sitemaps': generic_sitemaps_lastmod},
name='django.contrib.sitemaps.views.sitemap'),
"simple/i18n.xml",
views.sitemap,
{"sitemaps": simple_i18n_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
'cached/index.xml', cache_page(1)(views.index),
{'sitemaps': simple_sitemaps, 'sitemap_url_name': 'cached_sitemap'}),
"alternates/i18n.xml",
views.sitemap,
{"sitemaps": alternates_i18n_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
'cached/sitemap-<section>.xml', cache_page(1)(views.sitemap),
{'sitemaps': simple_sitemaps}, name='cached_sitemap'),
"limited/i18n.xml",
views.sitemap,
{"sitemaps": limited_i18n_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
'sitemap-without-entries/sitemap.xml', views.sitemap,
{'sitemaps': {}}, name='django.contrib.sitemaps.views.sitemap'),
path('callable-lastmod-partial/index.xml', views.index, {'sitemaps': callable_lastmod_partial_sitemap}),
path('callable-lastmod-partial/sitemap.xml', views.sitemap, {'sitemaps': callable_lastmod_partial_sitemap}),
path('callable-lastmod-full/index.xml', views.index, {'sitemaps': callable_lastmod_full_sitemap}),
path('callable-lastmod-full/sitemap.xml', views.sitemap, {'sitemaps': callable_lastmod_full_sitemap}),
"x-default/i18n.xml",
views.sitemap,
{"sitemaps": xdefault_i18n_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
'generic-lastmod/index.xml', views.index,
{'sitemaps': generic_sitemaps_lastmod},
name='django.contrib.sitemaps.views.index',
"simple/custom-sitemap.xml",
views.sitemap,
{"sitemaps": simple_sitemaps, "template_name": "custom_sitemap.xml"},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"empty/sitemap.xml",
views.sitemap,
{"sitemaps": empty_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"lastmod/sitemap.xml",
views.sitemap,
{"sitemaps": fixed_lastmod_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"lastmod-mixed/sitemap.xml",
views.sitemap,
{"sitemaps": fixed_lastmod_mixed_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"lastmod/date-sitemap.xml",
views.sitemap,
{"sitemaps": {"date-sitemap": DateSiteMap}},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"lastmod/tz-sitemap.xml",
views.sitemap,
{"sitemaps": {"tz-sitemap": TimezoneSiteMap}},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"lastmod-sitemaps/mixed-ascending.xml",
views.sitemap,
{"sitemaps": sitemaps_lastmod_mixed_ascending},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"lastmod-sitemaps/mixed-descending.xml",
views.sitemap,
{"sitemaps": sitemaps_lastmod_mixed_descending},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"lastmod-sitemaps/ascending.xml",
views.sitemap,
{"sitemaps": sitemaps_lastmod_ascending},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"lastmod-sitemaps/descending.xml",
views.sitemap,
{"sitemaps": sitemaps_lastmod_descending},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"lastmod/get-latest-lastmod-none-sitemap.xml",
views.index,
{"sitemaps": get_latest_lastmod_none_sitemaps},
name="django.contrib.sitemaps.views.index",
),
path(
"lastmod/get-latest-lastmod-sitemap.xml",
views.index,
{"sitemaps": get_latest_lastmod_sitemaps},
name="django.contrib.sitemaps.views.index",
),
path(
"lastmod/latest-lastmod-timezone-sitemap.xml",
views.index,
{"sitemaps": latest_lastmod_timezone_sitemaps},
name="django.contrib.sitemaps.views.index",
),
path(
"generic/sitemap.xml",
views.sitemap,
{"sitemaps": generic_sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"generic-lastmod/sitemap.xml",
views.sitemap,
{"sitemaps": generic_sitemaps_lastmod},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"cached/index.xml",
cache_page(1)(views.index),
{"sitemaps": simple_sitemaps, "sitemap_url_name": "cached_sitemap"},
),
path(
"cached/sitemap-<section>.xml",
cache_page(1)(views.sitemap),
{"sitemaps": simple_sitemaps},
name="cached_sitemap",
),
path(
"sitemap-without-entries/sitemap.xml",
views.sitemap,
{"sitemaps": {}},
name="django.contrib.sitemaps.views.sitemap",
),
path(
"callable-lastmod-partial/index.xml",
views.index,
{"sitemaps": callable_lastmod_partial_sitemap},
),
path(
"callable-lastmod-partial/sitemap.xml",
views.sitemap,
{"sitemaps": callable_lastmod_partial_sitemap},
),
path(
"callable-lastmod-full/index.xml",
views.index,
{"sitemaps": callable_lastmod_full_sitemap},
),
path(
"callable-lastmod-full/sitemap.xml",
views.sitemap,
{"sitemaps": callable_lastmod_full_sitemap},
),
path(
"generic-lastmod/index.xml",
views.index,
{"sitemaps": generic_sitemaps_lastmod},
name="django.contrib.sitemaps.views.index",
),
]
urlpatterns += i18n_patterns(
path('i18n/testmodel/<int:id>/', testmodelview, name='i18n_testmodel'),
path("i18n/testmodel/<int:id>/", testmodelview, name="i18n_testmodel"),
)