""" Custom filters and objects for news-related templates. """ from coffin import template from coffin.template.loader import render_to_string from django.conf import settings from django.utils.dateformat import DateFormat from jinja2 import Markup from flatblocks.models import FlatBlock from colorado.apps.gundeaths.models import Incident from colorado.apps.news.views import wp register = template.Library() from dateutil.parser import parse @register.filter def parsedate(value, format=None): dt = parse(value) if format: return DateFormat(dt).format(format) return dt @register.object def wp_pages(): """ Return a list of WordPress-created pages. Includes only title and slug to save bandwidth.
from askbot.conf import settings as askbot_settings from django.conf import settings as django_settings from askbot.skins import utils as skin_utils from askbot.utils.html import absolutize_urls, site_link from askbot.utils.html import site_url as site_url_func from askbot.utils import functions from askbot.utils import url_utils from askbot.utils.markup import markdown_input_converter from askbot.utils.slug import slugify from askbot.utils.pluralization import py_pluralize as _py_pluralize from askbot.shims.django_shims import ResolverMatch from django_countries import countries from django_countries import settings as countries_settings register = coffin_template.Library() absolutize_urls = register.filter(absolutize_urls) TIMEZONE_STR = pytz.timezone(django_settings.TIME_ZONE).localize( datetime.datetime.now()).strftime('%z') @register.filter def add_tz_offset(datetime_object): return str(datetime_object) + ' ' + TIMEZONE_STR @register.filter def as_js_bool(some_object): if bool(some_object):