Finish converting the tags app to user organizations.
This commit is contained in:
@@ -34,7 +34,7 @@ class APITagView(generics.RetrieveUpdateDestroyAPIView):
|
||||
'PATCH': (permission_tag_edit,),
|
||||
'PUT': (permission_tag_edit,)
|
||||
}
|
||||
queryset = Tag.objects.all()
|
||||
queryset = Tag.on_organization.all()
|
||||
serializer_class = TagSerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
@@ -71,7 +71,7 @@ class APITagListView(generics.ListCreateAPIView):
|
||||
mayan_object_permissions = {'GET': (permission_tag_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_tag_create,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = Tag.objects.all()
|
||||
queryset = Tag.on_organization.all()
|
||||
|
||||
def get_serializer_class(self):
|
||||
if self.request.method == 'GET':
|
||||
|
||||
@@ -40,7 +40,7 @@ class TagMultipleSelectionForm(forms.Form):
|
||||
logger.debug('user: %s', user)
|
||||
super(TagMultipleSelectionForm, self).__init__(*args, **kwargs)
|
||||
|
||||
queryset = Tag.objects.all()
|
||||
queryset = Tag.on_organization.all()
|
||||
try:
|
||||
Permission.check_permissions(user, (permission_tag_view,))
|
||||
except PermissionDenied:
|
||||
|
||||
@@ -48,7 +48,7 @@ class NewDocumentTagSerializer(serializers.Serializer):
|
||||
|
||||
def create(self, validated_data):
|
||||
try:
|
||||
tag = Tag.objects.get(pk=validated_data['tag'])
|
||||
tag = Tag.on_organization.get(pk=validated_data['tag'])
|
||||
|
||||
try:
|
||||
Permission.check_permissions(
|
||||
|
||||
@@ -8,6 +8,8 @@ from rest_framework.test import APITestCase
|
||||
|
||||
from documents.models import DocumentType
|
||||
from documents.tests import TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH
|
||||
from organizations.models import Organization
|
||||
from organizations.utils import create_default_organization
|
||||
from user_management.tests.literals import (
|
||||
TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME
|
||||
)
|
||||
@@ -26,6 +28,7 @@ class TagAPITestCase(APITestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
create_default_organization()
|
||||
self.admin_user = get_user_model().on_organization.create_superuser(
|
||||
username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL,
|
||||
password=TEST_ADMIN_PASSWORD
|
||||
@@ -37,6 +40,7 @@ class TagAPITestCase(APITestCase):
|
||||
|
||||
def tearDown(self):
|
||||
self.admin_user.delete()
|
||||
Organization.objects.clear_cache()
|
||||
|
||||
def test_tag_create(self):
|
||||
response = self.client.post(
|
||||
|
||||
@@ -42,10 +42,10 @@ class TagCreateView(SingleObjectCreateView):
|
||||
|
||||
def tag_attach(request, document_id=None, document_id_list=None):
|
||||
if document_id:
|
||||
queryset = Document.objects.filter(pk=document_id)
|
||||
queryset = Document.on_organization.filter(pk=document_id)
|
||||
post_action_redirect = reverse('tags:tag_list')
|
||||
elif document_id_list:
|
||||
queryset = Document.objects.filter(pk__in=document_id_list)
|
||||
queryset = Document.on_organization.filter(pk__in=document_id_list)
|
||||
|
||||
try:
|
||||
Permission.check_permissions(request.user, (permission_tag_attach,))
|
||||
@@ -282,9 +282,9 @@ class DocumentTagListView(TagListView):
|
||||
|
||||
def tag_remove(request, document_id=None, document_id_list=None, tag_id=None, tag_id_list=None):
|
||||
if document_id:
|
||||
documents = Document.objects.filter(pk=document_id)
|
||||
documents = Document.on_organization.filter(pk=document_id)
|
||||
elif document_id_list:
|
||||
documents = Document.objects.filter(pk__in=document_id_list)
|
||||
documents = Document.on_organization.filter(pk__in=document_id_list)
|
||||
|
||||
if not documents:
|
||||
messages.error(
|
||||
|
||||
Reference in New Issue
Block a user