From a64bc61810ed3b67ed36073e69b894cf679e3f01 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 29 Jan 2019 04:27:50 -0400 Subject: [PATCH] Allow defining SourceColumns without attributes SourceColums that don't specify an attibute or function will receive the instance itself instead. Signed-off-by: Roberto Rosario --- mayan/apps/navigation/classes.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mayan/apps/navigation/classes.py b/mayan/apps/navigation/classes.py index b6ec8f9e50..a009827667 100644 --- a/mayan/apps/navigation/classes.py +++ b/mayan/apps/navigation/classes.py @@ -578,10 +578,6 @@ class SourceColumn(object): self.label = None self.views = views or [] self.widget = widget - if not attribute and not func: - raise NavigationError( - 'Must provide either an attribute or a function' - ) self._calculate_label() @@ -636,11 +632,13 @@ class SourceColumn(object): if self.attribute: result = resolve_attribute( - obj=context['object'], attribute=self.attribute, - kwargs=self.kwargs + attribute=self.attribute, kwargs=self.kwargs, + obj=context['object'] ) elif self.func: result = self.func(context=context, **self.kwargs) + else: + result = context['object'] if self.widget: widget_instance = self.widget()