From 3eaff7d596c466fa643188646c8a81f88168f6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Wed, 8 Jul 2015 00:00:22 +0300 Subject: [PATCH] Simpler navigation --- hc/accounts/views.py | 2 +- hc/front/urls.py | 1 - hc/front/views.py | 42 ++++++++++--------- templates/base.html | 6 --- templates/{ => front}/about.html | 0 templates/{ => front}/docs.html | 2 +- .../front/{index.html => my_checks.html} | 0 templates/{ => front}/pricing.html | 0 templates/{index.html => front/welcome.html} | 0 9 files changed, 25 insertions(+), 28 deletions(-) rename templates/{ => front}/about.html (100%) rename templates/{ => front}/docs.html (95%) rename templates/front/{index.html => my_checks.html} (100%) rename templates/{ => front}/pricing.html (100%) rename templates/{index.html => front/welcome.html} (100%) diff --git a/hc/accounts/views.py b/hc/accounts/views.py index 5a789087..501973cf 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -79,6 +79,6 @@ def check_token(request, username, token): user.set_unusable_password() user.save() auth_login(request, user) - return redirect("hc-checks") + return redirect("hc-index") return render(request, "bad_link.html") diff --git a/hc/front/urls.py b/hc/front/urls.py index c7f2fc58..4d029112 100644 --- a/hc/front/urls.py +++ b/hc/front/urls.py @@ -4,7 +4,6 @@ from hc.front import views urlpatterns = [ url(r'^$', views.index, name="hc-index"), - url(r'^checks/$', views.checks, name="hc-checks"), url(r'^checks/add/$', views.add_check, name="hc-add-check"), url(r'^checks/([\w-]+)/name/$', views.update_name, name="hc-update-name"), url(r'^checks/([\w-]+)/timeout/$', views.update_timeout, name="hc-update-timeout"), diff --git a/hc/front/views.py b/hc/front/views.py index e008f881..8f8b9a7f 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -7,7 +7,7 @@ from hc.api.models import Check from hc.front.forms import TimeoutForm, TIMEOUT_CHOICES -def index(request): +def _welcome(request): if "welcome_code" not in request.session: check = Check() check.save() @@ -26,40 +26,44 @@ def index(request): timer_formatted = "Never" ctx = { - "page": "welcome", "check": check, "timer": timer, "timer_formatted": timer_formatted, "ping_url": check.url() } - return render(request, "index.html", ctx) + return render(request, "front/welcome.html", ctx) -def pricing(request): - return render(request, "pricing.html", {"page": "pricing"}) +def _my_checks(request): + checks = Check.objects.filter(user=request.user).order_by("created") + ctx = { + "checks": checks, + "now": timezone.now, + "timeout_choices": TIMEOUT_CHOICES + } -def docs(request): - return render(request, "docs.html", {"page": "docs"}) + return render(request, "front/my_checks.html", ctx) -def about(request): - return render(request, "about.html", {"page": "about"}) +def index(request): + if request.user.is_authenticated(): + return _my_checks(request) + else: + return _welcome(request) -@login_required -def checks(request): - checks = Check.objects.filter(user=request.user).order_by("created") +def pricing(request): + return render(request, "front/pricing.html", {"page": "pricing"}) - ctx = { - "checks": checks, - "now": timezone.now, - "timeout_choices": TIMEOUT_CHOICES, - "page": "checks" - } - return render(request, "front/index.html", ctx) +def docs(request): + return render(request, "front/docs.html", {"page": "docs"}) + + +def about(request): + return render(request, "front/about.html", {"page": "about"}) @login_required diff --git a/templates/base.html b/templates/base.html index 27a61f2e..5d4e9f63 100644 --- a/templates/base.html +++ b/templates/base.html @@ -19,12 +19,6 @@