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
from django.contrib.staticfiles.templatetags.staticfiles import static
import functools
import os
import random
from django import template
from django.conf import settings
from django.contrib.staticfiles import finders
register = template.Library()
banner_dir = static("/images/header_banners/")
current_dir = [pic for pic in os.listdir("thaliawebsite/" + banner_dir)
if pic.endswith(".jpg")]
bannerdir = 'images/header_banners'
def _banners():
imgdir = finders.find(bannerdir)
return [pic for pic in os.listdir(imgdir) if pic.endswith('.jpg')]
def pick_header_image():
return banner_dir + random.choice(current_dir)
"""Renders a random header image"""
return settings.STATIC_URL + bannerdir + '/' + random.choice(_banners())
Supports Markdown
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