Add overlay badge support

Support so print can print only important text.

SVG modified to use display:inline/none based on overlay True/False and
a symlink to make it easy to change to a completely seperate svg if that
is not optimal.

SVG added layers to split text and graphic so graphics can be easily
hidden and printed.

Closes: #38
This commit is contained in:
Sachi King 2018-01-20 12:24:32 +11:00
parent a7b619a2fd
commit 763f69cb61
3 changed files with 6872 additions and 3187 deletions

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 404 KiB

After

Width:  |  Height:  |  Size: 480 KiB

View file

@ -0,0 +1 @@
badge.svg

View file

@ -1146,8 +1146,8 @@ def _convert_img(img, outformat="png",dpi=200,width=None):
stdout=subprocess.PIPE).stdout
return out
def render_badge(user, format="png"):
rendered = render_badge_svg(user)
def render_badge(user, format="png", overlay=False):
rendered = render_badge_svg(user, overlay=overlay)
if format == "png":
rendered = _convert_img(rendered, outformat="png")
elif format == "pdf":
@ -1167,14 +1167,20 @@ def render_badge(user, format="png"):
return response
def render_badge_svg(user):
def render_badge_svg(user, overlay=False):
''' Renders a single user's badge as SVG. '''
data = {
"user": user,
"overlay": overlay
}
t = loader.get_template('registrasion/badge.svg')
if overlay:
template = 'registrasion/badge_overlay.svg'
else:
template = 'registrasion/badge.svg'
t = loader.get_template(template)
return t.render(data)
def badges(request):