WuttaWeb 0.10.2__tar.gz → 0.12.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/CHANGELOG.md +31 -0
  2. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/PKG-INFO +2 -2
  3. wuttaweb-0.12.0/docs/narr/index.rst +8 -0
  4. wuttaweb-0.12.0/docs/narr/templates/base.rst +251 -0
  5. wuttaweb-0.12.0/docs/narr/templates/index.rst +10 -0
  6. wuttaweb-0.12.0/docs/narr/templates/lookup.rst +69 -0
  7. wuttaweb-0.12.0/docs/narr/templates/overview.rst +15 -0
  8. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/pyproject.toml +2 -2
  9. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/forms/base.py +19 -0
  10. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/forms/schema.py +25 -0
  11. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/forms/widgets.py +85 -1
  12. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/grids/base.py +669 -5
  13. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/appinfo/configure.mako +56 -7
  14. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/appinfo/index.mako +46 -2
  15. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/auth/login.mako +3 -9
  16. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/base.mako +270 -179
  17. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/base_meta.mako +3 -5
  18. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/configure.mako +29 -7
  19. wuttaweb-0.12.0/src/wuttaweb/templates/deform/readonly/objectref.pt +9 -0
  20. wuttaweb-0.12.0/src/wuttaweb/templates/deform/readonly/rolerefs.pt +7 -0
  21. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/form.mako +8 -11
  22. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/forms/vue_template.mako +14 -1
  23. wuttaweb-0.12.0/src/wuttaweb/templates/grids/table_element.mako +49 -0
  24. wuttaweb-0.12.0/src/wuttaweb/templates/grids/vue_template.mako +685 -0
  25. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/home.mako +1 -8
  26. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/master/index.mako +8 -6
  27. wuttaweb-0.12.0/src/wuttaweb/templates/page.mako +50 -0
  28. wuttaweb-0.12.0/src/wuttaweb/templates/wutta-components.mako +167 -0
  29. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/common.py +5 -0
  30. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/master.py +133 -3
  31. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/people.py +29 -8
  32. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/roles.py +12 -1
  33. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/settings.py +103 -40
  34. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/users.py +4 -0
  35. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/forms/test_base.py +24 -0
  36. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/forms/test_schema.py +14 -0
  37. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/forms/test_widgets.py +59 -2
  38. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/grids/test_base.py +521 -16
  39. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/test_common.py +11 -0
  40. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/test_master.py +253 -204
  41. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/test_people.py +44 -5
  42. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/test_settings.py +21 -0
  43. wuttaweb-0.10.2/docs/narr/index.rst +0 -16
  44. wuttaweb-0.10.2/src/wuttaweb/templates/deform/readonly/objectref.pt +0 -1
  45. wuttaweb-0.10.2/src/wuttaweb/templates/grids/vue_template.mako +0 -349
  46. wuttaweb-0.10.2/src/wuttaweb/templates/page.mako +0 -81
  47. wuttaweb-0.10.2/src/wuttaweb/templates/wutta-components.mako +0 -71
  48. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/.gitignore +0 -0
  49. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/COPYING.txt +0 -0
  50. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/README.md +0 -0
  51. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/Makefile +0 -0
  52. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/_static/.keepme +0 -0
  53. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/index.rst +0 -0
  54. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/app.rst +0 -0
  55. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/auth.rst +0 -0
  56. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/db.rst +0 -0
  57. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/forms.base.rst +0 -0
  58. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/forms.rst +0 -0
  59. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/forms.schema.rst +0 -0
  60. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/forms.widgets.rst +0 -0
  61. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/grids.base.rst +0 -0
  62. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/grids.rst +0 -0
  63. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/handler.rst +0 -0
  64. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/helpers.rst +0 -0
  65. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/index.rst +0 -0
  66. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/menus.rst +0 -0
  67. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/static.rst +0 -0
  68. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/subscribers.rst +0 -0
  69. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/util.rst +0 -0
  70. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.auth.rst +0 -0
  71. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.base.rst +0 -0
  72. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.common.rst +0 -0
  73. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.essential.rst +0 -0
  74. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.master.rst +0 -0
  75. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.people.rst +0 -0
  76. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.roles.rst +0 -0
  77. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.rst +0 -0
  78. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.settings.rst +0 -0
  79. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/api/wuttaweb/views.users.rst +0 -0
  80. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/conf.py +0 -0
  81. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/glossary.rst +0 -0
  82. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/index.rst +0 -0
  83. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/docs/make.bat +0 -0
  84. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/__init__.py +0 -0
  85. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/_version.py +0 -0
  86. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/app.py +0 -0
  87. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/auth.py +0 -0
  88. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/db.py +0 -0
  89. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/forms/__init__.py +0 -0
  90. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/grids/__init__.py +0 -0
  91. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/handler.py +0 -0
  92. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/helpers.py +0 -0
  93. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/menus.py +0 -0
  94. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/static/__init__.py +0 -0
  95. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/static/img/favicon.ico +0 -0
  96. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/static/img/logo.png +0 -0
  97. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/static/img/testing.png +0 -0
  98. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/subscribers.py +0 -0
  99. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/auth/change_password.mako +0 -0
  100. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/checkbox.pt +0 -0
  101. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/checkbox_choice.pt +0 -0
  102. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/checked_password.pt +0 -0
  103. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/password.pt +0 -0
  104. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/permissions.pt +0 -0
  105. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/readonly/notes.pt +0 -0
  106. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/readonly/permissions.pt +0 -0
  107. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/select.pt +0 -0
  108. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/textarea.pt +0 -0
  109. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/deform/textinput.pt +0 -0
  110. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/forbidden.mako +0 -0
  111. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/master/configure.mako +0 -0
  112. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/master/create.mako +0 -0
  113. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/master/delete.mako +0 -0
  114. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/master/edit.mako +0 -0
  115. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/master/form.mako +0 -0
  116. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/master/view.mako +0 -0
  117. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/notfound.mako +0 -0
  118. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/people/view_profile.mako +0 -0
  119. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/templates/setup.mako +0 -0
  120. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/util.py +0 -0
  121. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/__init__.py +0 -0
  122. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/auth.py +0 -0
  123. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/base.py +0 -0
  124. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/src/wuttaweb/views/essential.py +0 -0
  125. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tasks.py +0 -0
  126. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/__init__.py +0 -0
  127. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/forms/__init__.py +0 -0
  128. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/grids/__init__.py +0 -0
  129. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/bb_fontawesome_svg_core.js +0 -0
  130. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/bb_free_solid_svg_icons.js +0 -0
  131. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/bb_oruga.js +0 -0
  132. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/bb_oruga_bulma.css +0 -0
  133. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/bb_oruga_bulma.js +0 -0
  134. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/bb_vue.js +0 -0
  135. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/bb_vue_fontawesome.js +0 -0
  136. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/buefy.css +0 -0
  137. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/buefy.js +0 -0
  138. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/fontawesome.js +0 -0
  139. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/vue.js +0 -0
  140. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/libcache/vue_resource.js +0 -0
  141. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/test_app.py +0 -0
  142. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/test_auth.py +0 -0
  143. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/test_handler.py +0 -0
  144. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/test_helpers.py +0 -0
  145. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/test_menus.py +0 -0
  146. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/test_static.py +0 -0
  147. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/test_subscribers.py +0 -0
  148. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/test_util.py +0 -0
  149. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/util.py +0 -0
  150. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/__init__.py +0 -0
  151. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/test___init__.py +0 -0
  152. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/test_auth.py +0 -0
  153. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/test_base.py +0 -0
  154. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/test_roles.py +0 -0
  155. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tests/views/test_users.py +0 -0
  156. {wuttaweb-0.10.2 → wuttaweb-0.12.0}/tox.ini +0 -0
@@ -5,6 +5,37 @@ All notable changes to wuttaweb will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## v0.12.0 (2024-08-22)
9
+
10
+ ### Feat
11
+
12
+ - add "copy link" button for sharing a grid view
13
+ - add initial support for proper grid filters
14
+ - add initial filtering logic to grid class
15
+ - add "searchable" column support for grids
16
+ - improve page linkage between role/user/person
17
+ - add basic autocomplete support, for Person
18
+
19
+ ### Fix
20
+
21
+ - cleanup templates for home, login pages
22
+ - cleanup logic for appinfo/configure
23
+ - expose settings for app node title, type
24
+ - show installed python packages on appinfo page
25
+ - tweak login form to stop extending size of background card
26
+ - add setting to auto-redirect anon users to login, from home page
27
+ - add form padding, validators for /configure pages
28
+ - add padding around main form, via wrapper css
29
+ - show CRUD buttons in header only if relevant and user has access
30
+ - tweak style config for home link app title in main menu
31
+
32
+ ## v0.11.0 (2024-08-20)
33
+
34
+ ### Feat
35
+
36
+ - split up base templates into more sections (def blocks)
37
+ - simplify base/page/form template structure; add docs
38
+
8
39
  ## v0.10.2 (2024-08-19)
9
40
 
10
41
  ### Fix
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: WuttaWeb
3
- Version: 0.10.2
3
+ Version: 0.12.0
4
4
  Summary: Web App for Wutta Framework
5
5
  Project-URL: Homepage, https://wuttaproject.org/
6
6
  Project-URL: Repository, https://forgejo.wuttaproject.org/wutta/wuttaweb
@@ -35,7 +35,7 @@ Requires-Dist: pyramid-tm
35
35
  Requires-Dist: pyramid>=2
36
36
  Requires-Dist: waitress
37
37
  Requires-Dist: webhelpers2
38
- Requires-Dist: wuttjamaican[db]>=0.12.0
38
+ Requires-Dist: wuttjamaican[db]>=0.12.1
39
39
  Requires-Dist: zope-sqlalchemy>=1.5
40
40
  Provides-Extra: docs
41
41
  Requires-Dist: furo; extra == 'docs'
@@ -0,0 +1,8 @@
1
+
2
+ Documentation
3
+ =============
4
+
5
+ .. toctree::
6
+ :maxdepth: 2
7
+
8
+ templates/index
@@ -0,0 +1,251 @@
1
+
2
+ Base Templates
3
+ ==============
4
+
5
+ This describes the base templates. When creating a custom page
6
+ template, you most often need to inherit from one of these:
7
+
8
+ * :ref:`page_base_template`
9
+ * :ref:`form_base_template`
10
+ * :ref:`master_base_templates`
11
+
12
+ .. note::
13
+
14
+ Any of these templates may be overridden; see
15
+ :ref:`mako-template-override`.
16
+
17
+
18
+ Global Base
19
+ ~~~~~~~~~~~
20
+
21
+ There is exactly one "true base template" for the web app, designated
22
+ as: ``/base.mako``
23
+
24
+ The default base template is ``wuttaweb:templates/base.mako`` and all
25
+ page templates inherit from it. However they inherit it by *name*
26
+ only (``/base.mako``) - therefore if you override this via custom
27
+ template search paths, effectively you have changed the **theme**.
28
+
29
+ In addition to general layout/structure, this template is reponsible
30
+ for creating the Vue app which encompasses the whole of every page.
31
+ It also establishes the ``WholePage`` component which is the Vue app's
32
+ one and only child component.
33
+
34
+ (``WholePage`` in turn will have other children, for page content.)
35
+
36
+ There is usually no need to define a template which inherits directly
37
+ from ``/base.mako``, rather you should inherit from ``/page.mako``
38
+ (see next section) or similar.
39
+
40
+ As pertains to Vue component logic, there are 3 blocks which you may
41
+ find a need to override. These are defined by ``/base.mako`` so will
42
+ apply to *all* templates:
43
+
44
+ * ``render_vue_templates()``
45
+ * ``modify_vue_vars()``
46
+ * ``make_vue_components()``
47
+
48
+ Most often it is necessary to customize ``modify_vue_vars()`` but keep
49
+ reading for an example.
50
+
51
+
52
+ .. _page_base_template:
53
+
54
+ Page Base
55
+ ~~~~~~~~~
56
+
57
+ The common base template for pages, designated as: ``/page.mako``
58
+
59
+ This extends the Vue logic from ``/base.mako`` by establishing
60
+ ``ThisPage`` component, which wraps all content within the current
61
+ page.
62
+
63
+ The final structure then is conceptually like:
64
+
65
+ .. code-block:: html
66
+
67
+ <div id="app">
68
+ <whole-page>
69
+ <!-- menu etc. -->
70
+ <this-page>
71
+ <!-- page contents -->
72
+ </this-page>
73
+ </whole-page>
74
+ </div>
75
+
76
+ Simple usage is to create a template which inherits from
77
+ ``/page.mako`` and defines a ``page_content()`` block, e.g.:
78
+
79
+ .. code-block:: mako
80
+
81
+ <%inherit file="/page.mako" />
82
+
83
+ <%def name="page_content()">
84
+ <p>hello world!</p>
85
+ </%def>
86
+
87
+ The default ``/page.mako`` logic knows where to render the
88
+ ``page_content()`` block so that it fits properly into the
89
+ component/layout structure.
90
+
91
+ Often you may need to customize Vue component logic for a page; this
92
+ is done by defining one of the blocks mentioned in previous section.
93
+
94
+ Here is a simple example which shows how this works:
95
+
96
+ .. code-block:: mako
97
+
98
+ <%inherit file="/page.mako" />
99
+
100
+ <%def name="page_content()">
101
+ <b-field label="Foo">
102
+ <b-input v-model="foo" />
103
+ </b-field>
104
+ <b-field>
105
+ <b-button @click="alertFoo()">
106
+ Alert
107
+ </b-button>
108
+ </b-field>
109
+ </%def>
110
+
111
+ <%def name="modify_vue_vars()">
112
+ ${parent.modify_vue_vars()}
113
+ <script>
114
+
115
+ // nb. this becomes ThisPage.data.foo
116
+ ThisPageData.foo = 'bar'
117
+
118
+ ThisPage.methods.alertFoo = function() {
119
+ alert("value of foo is: " + this.foo)
120
+ }
121
+
122
+ </script>
123
+ </%def>
124
+
125
+ You can see that ``page_content()`` is able to reference things from
126
+ ``ThisPage`` component, while the ``modify_vue_vars()`` block is used
127
+ to define those same things on the component.
128
+
129
+
130
+ .. _form_base_template:
131
+
132
+ Form Base
133
+ ~~~~~~~~~
134
+
135
+ The common base template for pages with a form, designated as:
136
+ ``/form.mako``
137
+
138
+ This expects the context dict to contain ``'form'`` which points to a
139
+ :class:`~wuttaweb.forms.base.Form` instance.
140
+
141
+ This template extends the Vue logic from ``/page.mako`` by
142
+ establishing a Vue component specific to the form object.
143
+
144
+ The final structure then is conceptually like:
145
+
146
+ .. code-block:: html
147
+
148
+ <div id="app">
149
+ <whole-page>
150
+ <!-- menu etc. -->
151
+ <this-page>
152
+ <wutta-form>
153
+ <!-- fields etc. -->
154
+ </wutta-form>
155
+ </this-page>
156
+ </whole-page>
157
+ </div>
158
+
159
+ A simple example which assumes one of the form fields exposes a button
160
+ with click event that triggers ``alertFoo()`` method on the form
161
+ component:
162
+
163
+ .. code-block:: mako
164
+
165
+ <%inherit file="/form.mako" />
166
+
167
+ <%def name="modify_vue_vars()">
168
+ ${parent.modify_vue_vars()}
169
+ <script>
170
+
171
+ // nb. this becomes e.g. WuttaForm.foo when component is created
172
+ ${form.vue_component}Data.foo = 'bar'
173
+
174
+ ${form.vue_component}.methods.alertFoo = function() {
175
+ alert("value of foo is: " + this.foo)
176
+ }
177
+
178
+ </script>
179
+ </%def>
180
+
181
+ .. note::
182
+
183
+ By default, ``${form.vue_compoment}`` is rendered as ``WuttaForm``
184
+ but that is not guaranteed. You should resist the temptation to
185
+ hard-code that; always use ``${form.vue_component}`` and (where
186
+ applicable) ``${form.vue_tagname}``.
187
+
188
+ The reason for this is to allow multiple forms to exist on a single
189
+ page, each with a separate Vue component. (Which is not shown in
190
+ the above example.)
191
+
192
+ See also :attr:`~wuttaweb.forms.base.Form.vue_component` and
193
+ :attr:`~wuttaweb.forms.base.Form.vue_tagname`.
194
+
195
+
196
+ .. _master_base_templates:
197
+
198
+ Master Base
199
+ ~~~~~~~~~~~
200
+
201
+ These templates are for use with
202
+ :class:`~wuttaweb.views.master.MasterView`. Each is the default
203
+ template used for the corresponding route/view, unless a more specific
204
+ template is defined.
205
+
206
+ The "index" template is unique in that it is (usually) for listing the
207
+ model data:
208
+
209
+ * ``/master/index.mako``
210
+
211
+ The "form" template is just a base template, does not directly
212
+ correspond to a route/view. Other CRUD templates inherit from it.
213
+ This inherits from ``/form.mako`` (see previous section).
214
+
215
+ * ``/master/form.mako``
216
+
217
+ These CRUD templates inherit from ``/master/form.mako`` and so
218
+ require a ``'form'`` in the context dict.
219
+
220
+ * ``/master/create.mako``
221
+ * ``/master/view.mako``
222
+ * ``/master/edit.mako``
223
+ * ``/master/delete.mako``
224
+
225
+ The "configure" template is for master views which have a
226
+ configuration page.
227
+
228
+ * ``/master/configure.mako``
229
+
230
+ Usage for these is not significantly different from the ones shown
231
+ above, in cases where you actually need to override the template.
232
+
233
+ As an example let's say you have defined a ``WidgetMasterView`` class
234
+ and want to override its "view" template. You would then create a
235
+ file as ``/widgets/view.mako`` (within your templates folder) and
236
+ be sure to inherit from the correct base template:
237
+
238
+ .. code-block:: mako
239
+
240
+ <%inherit file="/master/view.mako" />
241
+
242
+ <%def name="page_content()">
243
+
244
+ <p>THIS APPEARS FIRST!</p>
245
+
246
+ ## nb. the form will appear here
247
+ ${parent.page_content()}
248
+
249
+ <p>MADE IT TO THE END!</p>
250
+
251
+ </%def>
@@ -0,0 +1,10 @@
1
+
2
+ Templates
3
+ =========
4
+
5
+ .. toctree::
6
+ :maxdepth: 2
7
+
8
+ overview
9
+ base
10
+ lookup
@@ -0,0 +1,69 @@
1
+
2
+ Template Lookup
3
+ ===============
4
+
5
+ The discovery of templates is handled by Mako, and is configurable.
6
+
7
+ WuttaWeb comes with all templates it needs, in the path designated as
8
+ ``wuttaweb:templates``.
9
+
10
+ When the app renders a page, it invokes the Mako lookup logic, which
11
+ searches one or more folders and returns the first matching file it
12
+ encounters. By default ``wuttaweb:templates`` is the only place it
13
+ looks.
14
+
15
+ A template is searched for by "name" but it is more path-like, e.g.
16
+ ``/page.mako`` or ``/master/index.mako`` etc. So for example the file
17
+ at ``wuttaweb:templates/home.mako`` is used for home page (using
18
+ lookup name ``/home.mako``) by default.
19
+
20
+
21
+ .. _mako-template-override:
22
+
23
+ Overriding the Search Paths
24
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
25
+
26
+ The basic idea is to give it a list of paths it should search when
27
+ trying to find a template. The first template file found for a given
28
+ search name is used and no further search is done for that name.
29
+
30
+ You can define the Mako lookup sequence in your ``web.conf`` as
31
+ follows:
32
+
33
+ .. code-block:: ini
34
+
35
+ [app:main]
36
+ mako.directories =
37
+ /random/path/on/disk
38
+ poser.web:templates
39
+ wuttaweb:templates
40
+
41
+ This setting is interpreted by ``pyramid_mako`` (`docs`_).
42
+
43
+ .. _docs: https://docs.pylonsproject.org/projects/pyramid_mako/en/latest/index.html#mako-directories
44
+
45
+ Here ``wuttaweb:templates/home.mako`` would still be used by default
46
+ for home page, *unless* e.g. ``/random/path/on/disk/home.mako``
47
+ existed in which case that would be used.
48
+
49
+ Each path can have an arbitrary set of templates, they will
50
+ effectively be combined to a single set by the app, with the
51
+ definition order determining search priority.
52
+
53
+ If you are already using a custom ``app.main()`` function for
54
+ constructing the web app during startup, it may be a good idea to
55
+ change the *default* search paths to include your package.
56
+
57
+ Setup for custom ``app.main()`` is beyond the scope here, but assuming
58
+ you *do* already have one, this is what it looks like::
59
+
60
+ from wuttaweb import app as base
61
+
62
+ def main(global_config, **settings):
63
+
64
+ # nb. set the *default* mako search paths; however config can
65
+ # still override with method shown above
66
+ settings.setdefault('mako.directories', ['poser.web:templates',
67
+ 'wuttaweb:templates'])
68
+
69
+ return base.main(global_config, **settings)
@@ -0,0 +1,15 @@
1
+
2
+ Overview
3
+ ========
4
+
5
+ WuttaWeb uses the `Mako`_ template language for page rendering.
6
+
7
+ .. _Mako: https://www.makotemplates.org/
8
+
9
+ There is a "global" base template which effectively defines the
10
+ "theme" (page layout, Vue component structure). A few other base
11
+ templates provide a starting point for any custom pages; see
12
+ :doc:`base`.
13
+
14
+ Templates are found via lookup which is handled by Mako. This is
15
+ configurable so you can override any or all; see :doc:`lookup`.
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "WuttaWeb"
9
- version = "0.10.2"
9
+ version = "0.12.0"
10
10
  description = "Web App for Wutta Framework"
11
11
  readme = "README.md"
12
12
  authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]
@@ -41,7 +41,7 @@ dependencies = [
41
41
  "pyramid_tm",
42
42
  "waitress",
43
43
  "WebHelpers2",
44
- "WuttJamaican[db]>=0.12.0",
44
+ "WuttJamaican[db]>=0.12.1",
45
45
  "zope.sqlalchemy>=1.5",
46
46
  ]
47
47
 
@@ -25,6 +25,7 @@ Base form classes
25
25
  """
26
26
 
27
27
  import logging
28
+ from collections import OrderedDict
28
29
 
29
30
  import colander
30
31
  import deform
@@ -311,6 +312,9 @@ class Form:
311
312
 
312
313
  self.set_fields(fields or self.get_fields())
313
314
 
315
+ # nb. this tracks grid JSON data for inclusion in page template
316
+ self.grid_vue_data = OrderedDict()
317
+
314
318
  def __contains__(self, name):
315
319
  """
316
320
  Custom logic for the ``in`` operator, to allow easily checking
@@ -750,6 +754,10 @@ class Form:
750
754
  kwargs['appstruct'] = self.model_instance
751
755
 
752
756
  form = deform.Form(schema, **kwargs)
757
+ # nb. must give a reference back to wutta form; this is
758
+ # for sake of field schema nodes and widgets, e.g. to
759
+ # access the main model instance
760
+ form.wutta_form = self
753
761
  self.deform_form = form
754
762
 
755
763
  return self.deform_form
@@ -818,6 +826,17 @@ class Form:
818
826
  output = render(template, context)
819
827
  return HTML.literal(output)
820
828
 
829
+ def add_grid_vue_data(self, grid):
830
+ """ """
831
+ if not grid.key:
832
+ raise ValueError("grid must have a key!")
833
+
834
+ if grid.key in self.grid_vue_data:
835
+ log.warning("grid data with key '%s' already registered, "
836
+ "but will be replaced", grid.key)
837
+
838
+ self.grid_vue_data[grid.key] = grid.get_vue_data()
839
+
821
840
  def render_vue_field(
822
841
  self,
823
842
  fieldname,
@@ -246,6 +246,9 @@ class ObjectRef(colander.SchemaType):
246
246
  values.insert(0, self.empty_option)
247
247
  kwargs['values'] = values
248
248
 
249
+ if 'url' not in kwargs:
250
+ kwargs['url'] = lambda person: self.request.route_url('people.view', uuid=person.uuid)
251
+
249
252
  return widgets.ObjectRefWidget(self.request, **kwargs)
250
253
 
251
254
 
@@ -321,6 +324,28 @@ class RoleRefs(WuttaSet):
321
324
  return widgets.RoleRefsWidget(self.request, **kwargs)
322
325
 
323
326
 
327
+ class UserRefs(WuttaSet):
328
+ """
329
+ Form schema type for the Role
330
+ :attr:`~wuttjamaican:wuttjamaican.db.model.auth.Role.users`
331
+ association proxy field.
332
+
333
+ This is a subclass of :class:`WuttaSet`. It uses a ``set`` of
334
+ :class:`~wuttjamaican:wuttjamaican.db.model.auth.User` ``uuid``
335
+ values for underlying data format.
336
+ """
337
+
338
+ def widget_maker(self, **kwargs):
339
+ """
340
+ Constructs a default widget for the field.
341
+
342
+ :returns: Instance of
343
+ :class:`~wuttaweb.forms.widgets.UserRefsWidget`.
344
+ """
345
+ kwargs.setdefault('session', self.session)
346
+ return widgets.UserRefsWidget(self.request, **kwargs)
347
+
348
+
324
349
  class Permissions(WuttaSet):
325
350
  """
326
351
  Form schema type for the Role
@@ -44,6 +44,7 @@ from deform.widget import (Widget, TextInputWidget, TextAreaWidget,
44
44
  from webhelpers2.html import HTML
45
45
 
46
46
  from wuttaweb.db import Session
47
+ from wuttaweb.grids import Grid
47
48
 
48
49
 
49
50
  class ObjectRefWidget(SelectWidget):
@@ -83,9 +84,19 @@ class ObjectRefWidget(SelectWidget):
83
84
  """
84
85
  readonly_template = 'readonly/objectref'
85
86
 
86
- def __init__(self, request, *args, **kwargs):
87
+ def __init__(self, request, url=None, *args, **kwargs):
87
88
  super().__init__(*args, **kwargs)
88
89
  self.request = request
90
+ self.url = url
91
+
92
+ def get_template_values(self, field, cstruct, kw):
93
+ """ """
94
+ values = super().get_template_values(field, cstruct, kw)
95
+
96
+ if 'url' not in values and self.url and field.schema.model_instance:
97
+ values['url'] = self.url(field.schema.model_instance)
98
+
99
+ return values
89
100
 
90
101
 
91
102
  class NotesWidget(TextAreaWidget):
@@ -137,12 +148,17 @@ class RoleRefsWidget(WuttaCheckboxChoiceWidget):
137
148
  """
138
149
  Widget for use with User
139
150
  :attr:`~wuttjamaican:wuttjamaican.db.model.auth.User.roles` field.
151
+ This is the default widget for the
152
+ :class:`~wuttaweb.forms.schema.RoleRefs` type.
140
153
 
141
154
  This is a subclass of :class:`WuttaCheckboxChoiceWidget`.
142
155
  """
156
+ readonly_template = 'readonly/rolerefs'
143
157
 
144
158
  def serialize(self, field, cstruct, **kw):
145
159
  """ """
160
+ model = self.app.model
161
+
146
162
  # special logic when field is editable
147
163
  readonly = kw.get('readonly', self.readonly)
148
164
  if not readonly:
@@ -159,10 +175,78 @@ class RoleRefsWidget(WuttaCheckboxChoiceWidget):
159
175
  if val[0] != admin.uuid]
160
176
  kw['values'] = values
161
177
 
178
+ else: # readonly
179
+
180
+ # roles
181
+ roles = []
182
+ if cstruct:
183
+ for uuid in cstruct:
184
+ role = self.session.query(model.Role).get(uuid)
185
+ if role:
186
+ roles.append(role)
187
+ kw['roles'] = roles
188
+
189
+ # url
190
+ url = lambda role: self.request.route_url('roles.view', uuid=role.uuid)
191
+ kw['url'] = url
192
+
162
193
  # default logic from here
163
194
  return super().serialize(field, cstruct, **kw)
164
195
 
165
196
 
197
+ class UserRefsWidget(WuttaCheckboxChoiceWidget):
198
+ """
199
+ Widget for use with Role
200
+ :attr:`~wuttjamaican:wuttjamaican.db.model.auth.Role.users` field.
201
+ This is the default widget for the
202
+ :class:`~wuttaweb.forms.schema.UserRefs` type.
203
+
204
+ This is a subclass of :class:`WuttaCheckboxChoiceWidget`; however
205
+ it only supports readonly mode and does not use a template.
206
+ Rather, it generates and renders a
207
+ :class:`~wuttaweb.grids.base.Grid` showing the users list.
208
+ """
209
+
210
+ def serialize(self, field, cstruct, **kw):
211
+ """ """
212
+ readonly = kw.get('readonly', self.readonly)
213
+ if not readonly:
214
+ raise NotImplementedError("edit not allowed for this widget")
215
+
216
+ model = self.app.model
217
+ columns = ['person', 'username', 'active']
218
+
219
+ # generate data set for users
220
+ users = []
221
+ if cstruct:
222
+ for uuid in cstruct:
223
+ user = self.session.query(model.User).get(uuid)
224
+ if user:
225
+ users.append(dict([(key, getattr(user, key))
226
+ for key in columns + ['uuid']]))
227
+
228
+ # grid
229
+ grid = Grid(self.request, key='roles.view.users',
230
+ columns=columns, data=users)
231
+
232
+ # view action
233
+ if self.request.has_perm('users.view'):
234
+ url = lambda user, i: self.request.route_url('users.view', uuid=user['uuid'])
235
+ grid.add_action('view', icon='eye', url=url)
236
+ grid.set_link('person')
237
+ grid.set_link('username')
238
+
239
+ # edit action
240
+ if self.request.has_perm('users.edit'):
241
+ url = lambda user, i: self.request.route_url('users.edit', uuid=user['uuid'])
242
+ grid.add_action('edit', url=url)
243
+
244
+ # render as simple <b-table>
245
+ # nb. must indicate we are a part of this form
246
+ form = getattr(field.parent, 'wutta_form', None)
247
+ return grid.render_table_element(form)
248
+
249
+
166
250
  class PermissionsWidget(WuttaCheckboxChoiceWidget):
167
251
  """
168
252
  Widget for use with Role