From 0b96f9d28781fd224c1e51d3102cce5da25fd8be Mon Sep 17 00:00:00 2001 From: Jim Steil Date: Sun, 8 Aug 2021 14:19:45 -0500 Subject: [PATCH 1/4] allow removing extra auth_user fields from register page --- py4web/utils/auth.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/py4web/utils/auth.py b/py4web/utils/auth.py index 1c5ccbc88..e1faee483 100644 --- a/py4web/utils/auth.py +++ b/py4web/utils/auth.py @@ -198,6 +198,7 @@ def __init__( messages=copy.deepcopy(self.MESSAGES), button_classes=copy.deepcopy(self.BUTTON_CLASSES), default_login_enabled=True, + exclude_extra_fields_in_register=None, ) """Creates and Auth object responsible for handling @@ -782,7 +783,6 @@ def enable(self, route="auth", uses=(), env=None, spa=False): for group in self.param.messages.values(): for key, value in group.items(): group[key] = T(value) - def allowed(name): return set(self.param.allowed_actions) & set(["all", name]) @@ -1039,6 +1039,12 @@ def formstyle(self): def register(self): self.auth.db.auth_user.password.writable = True fields = [field for field in self.auth.db.auth_user if field.writable] + if self.auth.param.exclude_extra_fields_in_register: + fields = [ + field + for field in fields + if field.name not in self.auth.param.exclude_extra_fields_in_register + ] for k, field in enumerate(fields): if field.type == "password": fields.insert( From 7e274cf27c0f07e51127a3f9eddfbb820d75ac4d Mon Sep 17 00:00:00 2001 From: Jim Steil Date: Mon, 9 Aug 2021 07:55:35 -0500 Subject: [PATCH 2/4] allow removing extra auth_user fields from profile page --- py4web/utils/auth.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/py4web/utils/auth.py b/py4web/utils/auth.py index e1faee483..f97aed8c6 100644 --- a/py4web/utils/auth.py +++ b/py4web/utils/auth.py @@ -199,6 +199,7 @@ def __init__( button_classes=copy.deepcopy(self.BUTTON_CLASSES), default_login_enabled=True, exclude_extra_fields_in_register=None, + exclude_extra_fields_in_profile=None, ) """Creates and Auth object responsible for handling @@ -1296,6 +1297,12 @@ def profile(self): self.auth.db.auth_user.username.writable = False else: self.auth.db.auth_user.email.writable = False + if self.auth.param.exclude_extra_fields_in_profile: + for field in self.auth.extra_auth_user_fields: + if field.name in self.auth.param.exclude_extra_fields_in_profile: + field.writable = False + field.readable = False + form = Form( self.auth.db.auth_user, user, From d29f3110f8dba50184a99fdc9e623bc7287cc9b8 Mon Sep 17 00:00:00 2001 From: jarrodwilcox Date: Mon, 9 Aug 2021 09:25:51 -0400 Subject: [PATCH 3/4] Update chapter-01.rst Edited by Jarrod Wilcox for typos, punctuation and minor grammar. --- docs/chapter-01.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/chapter-01.rst b/docs/chapter-01.rst index 8c29aebcd..3dbcef08d 100644 --- a/docs/chapter-01.rst +++ b/docs/chapter-01.rst @@ -4,15 +4,15 @@ What is py4web? PY4WEB is a web framework for rapid development of efficient database driven web applications. It is an evolution of the popular web2py -framework but much faster and slicker. Its internal design has been much +framework, but much faster and slicker. Its internal design has been much simplified compared to web2py. PY4WEB can be seen as a competitor of other frameworks like Django or Flask, and it can indeed serve the same purpose. Yet PY4WEB aims to -provide a larger feature set out of the box and reduce the development +provide a larger feature set out of the box and to reduce the development time of new apps. -From a historical perspective our story starts in 2007 when web2py was +From a historical perspective, our story starts in 2007 when web2py was first released. web2py was designed to provide an all-inclusive solution for web development: one zip file containing the Python interpreter, the framework, a web based IDE, and a collection of battle-tested packages @@ -45,9 +45,9 @@ Here is a more explicit list (see :ref:`From web2py to py4web` for more details if you come from web2py): - PY4WEB, unlike web2py, requires Python 3. -- PY4WEB, unlike web2py, can be installed using pip and its +- PY4WEB, unlike web2py, can be installed using pip, and its dependencies are managed using requirements.txt. -- PY4WEB apps are regular Python modules. This is very different to +- PY4WEB apps are regular Python modules. This is very different from web2py. In particular, we ditched the custom importer, and we rely now exclusively on the regular Python import mechanism. - PY4WEB, like web2py, can serve multiple applications concurrently, as @@ -57,7 +57,7 @@ details if you come from web2py): - PY4WEB, unlike web2py, does not create a new environment at every request. It introduces the concept of fixtures to explicitly declare which objects need to be (re)initialized when a new http request arrives - or need cleanup when completed. This makes it much faster than web2py. + or needs cleanup when completed. This makes it much faster than web2py. - PY4WEB, has a new session object which, like web2py’s, provides strong security and encryption of the session data, but sessions are no longer stored in the file system - which created performance issues. @@ -82,7 +82,7 @@ details if you come from web2py): is a web IDE for uploading/managing/editing apps. - PY4WEB’s Dashboard includes a web based database interface. This replaces the appadmin functionality of web2py. -- PY4WEB comes with a Form object and a Grid objects that are +- PY4WEB comes with Form and Grid objects that are similar to web2py’s SQLFORM and SQLFORM.grid. - PY4WEB comes with an Auth object that replaces the web2py one. It is more modular and easier to extend. Out of the box, it provides the @@ -90,7 +90,7 @@ details if you come from web2py): request change password, edit profile as well as integration with PAM, SAML2, LDAP, OAUTH2 (google, facebook, and twitter). - PY4WEB leverages PyDAL's new tags functionality - to tag users with groups and search users by groups and + to tag users with groups, search users by groups, and apply permissions based on membership. - PY4WEB comes with with some custom Vue.js components designed to interact with the PyDAL RESTAPI, and with PY4WEB in general. These @@ -119,7 +119,6 @@ Many thanks to everyone who has contributed to the project, and especially: .. include:: ../README.rst :start-after: inclusion-marker-do-not-remove -Special thanks to Sam de Alfaro, who designed the official logo of py4web. We friendly call the logo "Axel the axolotl": it magically represents the sense of kindness -and inclusion we believe it's the cornerstone of our growing community. +Special thanks to Sam de Alfaro, who designed the official logo of py4web. We friendly call the logo "Axel the axolotl": it magically represents the sense of kindness and inclusion. We believe it's the cornerstone of our growing community. .. image:: images/logo.png From 85fb47f16919981d7024a1442728f7d9ca4e5e73 Mon Sep 17 00:00:00 2001 From: Andrew Gavgavian Date: Mon, 9 Aug 2021 11:22:15 -0700 Subject: [PATCH 4/4] Allow search to work with htmx --- py4web/utils/grid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py4web/utils/grid.py b/py4web/utils/grid.py index 773df9e1e..e9f540330 100644 --- a/py4web/utils/grid.py +++ b/py4web/utils/grid.py @@ -770,7 +770,7 @@ def _make_default_form(self): for key in request.query if not key in ("search_type", "search_string") ] - attrs = self.attributes_plugin.form(url=self.endpoint) + attrs = self.attributes_plugin.link(url=self.endpoint) form = FORM(*hidden_fields, **attrs) select = SELECT( *options,