Redirect to timer detail view instead of "next" on timer quick create.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-18 00:48:26 -04:00
parent 62a1142ad6
commit 8cb2c171f2
3 changed files with 5 additions and 2 deletions

View File

@ -6,7 +6,7 @@
aria-expanded="false"><i class="fa fa-clock-o" aria-hidden="true"></i> Timers</a>
<div class="dropdown-menu" aria-labelledby="timer-dropdown-menu-link">
{% if perms.core.add_timer %}
<a class="dropdown-item" href="{% url 'timer-add-quick' %}?next={{ next }}">
<a class="dropdown-item" href="{% url 'timer-add-quick' %}">
<i class="fa fa-plus" aria-hidden="true"></i> Create Timer
</a>
{% if timers %}

View File

@ -21,6 +21,7 @@ def timer_nav(context, active=True):
request = context['request'] or None
timers = Timer.objects.filter(user=request.user, active=active)
perms = context['perms'] or None
# The 'next' parameter is currently not used.
return {'timers': timers, 'perms': perms, 'next': request.path}

View File

@ -4,6 +4,7 @@ from __future__ import unicode_literals
from django.core.urlresolvers import resolve
from django.contrib.auth.mixins import (LoginRequiredMixin,
PermissionRequiredMixin)
from django.urls import reverse
from django.views.generic.base import TemplateView, RedirectView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView
@ -185,7 +186,8 @@ class TimerAddQuick(PermissionRequiredMixin, RedirectView):
def get(self, request, *args, **kwargs):
instance = Timer.objects.create(user=request.user)
instance.save()
self.url = request.GET.get('next', '/')
self.url = request.GET.get(
'next', reverse('timer-detail', args={instance.id}))
return super(TimerAddQuick, self).get(request, *args, **kwargs)