Simpler navigation

This commit is contained in:
Pēteris Caune 2015-07-08 00:00:22 +03:00
parent 3c57e4026a
commit 3eaff7d596
9 changed files with 26 additions and 29 deletions

View File

@ -79,6 +79,6 @@ def check_token(request, username, token):
user.set_unusable_password() user.set_unusable_password()
user.save() user.save()
auth_login(request, user) auth_login(request, user)
return redirect("hc-checks") return redirect("hc-index")
return render(request, "bad_link.html") return render(request, "bad_link.html")

View File

@ -4,7 +4,6 @@ from hc.front import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.index, name="hc-index"), 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/add/$', views.add_check, name="hc-add-check"),
url(r'^checks/([\w-]+)/name/$', views.update_name, name="hc-update-name"), url(r'^checks/([\w-]+)/name/$', views.update_name, name="hc-update-name"),
url(r'^checks/([\w-]+)/timeout/$', views.update_timeout, name="hc-update-timeout"), url(r'^checks/([\w-]+)/timeout/$', views.update_timeout, name="hc-update-timeout"),

View File

@ -7,7 +7,7 @@ from hc.api.models import Check
from hc.front.forms import TimeoutForm, TIMEOUT_CHOICES from hc.front.forms import TimeoutForm, TIMEOUT_CHOICES
def index(request): def _welcome(request):
if "welcome_code" not in request.session: if "welcome_code" not in request.session:
check = Check() check = Check()
check.save() check.save()
@ -26,40 +26,44 @@ def index(request):
timer_formatted = "Never" timer_formatted = "Never"
ctx = { ctx = {
"page": "welcome",
"check": check, "check": check,
"timer": timer, "timer": timer,
"timer_formatted": timer_formatted, "timer_formatted": timer_formatted,
"ping_url": check.url() "ping_url": check.url()
} }
return render(request, "index.html", ctx) return render(request, "front/welcome.html", ctx)
def pricing(request): def _my_checks(request):
return render(request, "pricing.html", {"page": "pricing"})
def docs(request):
return render(request, "docs.html", {"page": "docs"})
def about(request):
return render(request, "about.html", {"page": "about"})
@login_required
def checks(request):
checks = Check.objects.filter(user=request.user).order_by("created") checks = Check.objects.filter(user=request.user).order_by("created")
ctx = { ctx = {
"checks": checks, "checks": checks,
"now": timezone.now, "now": timezone.now,
"timeout_choices": TIMEOUT_CHOICES, "timeout_choices": TIMEOUT_CHOICES
"page": "checks"
} }
return render(request, "front/index.html", ctx) return render(request, "front/my_checks.html", ctx)
def index(request):
if request.user.is_authenticated():
return _my_checks(request)
else:
return _welcome(request)
def pricing(request):
return render(request, "front/pricing.html", {"page": "pricing"})
def docs(request):
return render(request, "front/docs.html", {"page": "docs"})
def about(request):
return render(request, "front/about.html", {"page": "about"})
@login_required @login_required

View File

@ -19,12 +19,6 @@
</div> </div>
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
{% if request.user.is_authenticated %}
<li {% if page == 'checks' %} class="active" {% endif %}>
<a href="{% url 'hc-checks' %}">My Checks</a>
</li>
{% endif %}
<li {% if page == 'pricing' %} class="active" {% endif %}> <li {% if page == 'pricing' %} class="active" {% endif %}>
<a href="{% url 'hc-pricing' %}">Pricing</a> <a href="{% url 'hc-pricing' %}">Pricing</a>
</li> </li>

View File

@ -8,7 +8,7 @@
<div class="col-sm-12"> <div class="col-sm-12">
<h3>Summary</h3> <h3>Summary</h3>
<p> <p>
Each check you create in <a href="{% url 'hc-checks' %}">My Checks</a> Each check you create in <a href="{% url 'hc-index' %}">My Checks</a>
page has an unique "ping" URL. Whenever you access this URL, page has an unique "ping" URL. Whenever you access this URL,
the "Last Ping" value of corresponding check is updated. the "Last Ping" value of corresponding check is updated.
</p> </p>