コード例 #1
0
    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)
コード例 #2
0
ファイル: customtags.py プロジェクト: rhymeswithcycle/billy
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):
コード例 #3
0
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.
    '''
コード例 #4
0
ファイル: customtags.py プロジェクト: h4ck3rm1k3/billy
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.
    '''
コード例 #5
0
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.
    '''