Refactors badge to have render_badge too.
This commit is contained in:
parent
c949a87b8a
commit
78714600bf
1 changed files with 14 additions and 6 deletions
|
@ -975,14 +975,22 @@ def badge(request, user_id):
|
|||
''' Renders a single user's badge (SVG). '''
|
||||
|
||||
user_id = int(user_id)
|
||||
user = User.objects.get(pk=user_id)
|
||||
|
||||
data = {
|
||||
"user": User.objects.get(pk=user_id),
|
||||
}
|
||||
|
||||
t = loader.get_template('registrasion/badge.svg')
|
||||
response = HttpResponse(t.render(data, request))
|
||||
rendered = render_badge(user)
|
||||
response = HttpResponse(rendered)
|
||||
|
||||
response["Content-Type"] = "image/svg+xml"
|
||||
response["Content-Disposition"] = 'inline; filename="badge.svg"'
|
||||
return response
|
||||
|
||||
|
||||
def render_badge(user):
|
||||
''' Renders a single user's badge. '''
|
||||
|
||||
data = {
|
||||
"user": user,
|
||||
}
|
||||
|
||||
t = loader.get_template('registrasion/badge.svg')
|
||||
return t.render(data)
|
||||
|
|
Loading…
Reference in a new issue