fix tagmember visibility
This commit is contained in:
parent
98a4f0e9cb
commit
e31c102f53
3 changed files with 2 additions and 38 deletions
|
@ -20,7 +20,7 @@ from users.views import login
|
|||
from common.api import api
|
||||
|
||||
urlpatterns = [
|
||||
path("api/", api.urls),
|
||||
path("api/", api.urls), # type: ignore
|
||||
path("login/", login),
|
||||
path("markdownx/", include("markdownx.urls")),
|
||||
path("users/", include("users.urls")),
|
||||
|
|
|
@ -1019,7 +1019,7 @@ class TagManager:
|
|||
tag = Tag.objects.create(
|
||||
owner=user, title=title, visibility=default_visibility
|
||||
)
|
||||
tag.append_item(item)
|
||||
tag.append_item(item, visibility=default_visibility)
|
||||
for title in current_titles - titles:
|
||||
tag = Tag.objects.filter(owner=user, title=title).first()
|
||||
tag.remove_item(item)
|
||||
|
@ -1031,16 +1031,6 @@ class TagManager:
|
|||
]
|
||||
return current_titles
|
||||
|
||||
@staticmethod
|
||||
def add_tag_by_user(item, tag_title, user, default_visibility=0):
|
||||
title = Tag.cleanup_title(tag_title)
|
||||
tag = Tag.objects.filter(owner=user, title=title).first()
|
||||
if not tag:
|
||||
tag = Tag.objects.create(
|
||||
owner=user, title=title, visibility=default_visibility
|
||||
)
|
||||
tag.append_item(item)
|
||||
|
||||
@staticmethod
|
||||
def get_manager_for_user(user):
|
||||
return TagManager(user)
|
||||
|
@ -1056,10 +1046,6 @@ class TagManager:
|
|||
def public_tags(self):
|
||||
return TagManager.all_tags_for_user(self.owner, public_only=True)
|
||||
|
||||
def add_item_tags(self, item, tags, visibility=0):
|
||||
for tag in tags:
|
||||
TagManager.add_tag_by_user(item, tag, self.owner, visibility)
|
||||
|
||||
def get_item_tags(self, item):
|
||||
return sorted(
|
||||
[
|
||||
|
|
|
@ -116,28 +116,6 @@ class TagTest(TestCase):
|
|||
TagManager.tag_item_by_user(self.book1, self.user2, [t2, t3])
|
||||
self.assertEqual(self.book1.tags, [t2, t3])
|
||||
|
||||
def test_tag(self):
|
||||
t1 = "tag 1"
|
||||
t2 = "tag 2"
|
||||
t3 = "tag 3"
|
||||
TagManager.add_tag_by_user(self.book1, t3, self.user2)
|
||||
TagManager.add_tag_by_user(self.book1, t1, self.user1)
|
||||
TagManager.add_tag_by_user(self.book1, t1, self.user2)
|
||||
self.assertEqual(self.book1.tags, [t1, t3])
|
||||
TagManager.add_tag_by_user(self.book1, t2, self.user1, default_visibility=2)
|
||||
self.assertEqual(self.book1.tags, [t1, t3])
|
||||
TagManager.add_tag_by_user(self.book1, t3, self.user1)
|
||||
TagManager.add_tag_by_user(self.book1, t3, self.user3)
|
||||
self.assertEqual(self.book1.tags, [t1, t3])
|
||||
TagManager.add_tag_by_user(self.book1, t3, self.user3)
|
||||
TagManager.add_tag_by_user(self.book1, t3, self.user3)
|
||||
self.assertEqual(Tag.objects.count(), 6)
|
||||
TagManager.add_tag_by_user(self.book2, t1, self.user2)
|
||||
self.assertEqual(self.user2.tags, [t1, t3])
|
||||
TagManager.add_tag_by_user(self.book2, t3, self.user2)
|
||||
TagManager.add_tag_by_user(self.movie1, t3, self.user2)
|
||||
self.assertEqual(sorted(self.user2.tags), [t1, t3])
|
||||
|
||||
|
||||
class MarkTest(TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue