diff --git a/core/context_processors.py b/core/context_processors.py index 49cdfaf1..c1828750 100644 --- a/core/context_processors.py +++ b/core/context_processors.py @@ -1,7 +1,7 @@ from django.conf import settings from django.core.cache import cache -from chronam.core import models, index +from chronam.core import index, models from chronam.core.forms import _fulltext_range @@ -11,12 +11,12 @@ def extra_request_info(request): """ fulltext_range = _fulltext_range() return { - 'site_title': 'Chronicling America', - 'omniture_url': getattr(settings, "OMNITURE_SCRIPT", None), - 'sharetool_url': getattr(settings, "SHARETOOL_URL", None), - 'RAVEN_PUBLIC_DSN': getattr(settings, 'RAVEN_PUBLIC_DSN', None), - 'fulltext_startdate': fulltext_range[0], - 'fulltext_enddate': fulltext_range[1], + "site_title": "Chronicling America", + "omniture_url": getattr(settings, "OMNITURE_SCRIPT", None), + "sharetool_url": getattr(settings, "SHARETOOL_URL", None), + "RAVEN_PUBLIC_DSN": getattr(settings, "RAVEN_PUBLIC_DSN", None), + "fulltext_startdate": fulltext_range[0], + "fulltext_enddate": fulltext_range[1], } @@ -28,10 +28,14 @@ def newspaper_info(request): titles_with_issues_count = titles_with_issues.count() _places = models.Place.objects.filter(titles__in=titles_with_issues) - states_with_issues = sorted(set(place.state for place in _places if place.state is not None)) + states_with_issues = sorted( + set(place.state for place in _places if place.state is not None) + ) _languages = models.Language.objects.filter(titles__in=titles_with_issues) - languages_with_issues = sorted(set((lang.code, lang.name) for lang in _languages)) + languages_with_issues = sorted( + set((lang.code, lang.name) for lang in _languages) + ) # TODO: might make sense to add a Ethnicity.has_issue model field # to save having to recompute this all the time, eventhough it @@ -43,11 +47,13 @@ def newspaper_info(request): if e.has_issues and e.name not in ["African", "Canadian", "Welsh"]: ethnicities_with_issues.append(e.name) - info = {'titles_with_issues_count': titles_with_issues_count, - 'states_with_issues': states_with_issues, - 'languages_with_issues': languages_with_issues, - 'ethnicities_with_issues': ethnicities_with_issues, - 'total_page_count': total_page_count} + info = { + "titles_with_issues_count": titles_with_issues_count, + "states_with_issues": states_with_issues, + "languages_with_issues": languages_with_issues, + "ethnicities_with_issues": ethnicities_with_issues, + "total_page_count": total_page_count, + } cache.set("newspaper_info", info, settings.METADATA_TTL_SECONDS)