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> 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"> <div class="dropdown-menu" aria-labelledby="timer-dropdown-menu-link">
{% if perms.core.add_timer %} {% 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 <i class="fa fa-plus" aria-hidden="true"></i> Create Timer
</a> </a>
{% if timers %} {% if timers %}

View File

@ -21,6 +21,7 @@ def timer_nav(context, active=True):
request = context['request'] or None request = context['request'] or None
timers = Timer.objects.filter(user=request.user, active=active) timers = Timer.objects.filter(user=request.user, active=active)
perms = context['perms'] or None perms = context['perms'] or None
# The 'next' parameter is currently not used.
return {'timers': timers, 'perms': perms, 'next': request.path} 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.core.urlresolvers import resolve
from django.contrib.auth.mixins import (LoginRequiredMixin, from django.contrib.auth.mixins import (LoginRequiredMixin,
PermissionRequiredMixin) PermissionRequiredMixin)
from django.urls import reverse
from django.views.generic.base import TemplateView, RedirectView from django.views.generic.base import TemplateView, RedirectView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views.generic.edit import CreateView, UpdateView, DeleteView
@ -185,7 +186,8 @@ class TimerAddQuick(PermissionRequiredMixin, RedirectView):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
instance = Timer.objects.create(user=request.user) instance = Timer.objects.create(user=request.user)
instance.save() 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) return super(TimerAddQuick, self).get(request, *args, **kwargs)