[PATCH 07/11] views: Populate 'project' attribute of PatchForm

Stephen Finucane stephen at that.guru
Mon Apr 16 08:54:01 AEST 2018


This is required to ensure we can filter delegates by project. If we
don't do this, our <select> gets stupid long, as seen in commit
198139e41.

Signed-off-by: Stephen Finucane <stephen at that.guru>
---
 patchwork/views/patch.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py
index 7e962e72..c1fccbc2 100644
--- a/patchwork/views/patch.py
+++ b/patchwork/views/patch.py
@@ -69,7 +69,7 @@ def patch_detail(request, patch_id):
     createbundleform = None
 
     if editable:
-        form = PatchForm(instance=patch)
+        form = PatchForm(instance=patch, project=patch.project)
     if is_authenticated(request.user):
         createbundleform = CreateBundleForm()
 
@@ -106,7 +106,8 @@ def patch_detail(request, patch_id):
             return HttpResponseForbidden()
 
         elif action is None:
-            form = PatchForm(data=request.POST, instance=patch)
+            form = PatchForm(data=request.POST, instance=patch,
+                             project=patch.project)
             if form.is_valid():
                 form.save()
                 messages.success(request, 'Patch updated')
-- 
2.14.3



More information about the Patchwork mailing list