Unverified Commit 4e9b7e32 authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Refactor bannerdir to fix import in docs

parent 29a71089
from django import template import functools
from django.contrib.staticfiles.templatetags.staticfiles import static
import os import os
import random import random
from django import template
from django.conf import settings
from django.contrib.staticfiles import finders
register = template.Library() register = template.Library()
banner_dir = static("/images/header_banners/") bannerdir = 'images/header_banners'
current_dir = [pic for pic in os.listdir("thaliawebsite/" + banner_dir)
if pic.endswith(".jpg")]
def _banners():
imgdir = finders.find(bannerdir)
return [pic for pic in os.listdir(imgdir) if pic.endswith('.jpg')]
@register.simple_tag @register.simple_tag
def pick_header_image(): def pick_header_image():
return banner_dir + random.choice(current_dir) """Renders a random header image"""
return settings.STATIC_URL + bannerdir + '/' + random.choice(_banners())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment