Tags app: Add explicit post action redirect for the tag attach and tag remove actions when working on a single document.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import absolute_import, unicode_literals
|
||||
import logging
|
||||
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.shortcuts import get_object_or_404, reverse
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _, ungettext
|
||||
|
||||
@@ -77,6 +77,13 @@ class TagAttachActionView(MultipleObjectFormActionView):
|
||||
|
||||
return result
|
||||
|
||||
def get_post_action_redirect(self):
|
||||
queryset = self.get_queryset()
|
||||
if queryset.count() == 1:
|
||||
return reverse('tags:document_tags', args=(queryset.first().pk,))
|
||||
else:
|
||||
return super(TagAttachActionView, self).get_post_action_redirect()
|
||||
|
||||
def object_action(self, form, instance):
|
||||
attached_tags = instance.attached_tags()
|
||||
|
||||
@@ -291,6 +298,13 @@ class TagRemoveActionView(MultipleObjectFormActionView):
|
||||
|
||||
return result
|
||||
|
||||
def get_post_action_redirect(self):
|
||||
queryset = self.get_queryset()
|
||||
if queryset.count() == 1:
|
||||
return reverse('tags:document_tags', args=(queryset.first().pk,))
|
||||
else:
|
||||
return super(TagRemoveActionView, self).get_post_action_redirect()
|
||||
|
||||
def object_action(self, form, instance):
|
||||
attached_tags = instance.attached_tags()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user