[2/5] toaster: models Layer_Version get_detailspage_url optional project_id

Submitted by Michael Wood on Nov. 30, 2016, 3:25 p.m. | Patch ID: 134537

Details

Message ID 1480519521-8779-2-git-send-email-michael.g.wood@intel.com
State New
Headers show

Commit Message

Michael Wood Nov. 30, 2016, 3:25 p.m.
Allow passing none as the project id, this is convenient for layers
which belong to projects already and therefore have their own project
field.

Add documentation string to function

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
 bitbake/lib/toaster/orm/models.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index d420bfa..23d2ad0 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1473,7 +1473,13 @@  class Layer_Version(models.Model):
             return self.commit
         return 'N/A'
 
-    def get_detailspage_url(self, project_id):
+    def get_detailspage_url(self, project_id=None):
+        """ returns the url to the layer details page uses own project
+        field if project_id is not specified """
+
+        if project_id is None:
+            project_id = self.project.pk
+
         return reverse('layerdetails', args=(project_id, self.pk))
 
     def get_alldeps(self, project_id):