[v2,07/10] views: Populate 'project' attribute of PatchForm

Message ID 20181014124541.13393-8-stephen@that.guru
State New
Headers show
Series
  • Add labels support
Related show

Commit Message

Stephen Finucane Oct. 14, 2018, 12:45 p.m.
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@that.guru>
---
 patchwork/views/patch.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py
index 862dc83d..8e6cbcbd 100644
--- a/patchwork/views/patch.py
+++ b/patchwork/views/patch.py
@@ -54,7 +54,7 @@  def patch_detail(request, patch_id):
     createbundleform = None
 
     if editable:
-        form = PatchForm(instance=patch)
+        form = PatchForm(instance=patch, project=patch.project)
     if request.user.is_authenticated:
         createbundleform = CreateBundleForm()
 
@@ -91,7 +91,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')