def process_view(self, request, func, args, kw): # Skip API or admin views. for path in ['/admin', '/api']: if request.path.startswith(path): return func(request, *args, **kw) # For public views, make sure the state is active. if 'abbr' in kw: if kw['abbr'] not in settings.ACTIVE_STATES + ['all']: try: metadata = Metadata.get_object(kw['abbr']) except DoesNotExist: raise Http404 return render(request, templatename('state_not_active_yet'), dict(metadata=metadata, nav_active=None)) else: return func(request, *args, **kw)
from decimal import Decimal import re from django import template from django.utils.html import strip_tags from billy.core import settings from billy.web.public.views.utils import templatename from billy.web.public.forms import get_region_select_form register = template.Library() @register.inclusion_tag(templatename('region_select_form')) def region_select_form(abbr=None): return {'form': get_region_select_form({'abbr': abbr})} @register.inclusion_tag(templatename('sources')) def sources(obj): return {'sources': obj['sources']} @register.filter def plusfield(obj, key): return obj.get('+' + key) @register.filter def party_noun(party, count=1):
import re import json import urllib from django import template from django.utils.html import strip_tags from billy.core import settings from billy.web.public.forms import get_region_select_form from billy.web.public.views.utils import templatename register = template.Library() @register.inclusion_tag(templatename('region_select_form')) def region_select_form(abbr=None): return {'form': get_region_select_form({'abbr': abbr})} @register.inclusion_tag(templatename('sources')) def sources(obj): return {'sources': obj['sources']} @register.filter def sources_urlize(url): '''Django's urlize built-in template tag does a lot of other things, like linking domain-only links, but it won't hyperlink ftp links, so this is a more liberal replacement for source links. '''
from django import template from django.utils.html import strip_tags import pytz from billy.core import settings from billy.web.public.forms import get_region_select_form from billy.web.public.views.utils import templatename from billy.web.public.views.favorites import is_favorite register = template.Library() @register.inclusion_tag(templatename('region_select_form')) def region_select_form(abbr=None): return {'form': get_region_select_form({'abbr': abbr})} @register.inclusion_tag(templatename('sources')) def sources(obj): return {'sources': obj['sources']} @register.filter def sources_urlize(url): '''Django's urlize built-in template tag does a lot of other things, like linking domain-only links, but it won't hyperlink ftp links, so this is a more liberal replacement for source links. '''