Files
@ 1ba1a97c4555
Branch filter:
Location: symposion_app/pinaxcon/templatetags/lca2017_tags.py - annotation
1ba1a97c4555
2.5 KiB
text/x-python
move templates out of vendor specific locations
Lets not kid ourselves. The whole apps templates are client specific.
Lets just remove that and not think it isn't.
Lets not kid ourselves. The whole apps templates are client specific.
Lets just remove that and not think it isn't.
ff16f71df6e8 ff16f71df6e8 a3474fd9cd4c e6c623a69ca9 a3474fd9cd4c ff16f71df6e8 ff16f71df6e8 a3474fd9cd4c 0eda616345b9 ff16f71df6e8 a3474fd9cd4c ff16f71df6e8 e6c623a69ca9 e6c623a69ca9 ff16f71df6e8 e6c623a69ca9 e6c623a69ca9 e6c623a69ca9 ecabf31e54b9 ff16f71df6e8 ecabf31e54b9 ecabf31e54b9 ecabf31e54b9 ecabf31e54b9 ff16f71df6e8 ecabf31e54b9 ecabf31e54b9 ecabf31e54b9 ecabf31e54b9 ff16f71df6e8 ecabf31e54b9 ecabf31e54b9 ecabf31e54b9 ecabf31e54b9 ff16f71df6e8 ff16f71df6e8 8d68cca01f87 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 8d68cca01f87 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 39b556b7ac4f 39b556b7ac4f 39b556b7ac4f ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 5be0c8be19f7 5be0c8be19f7 5be0c8be19f7 5be0c8be19f7 5be0c8be19f7 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 ff16f71df6e8 a3474fd9cd4c a3474fd9cd4c a3474fd9cd4c a3474fd9cd4c a3474fd9cd4c a3474fd9cd4c a3474fd9cd4c a3474fd9cd4c a3474fd9cd4c 0eda616345b9 39b556b7ac4f 0eda616345b9 0eda616345b9 0eda616345b9 0eda616345b9 0eda616345b9 0eda616345b9 0eda616345b9 | import hashlib
from decimal import Decimal
from django import template
from django.conf import settings
from django.contrib.staticfiles.templatetags import staticfiles
from easy_thumbnails.files import get_thumbnailer
from symposion.conference import models as conference_models
from symposion.schedule.models import Track
CONFERENCE_ID = settings.CONFERENCE_ID
register = template.Library()
@register.assignment_tag()
def classname(ob):
return ob.__class__.__name__
@register.simple_tag(takes_context=True)
def can_manage(context, proposal):
return proposal_permission(context, "manage", proposal)
@register.simple_tag(takes_context=True)
def can_review(context, proposal):
return proposal_permission(context, "review", proposal)
def proposal_permission(context, permname, proposal):
slug = proposal.kind.section.slug
perm = "reviews.can_%s_%s" % (permname, slug)
return context.request.user.has_perm(perm)
# {% load statictags %}{% static 'pyconau2017/images/svgs/illustrations/' %}{{ illustration }}
@register.simple_tag(takes_context=False)
def illustration(name):
return staticfiles.static('pyconau2017/images/svgs/illustrations/') + name
@register.simple_tag(takes_context=True)
def speaker_photo(context, speaker, size):
''' Provides the speaker profile, or else fall back to libravatar or gravatar. '''
if speaker.photo:
thumbnailer = get_thumbnailer(speaker.photo)
thumbnail_options = {'crop': True, 'size': (size, size)}
thumbnail = thumbnailer.get_thumbnail(thumbnail_options)
return thumbnail.url
else:
email = speaker.user.email.encode("utf-8")
md5sum = hashlib.md5(email.strip().lower()).hexdigest()
fallback_image = ("https://linux.conf.au/site_media/static/lca2017"
"/images/speaker-fallback-devil.jpg")
url = "https://secure.gravatar.com/avatar/%s?s=%d&d=%s" % (md5sum, size, fallback_image)
return url
@register.simple_tag()
def define(value):
return value
@register.simple_tag()
def presentation_bg_number(presentation, count):
return sum(ord(i) for i in presentation.title) % count
@register.filter()
def gst(amount):
two_places = Decimal(10) ** -2
return Decimal(amount / 11).quantize(two_places)
@register.simple_tag()
def conference_name():
return conference_models.Conference.objects.get(id=CONFERENCE_ID).title
@register.filter()
def trackname(room, day):
try:
track_name = room.track_set.get(day=day).name
except Track.DoesNotExist:
track_name = None
return track_name
|