Added guards against duplicate m2m entries.

- Legacy-Id: 16304
This commit is contained in:
Henrik Levkowetz 2019-06-25 11:01:25 +00:00
parent 32a06473bb
commit f5f838ddf8
2 changed files with 14 additions and 7 deletions

View file

@ -87,6 +87,7 @@ class CommunityListTests(TestCase):
# with list
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
if not draft in clist.added_docs.all():
clist.added_docs.add(draft)
SearchRule.objects.create(
community_list=clist,
@ -249,6 +250,7 @@ class CommunityListTests(TestCase):
# with list
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
if not draft in clist.added_docs.all():
clist.added_docs.add(draft)
SearchRule.objects.create(
community_list=clist,
@ -284,6 +286,7 @@ class CommunityListTests(TestCase):
# with list
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
if not draft in clist.added_docs.all():
clist.added_docs.add(draft)
SearchRule.objects.create(
community_list=clist,
@ -325,6 +328,7 @@ class CommunityListTests(TestCase):
# subscription with list
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
if not draft in clist.added_docs.all():
clist.added_docs.add(draft)
SearchRule.objects.create(
community_list=clist,
@ -368,6 +372,7 @@ class CommunityListTests(TestCase):
draft = WgDraftFactory()
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
if not draft in clist.added_docs.all():
clist.added_docs.add(draft)
EmailSubscription.objects.create(community_list=clist, email=Email.objects.filter(person__user__username="plain").first(), notify_on="significant")

View file

@ -53,6 +53,7 @@ def manage_list(request, username=None, acronym=None, group_type=None):
clist.save()
for d in add_doc_form.cleaned_data['documents']:
if not d in clist.added_docs.all():
clist.added_docs.add(d)
return HttpResponseRedirect("")
@ -130,6 +131,7 @@ def track_document(request, name, username=None, acronym=None):
if clist.pk is None:
clist.save()
if not doc in clist.added_docs.all():
clist.added_docs.add(doc)
if request.is_ajax():