-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert all templates and views to Jinja
- Loading branch information
1 parent
fe949e3
commit b0fc20f
Showing
44 changed files
with
212 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from django.template.context_processors import csrf | ||
from django.template.defaultfilters import ( | ||
cut, | ||
date, | ||
linebreaks, | ||
pluralize, | ||
slugify, | ||
truncatewords, | ||
urlencode, | ||
) | ||
from django.contrib.staticfiles.storage import staticfiles_storage | ||
from jinja2 import pass_context | ||
from jinja2.ext import Extension | ||
|
||
from wagtail.contrib.search_promotions.templatetags.wagtailsearchpromotions_tags import ( | ||
get_search_promotions, | ||
) | ||
|
||
from bakerydemo.base.templatetags.navigation_tags import ( | ||
breadcrumbs, | ||
get_footer_text, | ||
get_site_root, | ||
top_menu, | ||
top_menu_children, | ||
) | ||
from bakerydemo.base.templatetags.gallery_tags import gallery | ||
|
||
|
||
class BaseExtension(Extension): | ||
def __init__(self, environment): | ||
super().__init__(environment) | ||
self.environment.globals.update( | ||
{ | ||
"static": staticfiles_storage.url, | ||
"csrf": csrf, | ||
"get_search_promotions": get_search_promotions, | ||
"breadcrumbs": pass_context(breadcrumbs), | ||
"get_footer_text": pass_context(get_footer_text), | ||
"get_site_root": pass_context(get_site_root), | ||
"top_menu": top_menu, | ||
"top_menu_children": top_menu_children, | ||
"gallery": gallery, | ||
} | ||
) | ||
|
||
self.environment.filters.update( | ||
{ | ||
"cut": cut, | ||
"date": date, | ||
"linebreaks": linebreaks, | ||
"pluralize": pluralize, | ||
"slugify": slugify, | ||
"truncatewords": truncatewords, | ||
"urlencode": urlencode, | ||
} | ||
) | ||
|
||
|
||
base = BaseExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
from django import template | ||
from wagtail.images.models import Image | ||
|
||
register = template.Library() | ||
|
||
|
||
# Retrieves a single gallery item and returns a gallery of images | ||
@register.inclusion_tag("tags/gallery.html", takes_context=True) | ||
def gallery(context, gallery): | ||
def gallery(gallery): | ||
images = Image.objects.filter(collection=gallery) | ||
|
||
return { | ||
"images": images, | ||
"request": context["request"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{% extends "base.html" %} | ||
{% load wagtailcore_tags %} | ||
|
||
{% block content %} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.