forked from GithubBackups/healthchecks
Merge pull request #29 from BetterWorks/fixDocsPage
fix docs page crashing if welcome code is expired
This commit is contained in:
commit
29df1be80c
@ -55,10 +55,7 @@ def my_checks(request):
|
|||||||
return render(request, "front/my_checks.html", ctx)
|
return render(request, "front/my_checks.html", ctx)
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def _welcome_check(request):
|
||||||
if request.user.is_authenticated():
|
|
||||||
return redirect("hc-checks")
|
|
||||||
|
|
||||||
check = None
|
check = None
|
||||||
if "welcome_code" in request.session:
|
if "welcome_code" in request.session:
|
||||||
code = request.session["welcome_code"]
|
code = request.session["welcome_code"]
|
||||||
@ -67,8 +64,16 @@ def index(request):
|
|||||||
if check is None:
|
if check is None:
|
||||||
check = Check()
|
check = Check()
|
||||||
check.save()
|
check.save()
|
||||||
code = str(check.code)
|
request.session["welcome_code"] = str(check.code)
|
||||||
request.session["welcome_code"] = code
|
|
||||||
|
return check
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
if request.user.is_authenticated():
|
||||||
|
return redirect("hc-checks")
|
||||||
|
|
||||||
|
check = _welcome_check(request)
|
||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
"page": "welcome",
|
"page": "welcome",
|
||||||
@ -80,11 +85,7 @@ def index(request):
|
|||||||
|
|
||||||
|
|
||||||
def docs(request):
|
def docs(request):
|
||||||
if "welcome_code" in request.session:
|
check = _welcome_check(request)
|
||||||
code = request.session["welcome_code"]
|
|
||||||
check = Check.objects.get(code=code)
|
|
||||||
else:
|
|
||||||
check = Check(code="uuid-goes-here")
|
|
||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
"page": "docs",
|
"page": "docs",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user