Merged in [16583] from rjsparks@nostrum.com:

Restore ability to remove documents while managing a personal list. Required updating code to match the recent change to Document's primary key. Fixes #2757.
 - Legacy-Id: 16608
Note: SVN reference [16583] has been migrated to Git commit 821609888a2c8a6db67867dd334103b034157d20
This commit is contained in:
Henrik Levkowetz 2019-08-01 14:27:00 +00:00
parent baa639ba01
commit b873af1eac
2 changed files with 4 additions and 4 deletions

View file

@ -123,7 +123,7 @@ class CommunityListTests(TestCase):
self.assertContains(r, draft.name)
# remove document
r = self.client.post(url, { "action": "remove_document", "document": draft.name })
r = self.client.post(url, { "action": "remove_document", "document": draft.pk })
self.assertEqual(r.status_code, 302)
clist = CommunityList.objects.get(user__username="plain")
self.assertTrue(not clist.added_docs.filter(pk=draft.pk))

View file

@ -67,9 +67,9 @@ def manage_list(request, username=None, acronym=None, group_type=None):
add_doc_form = AddDocumentsForm()
if request.method == 'POST' and action == 'remove_document':
document_name = request.POST.get('document')
if clist.pk is not None and document_name:
document = get_object_or_404(clist.added_docs, name=document_name)
document_id = request.POST.get('document')
if clist.pk is not None and document_id:
document = get_object_or_404(clist.added_docs, id=document_id)
clist.added_docs.remove(document)
return HttpResponseRedirect("")