From b9bfee9615307caa30dcff98bb79b6497d5db572 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Sat, 5 Apr 2014 09:49:54 +0200 Subject: [PATCH] [gen] Ref field: more work on global actions. --- fields/__init__.py | 7 ++++ fields/ref.py | 88 ++++++++++++++++++++++++++-------------------- gen/tr/Appy.pot | 4 +++ gen/tr/ar.po | 4 +++ gen/tr/de.po | 4 +++ gen/tr/en.po | 4 +++ gen/tr/es.po | 4 +++ gen/tr/fr.po | 4 +++ gen/tr/it.po | 4 +++ gen/tr/nl.po | 4 +++ 10 files changed, 89 insertions(+), 38 deletions(-) diff --git a/fields/__init__.py b/fields/__init__.py index b779cae..7acc4d7 100644 --- a/fields/__init__.py +++ b/fields/__init__.py @@ -685,6 +685,13 @@ class Field: obj.log(sutils.Traceback.get(), type='error') raise e + def getAttribute(self, obj, name): + '''Gets the value of attribue p_name on p_self, which can be a simple + value or the result of a method call on p_obj.''' + res = getattr(self, name) + if not callable(res): return res + return self.callMethod(obj, res) + def process(self, obj): '''This method is a general hook allowing a field to perform some processing after an URL on an object has been called, of the form diff --git a/fields/ref.py b/fields/ref.py index 670b948..e3e066f 100644 --- a/fields/ref.py +++ b/fields/ref.py @@ -277,7 +277,8 @@ class Ref(Field): (q(ajaxHookId), q(zobj.absolute_url()), \ q(field.name), q(innerRef)); changeOrder=False; - checkboxes=field.checkboxesEnabled(zobj) and (totalNumber > 1); + checkboxes=field.getAttribute(zobj, 'checkboxes') and \ + (totalNumber > 1); showSubTitles=showSubTitles|\ req.get('showSubTitles', 'true') == 'true'; subLabel='selectable_objects'">:field.pxViewList''') @@ -341,8 +342,8 @@ class Ref(Field): navBaseCall='askRefField(%s,%s,%s,%s,**v**)' % \ (q(ajaxHookId), q(zobj.absolute_url()), \ q(field.name), q(innerRef)); - changeOrder=field.changeOrderEnabled(zobj); - checkboxesEnabled=field.checkboxesEnabled(zobj); + changeOrder=field.getAttribute(zobj, 'changeOrder'); + checkboxesEnabled=field.getAttribute(zobj, 'checkboxes'); checkboxes=checkboxesEnabled and (totalNumber > 1); showSubTitles=req.get('showSubTitles', 'true') == 'true'">