Added guards against duplicate m2m entries.
- Legacy-Id: 16304
This commit is contained in:
parent
32a06473bb
commit
f5f838ddf8
|
@ -87,7 +87,8 @@ class CommunityListTests(TestCase):
|
|||
|
||||
# with list
|
||||
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
|
||||
clist.added_docs.add(draft)
|
||||
if not draft in clist.added_docs.all():
|
||||
clist.added_docs.add(draft)
|
||||
SearchRule.objects.create(
|
||||
community_list=clist,
|
||||
rule_type="name_contains",
|
||||
|
@ -249,7 +250,8 @@ class CommunityListTests(TestCase):
|
|||
|
||||
# with list
|
||||
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
|
||||
clist.added_docs.add(draft)
|
||||
if not draft in clist.added_docs.all():
|
||||
clist.added_docs.add(draft)
|
||||
SearchRule.objects.create(
|
||||
community_list=clist,
|
||||
rule_type="name_contains",
|
||||
|
@ -284,7 +286,8 @@ class CommunityListTests(TestCase):
|
|||
|
||||
# with list
|
||||
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
|
||||
clist.added_docs.add(draft)
|
||||
if not draft in clist.added_docs.all():
|
||||
clist.added_docs.add(draft)
|
||||
SearchRule.objects.create(
|
||||
community_list=clist,
|
||||
rule_type="name_contains",
|
||||
|
@ -325,7 +328,8 @@ class CommunityListTests(TestCase):
|
|||
|
||||
# subscription with list
|
||||
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
|
||||
clist.added_docs.add(draft)
|
||||
if not draft in clist.added_docs.all():
|
||||
clist.added_docs.add(draft)
|
||||
SearchRule.objects.create(
|
||||
community_list=clist,
|
||||
rule_type="name_contains",
|
||||
|
@ -368,7 +372,8 @@ class CommunityListTests(TestCase):
|
|||
draft = WgDraftFactory()
|
||||
|
||||
clist = CommunityList.objects.create(user=User.objects.get(username="plain"))
|
||||
clist.added_docs.add(draft)
|
||||
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")
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ def manage_list(request, username=None, acronym=None, group_type=None):
|
|||
clist.save()
|
||||
|
||||
for d in add_doc_form.cleaned_data['documents']:
|
||||
clist.added_docs.add(d)
|
||||
if not d in clist.added_docs.all():
|
||||
clist.added_docs.add(d)
|
||||
|
||||
return HttpResponseRedirect("")
|
||||
else:
|
||||
|
@ -130,7 +131,8 @@ def track_document(request, name, username=None, acronym=None):
|
|||
if clist.pk is None:
|
||||
clist.save()
|
||||
|
||||
clist.added_docs.add(doc)
|
||||
if not doc in clist.added_docs.all():
|
||||
clist.added_docs.add(doc)
|
||||
|
||||
if request.is_ajax():
|
||||
return HttpResponse(json.dumps({ 'success': True }), content_type='text/plain')
|
||||
|
|
Loading…
Reference in a new issue