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:
Roberto Rosario
2018-08-17 04:16:06 -04:00
parent 076468a922
commit 3ca6595fe6
4 changed files with 98 additions and 2 deletions
+15 -1
View File
@@ -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()