[PATCH v2 2/6] models: Add Bundle.is_editable function

Stephen Finucane stephen at that.guru
Wed Mar 8 06:22:42 AEDT 2017


We'll use this for the REST API.

Signed-off-by: Stephen Finucane <stephen at that.guru>
Cc: Daniel Axtens <dja at axtens.net>
---
 patchwork/models.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/patchwork/models.py b/patchwork/models.py
index 94aaa0f..cfe5b51 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -734,6 +734,11 @@ class Bundle(models.Model):
                                             'bundlename': self.name
                                         }))
 
+    def is_editable(self, user):
+        if not user.is_authenticated():
+            return False
+        return user == self.owner
+
     @models.permalink
     def get_absolute_url(self):
         return ('bundle-detail', (), {
-- 
2.9.3



More information about the Patchwork mailing list