Set ref in form if user already has one

This commit is contained in:
Sebastian Lohff 2017-01-26 18:52:27 +01:00
parent ac59a532c4
commit 94739d3508
1 changed files with 4 additions and 1 deletions

View File

@ -148,7 +148,10 @@ def updateRef(request, shadow, uid):
messages.success(request, "%s%s ref set to %s" % ("(shadow) " if shadow else "", user, ref)) messages.success(request, "%s%s ref set to %s" % ("(shadow) " if shadow else "", user, ref))
return HttpResponseRedirect(reverse("contest:registerRefs")) return HttpResponseRedirect(reverse("contest:registerRefs"))
else: else:
form = UpdateRefForm() data = {}
if user.ref:
data["existingRef"] = user.ref
form = UpdateRefForm(initial=data)
return render(request, 'contest/updateRef.html', {'userobj': user, 'form': form, "shadow": shadow}) return render(request, 'contest/updateRef.html', {'userobj': user, 'form': form, "shadow": shadow})