Use waffl to be able to flip overlay on/off

This commit is contained in:
James Polley 2018-01-21 00:53:02 +11:00
parent a8551e999c
commit ac8df2da28

View file

@ -36,6 +36,7 @@ from django.http import Http404, HttpResponse
from django.shortcuts import redirect
from django.shortcuts import render
from django.template import Context, Template, loader
import waffle
from lxml import etree
from copy import deepcopy
@ -1116,11 +1117,11 @@ def _get_badge_template_name():
@login_required
def user_badge(request, format="png"):
'''Shows the logged-in user their badge'''
if waffle.flag_is_active("force_badge_overlay"):
if waffle.flag_is_active(request, "force_badge_overlay"):
overlay=True
else:
overlay=False
return render_badge(request.user, format, overlay)
return render_badge(request.user, format, overlay, request)
@user_passes_test(_staff_only)
def badge(request, user_id, format="png"):
@ -1149,8 +1150,8 @@ def _convert_img(img, outformat="png",dpi=200,width=None):
stdout=subprocess.PIPE).stdout
return out
def render_badge(user, format="png", overlay=False):
if waffle.flag_is_active("force_badge_overlay"):
def render_badge(user, format="png", overlay=False, request=None):
if request and waffle.flag_is_active(request, "force_badge_overlay"):
overlay=True
rendered = render_badge_svg(user, overlay=overlay)
if format == "png":