From 2f5eb409b632df5fe722739c59fc69fc5f5f54f7 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Wed, 8 Nov 2017 00:40:47 -0600 Subject: [PATCH] show computed fields in readonly mode in appadmin --- gluon/contrib/populate.py | 2 ++ gluon/packages/dal | 2 +- gluon/sqlhtml.py | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gluon/contrib/populate.py b/gluon/contrib/populate.py index 6977e8d5..26ef8aed 100644 --- a/gluon/contrib/populate.py +++ b/gluon/contrib/populate.py @@ -137,6 +137,8 @@ def populate_generator(table, default=True, compute=False, contents={}): continue elif field.type == 'upload': continue + elif field.compute is not None: + continue elif default and not field.default in (None, ''): record[fieldname] = field.default elif compute and field.compute: diff --git a/gluon/packages/dal b/gluon/packages/dal index f9f0fdfc..35dd4fc6 160000 --- a/gluon/packages/dal +++ b/gluon/packages/dal @@ -1 +1 @@ -Subproject commit f9f0fdfc9a9bedb40a191e5b85b44cb08c672f17 +Subproject commit 35dd4fc6f8fb8187e7c08217eebf3074e0d27fbc diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index c4095e44..afb2279e 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -1244,8 +1244,8 @@ class SQLFORM(FORM): # will only use writable or readable fields, unless forced to ignore if fields is None: fields = [f.name for f in table if - (ignore_rw or f.writable or f.readable) and - (readonly or not f.compute)] + (ignore_rw or f.writable or f.readable) and + not (f.compute and not record)] self.fields = fields # make sure we have an id @@ -1328,7 +1328,7 @@ class SQLFORM(FORM): label = LABEL(label, label and sep, _for=field_id, _id=field_id + SQLFORM.ID_LABEL_SUFFIX) - cond = readonly or \ + cond = readonly or field.compute or \ (not ignore_rw and not field.writable and field.readable) if cond: