Django-SupportTools 3.6.4__tar.gz → 4.0.dev3__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 (79) hide show
  1. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/Django_SupportTools.egg-info/PKG-INFO +2 -2
  2. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/Django_SupportTools.egg-info/SOURCES.txt +9 -0
  3. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/PKG-INFO +2 -2
  4. django_supporttools-4.0.dev3/README.md +390 -0
  5. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/setup.py +1 -1
  6. django_supporttools-4.0.dev3/supporttools/VERSION +1 -0
  7. django_supporttools-4.0.dev3/supporttools/context_processors.py +228 -0
  8. django_supporttools-4.0.dev3/supporttools/static/supporttools/css/bootstrap-icons.woff +0 -0
  9. django_supporttools-4.0.dev3/supporttools/static/supporttools/css/bootstrap-icons.woff2 +0 -0
  10. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/supporttools/css/desktop.less +37 -23
  11. django_supporttools-4.0.dev3/supporttools/static/supporttools/css/main.css +1 -0
  12. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/supporttools/css/mobile.less +5 -0
  13. django_supporttools-4.0.dev3/supporttools/static/supporttools/js/main.js +1 -0
  14. django_supporttools-3.6.4/supporttools/static/supporttools/js/main.js → django_supporttools-4.0.dev3/supporttools/static/supporttools/js/restclients.js +29 -62
  15. django_supporttools-4.0.dev3/supporttools/templates/restclients/proxy_wrapper.html +7 -0
  16. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/templates/supporttools/base.html +59 -8
  17. django_supporttools-4.0.dev3/supporttools/templates/supporttools/spa_tool.html +17 -0
  18. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/templatetags/sidebar_links.py +3 -3
  19. django_supporttools-4.0.dev3/supporttools/templatetags/vite.py +99 -0
  20. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/tests/__init__.py +4 -3
  21. django_supporttools-4.0.dev3/supporttools/tests/test_context_processors.py +217 -0
  22. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/tests/test_sidebar_links.py +2 -2
  23. django_supporttools-4.0.dev3/supporttools/tests/test_templatetags_vite.py +165 -0
  24. django_supporttools-4.0.dev3/supporttools/tests/test_urls.py +66 -0
  25. django_supporttools-4.0.dev3/supporttools/tests/test_views.py +114 -0
  26. django_supporttools-4.0.dev3/supporttools/urls.py +66 -0
  27. django_supporttools-4.0.dev3/supporttools/views.py +37 -0
  28. django_supporttools-3.6.4/README.md +0 -50
  29. django_supporttools-3.6.4/supporttools/VERSION +0 -1
  30. django_supporttools-3.6.4/supporttools/context_processors.py +0 -39
  31. django_supporttools-3.6.4/supporttools/templates/restclients/proxy_wrapper.html +0 -2
  32. django_supporttools-3.6.4/supporttools/tests/test_context_processors.py +0 -89
  33. django_supporttools-3.6.4/supporttools/urls.py +0 -10
  34. django_supporttools-3.6.4/supporttools/views.py +0 -9
  35. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/Django_SupportTools.egg-info/dependency_links.txt +0 -0
  36. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/Django_SupportTools.egg-info/requires.txt +0 -0
  37. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/Django_SupportTools.egg-info/top_level.txt +0 -0
  38. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/LICENSE +0 -0
  39. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/MANIFEST.in +0 -0
  40. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/setup.cfg +0 -0
  41. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/__init__.py +0 -0
  42. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/supporttools/css/.DS_Store +0 -0
  43. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/android-196x196.png +0 -0
  44. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-114x114-precomposed.png +0 -0
  45. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-120x120-precomposed.png +0 -0
  46. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-144x144-precomposed.png +0 -0
  47. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-152x152-precomposed.png +0 -0
  48. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-180x180-precomposed.png +0 -0
  49. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-192x192-precomposed.png +0 -0
  50. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-57x57-precomposed.png +0 -0
  51. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-60x60-precomposed.png +0 -0
  52. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-72x72-precomposed.png +0 -0
  53. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-76x76-precomposed.png +0 -0
  54. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/apple-touch-icon-precomposed.png +0 -0
  55. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/favicon.ico +0 -0
  56. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/win8-144x144.png +0 -0
  57. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/win8-150x150.png +0 -0
  58. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/win8-310x150.png +0 -0
  59. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/win8-310x310.png +0 -0
  60. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/uw/ico/win8-70x70.png +0 -0
  61. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/fonts/FontAwesome.otf +0 -0
  62. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/fonts/fontawesome-webfont.eot +0 -0
  63. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/fonts/fontawesome-webfont.svg +0 -0
  64. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/fonts/fontawesome-webfont.ttf +0 -0
  65. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/fonts/fontawesome-webfont.woff +0 -0
  66. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/fonts/glyphicons-halflings-regular.eot +0 -0
  67. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/fonts/glyphicons-halflings-regular.svg +0 -0
  68. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/fonts/glyphicons-halflings-regular.ttf +0 -0
  69. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/fonts/glyphicons-halflings-regular.woff +0 -0
  70. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/js/chart.min.js +0 -0
  71. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/js/jquery-1.10.2.min.js +0 -0
  72. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/static/vendor/js/less-1.7.0.min.js +0 -0
  73. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/templates/persistent_message/manage_wrapper.html +0 -0
  74. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/templates/status_app/status_wrapper.html +0 -0
  75. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/templates/supporttools/default_sidelinks.html +0 -0
  76. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/templates/supporttools/home.html +0 -0
  77. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/templates/userservice/user_override_wrapper.html +0 -0
  78. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/templatetags/__init__.py +0 -0
  79. {django_supporttools-3.6.4 → django_supporttools-4.0.dev3}/supporttools/tests/test_templates/supporttools/custom_sidebar_links.html +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Django-SupportTools
3
- Version: 3.6.4
3
+ Version: 4.0.dev3
4
4
  Summary: A Django application used for theming and wrapping support tools.
5
5
  Home-page: https://github.com/uw-it-aca/django-supporttools
6
- Author: UW-IT Student & Educational Technology Services
6
+ Author: UWIT Student & Educational Technology Services
7
7
  Author-email: aca-it@uw.edu
8
8
  License: Apache License, Version 2.0
9
9
  Classifier: Intended Audience :: Developers
@@ -13,9 +13,13 @@ supporttools/context_processors.py
13
13
  supporttools/urls.py
14
14
  supporttools/views.py
15
15
  supporttools/static/supporttools/css/.DS_Store
16
+ supporttools/static/supporttools/css/bootstrap-icons.woff
17
+ supporttools/static/supporttools/css/bootstrap-icons.woff2
16
18
  supporttools/static/supporttools/css/desktop.less
19
+ supporttools/static/supporttools/css/main.css
17
20
  supporttools/static/supporttools/css/mobile.less
18
21
  supporttools/static/supporttools/js/main.js
22
+ supporttools/static/supporttools/js/restclients.js
19
23
  supporttools/static/uw/ico/android-196x196.png
20
24
  supporttools/static/uw/ico/apple-touch-icon-114x114-precomposed.png
21
25
  supporttools/static/uw/ico/apple-touch-icon-120x120-precomposed.png
@@ -52,10 +56,15 @@ supporttools/templates/status_app/status_wrapper.html
52
56
  supporttools/templates/supporttools/base.html
53
57
  supporttools/templates/supporttools/default_sidelinks.html
54
58
  supporttools/templates/supporttools/home.html
59
+ supporttools/templates/supporttools/spa_tool.html
55
60
  supporttools/templates/userservice/user_override_wrapper.html
56
61
  supporttools/templatetags/__init__.py
57
62
  supporttools/templatetags/sidebar_links.py
63
+ supporttools/templatetags/vite.py
58
64
  supporttools/tests/__init__.py
59
65
  supporttools/tests/test_context_processors.py
60
66
  supporttools/tests/test_sidebar_links.py
67
+ supporttools/tests/test_templatetags_vite.py
68
+ supporttools/tests/test_urls.py
69
+ supporttools/tests/test_views.py
61
70
  supporttools/tests/test_templates/supporttools/custom_sidebar_links.html
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Django-SupportTools
3
- Version: 3.6.4
3
+ Version: 4.0.dev3
4
4
  Summary: A Django application used for theming and wrapping support tools.
5
5
  Home-page: https://github.com/uw-it-aca/django-supporttools
6
- Author: UW-IT Student & Educational Technology Services
6
+ Author: UWIT Student & Educational Technology Services
7
7
  Author-email: aca-it@uw.edu
8
8
  License: Apache License, Version 2.0
9
9
  Classifier: Intended Audience :: Developers
@@ -0,0 +1,390 @@
1
+ # Django Support Tools
2
+
3
+ [![Build Status](https://github.com/uw-it-aca/django-supporttools/workflows/tests/badge.svg)](https://github.com/uw-it-aca/django-supporttools/actions)
4
+ [![Coverage Status](https://coveralls.io/repos/github/uw-it-aca/django-supporttools/badge.svg?branch=main)](https://coveralls.io/github/uw-it-aca/django-supporttools?branch=main)
5
+ [![PyPi Version](https://img.shields.io/pypi/v/django-supporttools.svg)](https://pypi.python.org/pypi/django-supporttools)
6
+ ![Python versions](https://img.shields.io/badge/python-3.10%20%7C%203.12-blue.svg)
7
+ ![Django versions](https://img.shields.io/badge/django-4.2%20%7C%205.2-green.svg)
8
+
9
+
10
+ A Django application used for theming and wrapping support tools.
11
+
12
+ Supported Python versions are 3.10 and 3.12. CI tests each against Django 4.2
13
+ and 5.2.
14
+
15
+ ### Installation
16
+
17
+ This should be installed as a dependency in your project. You should not install this manually.
18
+
19
+ ### Configuration
20
+
21
+ Add these values to your project's settings.py:
22
+
23
+ ```
24
+ MIDDLEWARE = [
25
+ ...
26
+ 'userservice.user.UserServiceMiddleware',
27
+ 'django_user_agents.middleware.UserAgentMiddleware',
28
+ ]
29
+
30
+ INSTALLED_APPS = [
31
+ ...
32
+ 'supporttools',
33
+ 'userservice',
34
+ 'compressor',
35
+ 'django_user_agents',
36
+ ]
37
+
38
+ TEMPLATES = [
39
+ {
40
+ 'OPTIONS': {
41
+ 'context_processors': [
42
+ ...
43
+ 'django.template.context_processors.request',
44
+ 'supporttools.context_processors.supportools_globals',
45
+ 'supporttools.context_processors.has_less_compiled',
46
+ ],
47
+ },
48
+ },
49
+ ]
50
+
51
+ # Where the back link should go, and how it's labeled.
52
+ SUPPORTTOOLS_PARENT_APP = "TestApp"
53
+ SUPPORTTOOLS_PARENT_APP_URL = "/"
54
+
55
+ # Optional: enable Vue-powered supporttools navigation shell.
56
+ # Keep False during migration to preserve legacy behavior.
57
+ SUPPORTTOOLS_VUE_ENABLED = False
58
+
59
+ # Required when this app defines SPA tools with a `vite_entry`.
60
+ # This is a filesystem path to the manifest generated by the app's Vite build,
61
+ # not a static URL. Update it for the collected-static location in production.
62
+ VITE_MANIFEST_PATH = BASE_DIR / 'myapp/static/.vite/manifest.json'
63
+
64
+ # Optional: new structured link registry (preferred over EXTRA_VIEWS
65
+ # when configured).
66
+ # Example A — simple server-rendered tool:
67
+ SUPPORTTOOLS_VIEW_REGISTRY = [
68
+ {
69
+ "id": "app-tool-1",
70
+ "section": "application",
71
+ "order": 10,
72
+ "label": "Example Tool",
73
+ "url_name": "example_tool",
74
+ "url_args": [],
75
+ "url_kwargs": {},
76
+ }
77
+ ]
78
+
79
+ # Example B — SPA tool (use one definition, not both):
80
+ # Optional: mixed navigation support for incremental migration.
81
+ # Legacy tools can stay server-rendered; converted Vue tools are SPA-only.
82
+ # mode defaults to "server" only for legacy entries.
83
+ # Entries with SPA marker fields (route/component_key/vite_entry)
84
+ # are treated as "spa" even if mode is omitted.
85
+ #
86
+ # SPA-mode fields:
87
+ # route – URL path the component is served at (must match a Django URL pattern)
88
+ # component_key – key used to look up the component in window.supporttoolsSpaComponents
89
+ # vite_entry – Vite asset path; passed to {% vite_scripts %} in the generic SPA template
90
+ # view – dotted import path to the Django view class (required unless SUPPORTTOOLS_DEFAULT_SPA_VIEW is set)
91
+ SUPPORTTOOLS_VIEW_REGISTRY = [
92
+ {
93
+ "id": "retention-admin",
94
+ "section": "application",
95
+ "order": 20,
96
+ "label": "Retention Admin",
97
+ "url_name": "retention_admin",
98
+ "mode": "spa",
99
+ "route": "/support/retention_admin/",
100
+ "component_key": "retention_admin",
101
+ "vite_entry": "myapp_vue/support/retention-admin.js",
102
+ "view": "myapp.views.support.retention.RetentionAdminView", # omit to use the default SPA view
103
+ }
104
+ ]
105
+
106
+ # Optional: default view class for auto-registered SPA tools.
107
+ # Used when a registry entry omits the "view" key.
108
+ # Typically a project-specific subclass of SpaToolView that adds authentication.
109
+ SUPPORTTOOLS_DEFAULT_SPA_VIEW = "myapp.views.support.base.MySpaToolView"
110
+ ```
111
+
112
+ ### Migrating to Vue
113
+
114
+ Apps can migrate incrementally across four phases. Each phase is independently
115
+ testable and reversible before moving to the next.
116
+
117
+ | Phase | What changes | Minimum required |
118
+ |---|---|---|
119
+ | 0 | Nothing — existing server-rendered nav keeps working | No changes required |
120
+ | 1 | Enable the Vue nav shell | One settings flag: `SUPPORTTOOLS_VUE_ENABLED = True` |
121
+ | 2 | Register tools explicitly | Add entries to `SUPPORTTOOLS_VIEW_REGISTRY` (or keep using `SUPPORTTOOLS_EXTRA_VIEWS`) |
122
+ | 3 | Set up shared SPA infrastructure | One base view class, one settings entry, one `urls.py` line, one Vite config snippet |
123
+ | 4 | Convert individual pages to Vue | One registry entry + one JS entry point + one Vue component per tool |
124
+
125
+ Phases 0–2 require no Node.js and no frontend changes. Phase 3 is a
126
+ one-time project setup. Phase 4 is per-tool and fully incremental — legacy
127
+ tools can remain server-rendered indefinitely.
128
+
129
+ ---
130
+
131
+ #### Phase 1 — Enable the Vue nav shell (zero-config)
132
+
133
+ Set the feature flag in your settings file:
134
+
135
+ ```python
136
+ SUPPORTTOOLS_VUE_ENABLED = True
137
+ ```
138
+
139
+ That is the only required change. When the flag is on, the Vue nav shell
140
+ mounts on `#supporttools-vue-nav` and automatically harvests links from the
141
+ server-rendered `{% sidebar_links %}` output already present in the DOM — so
142
+ your existing `custom_sidebar_links.html` override (if any) keeps its section
143
+ headings, link labels, ordering, and visibility rules with no changes.
144
+ Enabling the shell does not convert any tool page; tools remain server-rendered
145
+ until they are configured as SPA entries in Phase 4.
146
+
147
+ **Verify**: the sidebar renders the same links as before, the hamburger toggle
148
+ works on mobile viewports, and there are no JS errors in the browser console.
149
+
150
+ ---
151
+
152
+ #### Phase 2 — Register your tools explicitly (optional but recommended)
153
+
154
+ The rendered sidebar remains the presentation source of truth while an app is
155
+ migrating. Registering tools in settings adds navigation behavior such as SPA
156
+ routing; explicit registry entries that are not in the rendered sidebar are
157
+ also appended, so tools can be converted incrementally.
158
+
159
+ **Option A — simple dict (lowest friction first step):**
160
+
161
+ ```python
162
+ # settings.py
163
+ SUPPORTTOOLS_EXTRA_VIEWS = {
164
+ "My Tool": "my_tool_url_name",
165
+ "Another Tool": "another_tool_url_name",
166
+ }
167
+ ```
168
+
169
+ **Option B — structured registry (preferred for new work):**
170
+
171
+ ```python
172
+ # settings.py
173
+ SUPPORTTOOLS_VIEW_REGISTRY = [
174
+ {
175
+ "id": "my-tool",
176
+ "section": "application",
177
+ "order": 10,
178
+ "label": "My Tool",
179
+ "url_name": "my_tool_url_name",
180
+ },
181
+ {
182
+ "id": "another-tool",
183
+ "section": "application",
184
+ "order": 20,
185
+ "label": "Another Tool",
186
+ "url_name": "another_tool_url_name",
187
+ },
188
+ ]
189
+ ```
190
+
191
+ When `SUPPORTTOOLS_VIEW_REGISTRY` is set it takes precedence; entries from
192
+ `SUPPORTTOOLS_EXTRA_VIEWS` are merged in as a supplement. Once your tools are
193
+ registered here, a simple `custom_sidebar_links.html` override can be removed.
194
+ Keep an override that supplies custom sections, conditional links, or required
195
+ ordering until the rendered Vue navigation has been verified to preserve those
196
+ requirements.
197
+
198
+ ---
199
+
200
+ #### Phase 3 — Set up shared SPA infrastructure (once per project)
201
+
202
+ Complete this once before converting any individual tool in Phase 4.
203
+
204
+ **1. Create a project-level SPA view base** that adds your auth decorator:
205
+
206
+ ```python
207
+ # myapp/views/support/base.py
208
+ from django.conf import settings
209
+ from django.utils.decorators import method_decorator
210
+ from uw_saml.decorators import group_required
211
+ from supporttools.views import SpaToolView
212
+
213
+ @method_decorator(group_required(settings.MY_SUPPORT_GROUP), name='dispatch')
214
+ class MySpaToolView(SpaToolView):
215
+ pass
216
+ ```
217
+
218
+ **2. Add the default view and register SPA URLs**:
219
+
220
+ ```python
221
+ # settings.py
222
+ SUPPORTTOOLS_DEFAULT_SPA_VIEW = "myapp.views.support.base.MySpaToolView"
223
+ ```
224
+
225
+ If your project does not already include `supporttools.urls`, append generated
226
+ SPA routes after your application routes:
227
+
228
+ ```python
229
+ # project/urls.py
230
+ from supporttools.urls import get_registry_urlpatterns
231
+
232
+ urlpatterns += get_registry_urlpatterns()
233
+ ```
234
+
235
+ Do not add a root-level `include("supporttools.urls")` solely to enable SPA
236
+ routes: its legacy home route is a catch-all. Alternatively, keep an existing
237
+ project URL and change that URL's view to your authenticated SPA view. In either
238
+ case, each registry `route` must resolve to the URL served by that view.
239
+
240
+ **3. Auto-discover Vite entry points** by editing your existing `vite.config.js`
241
+ so new tools are picked up automatically:
242
+
243
+ Add/merge the snippet below into your current Vite config. Do not replace the
244
+ entire file.
245
+
246
+ ```javascript
247
+ // vite.config.js
248
+ import { readdirSync } from "fs";
249
+
250
+ const supportEntries = readdirSync("./myapp_vue/support")
251
+ .filter((f) => f.endsWith(".js"))
252
+ .map((f) => `./myapp_vue/support/${f}`);
253
+
254
+ export default defineConfig({
255
+ build: {
256
+ manifest: true,
257
+ rollupOptions: {
258
+ input: ["./myapp_vue/main.js", ...supportEntries],
259
+ },
260
+ },
261
+ });
262
+ ```
263
+
264
+ Each `vite_entry` must be an input in this app-owned Vite build. Build the
265
+ assets with `npm run build` before `collectstatic`, and configure
266
+ `VITE_MANIFEST_PATH` to the generated manifest's filesystem path. The generic
267
+ SPA template loads both the entry's JavaScript and its manifest-listed CSS.
268
+
269
+ ---
270
+
271
+ #### Phase 4 — Convert individual pages to Vue
272
+
273
+ Each page can be converted independently without affecting other tools.
274
+ Legacy tools can remain server-rendered while converted tools use SPA nav.
275
+
276
+ - `mode: "server"` (default for legacy entries): normal full-page navigation.
277
+ - `mode: "spa"`: client-side navigation — no full-page reload when the sidebar
278
+ link is clicked.
279
+ - Converted Vue tools are SPA-only. If `route`, `component_key`, or
280
+ `vite_entry` is present, the entry is normalized to `mode: "spa"`.
281
+
282
+ Data access is owned by the tool component. A tool can pre-load data from
283
+ the server on direct URL navigation, and fetch from API endpoints when
284
+ mounted via SPA navigation. This direct-URL bootstrap uses the SPA view
285
+ template; it is not a fallback to server-navigation mode.
286
+
287
+ ---
288
+
289
+ ##### Adding a new SPA tool
290
+
291
+ **1. Register the tool in `SUPPORTTOOLS_VIEW_REGISTRY`**
292
+
293
+ ```python
294
+ {
295
+ "id": "my-tool",
296
+ "section": "application",
297
+ "order": 10,
298
+ "label": "My Tool",
299
+ "url_name": "my_tool",
300
+ "mode": "spa",
301
+ "route": "/support/my_tool/",
302
+ "component_key": "my_tool",
303
+ "vite_entry": "myapp_vue/support/my-tool.js",
304
+ # "view": "myapp.views.support.my_tool.MyToolView" # only needed for custom server data
305
+ }
306
+ ```
307
+
308
+ The URL is registered by the Phase 3 URL handoff. No additional `urls.py` edit
309
+ is needed for this tool.
310
+
311
+ **2. Create the Vue entry point** (the entire file):
312
+
313
+ ```javascript
314
+ // myapp_vue/support/my-tool.js
315
+ window.supporttoolsRegisterSpaTool("my_tool", () => import("./MyTool.vue"));
316
+ ```
317
+
318
+ `window.supporttoolsRegisterSpaTool` is provided by the supporttools bundle
319
+ already loaded in `base.html`. It handles both SPA-nav mounting (via the
320
+ sidebar) and direct-URL mounting (via server-rendered JSON). No imports needed.
321
+
322
+ **3. Create the Vue component**
323
+
324
+ The component receives a `pageData` prop on direct-URL load (populated from
325
+ server-rendered JSON), and a `tool` prop when mounted via SPA navigation:
326
+
327
+ ```vue
328
+ <template>
329
+ <div>
330
+ <h1>My Tool</h1>
331
+ <!-- your UI -->
332
+ </div>
333
+ </template>
334
+
335
+ <script>
336
+ export default {
337
+ name: "MyTool",
338
+ props: {
339
+ pageData: { type: Object, default: () => ({}) },
340
+ tool: { type: Object, default: null },
341
+ },
342
+ async mounted() {
343
+ // When mounted via SPA nav, pageData is empty — fetch fresh data from API.
344
+ if (this.tool && this.tool.mode === "spa") {
345
+ await this.loadData();
346
+ }
347
+ },
348
+ methods: {
349
+ async loadData() { /* fetch from your API endpoint */ },
350
+ },
351
+ };
352
+ </script>
353
+ ```
354
+
355
+ **That's all that's needed for a tool with no server-side bootstrap data.**
356
+
357
+ ---
358
+
359
+ ##### Adding server-side bootstrap data (optional)
360
+
361
+ If the tool needs data pre-loaded on direct URL navigation, create a
362
+ Django view that inherits from your project's SPA view base and overrides
363
+ `get_page_data()`. The data is serialised to JSON and passed as the
364
+ `pageData` prop automatically by the generic `spa_tool.html` template.
365
+
366
+ ```python
367
+ # myapp/views/support/my_tool.py
368
+ from myapp.views.support.base import MySpaToolView
369
+
370
+ class MyToolView(MySpaToolView):
371
+ def get_page_data(self):
372
+ return {
373
+ 'items': [
374
+ {'id': obj.id, 'name': obj.name}
375
+ for obj in MyModel.objects.all()
376
+ ]
377
+ }
378
+ ```
379
+
380
+ Then add `"view": "myapp.views.support.my_tool.MyToolView"` to the registry
381
+ entry. No template file needed — `spa_tool.html` is used automatically.
382
+
383
+ ---
384
+
385
+ #### CI/CD note
386
+
387
+ The compiled bundle at `supporttools/static/supporttools/js/main.js` is built
388
+ at publish time by CI and distributed inside the PyPI wheel. Consuming apps do
389
+ not need Node.js. See `.github/workflows/cicd.yml` for the build step in the
390
+ `publish` job.
@@ -18,7 +18,7 @@ setup(
18
18
  name='Django-SupportTools',
19
19
  version=VERSION,
20
20
  packages=['supporttools'],
21
- author="UW-IT Student & Educational Technology Services",
21
+ author="UWIT Student & Educational Technology Services",
22
22
  author_email="aca-it@uw.edu",
23
23
  include_package_data=True,
24
24
  install_requires=[
@@ -0,0 +1 @@
1
+ 4.0dev3
@@ -0,0 +1,228 @@
1
+ # Copyright 2026 UW-IT, University of Washington
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ import logging
5
+
6
+ from django.conf import settings
7
+ from django.urls import NoReverseMatch, reverse
8
+ from userservice.user import UserService
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+
13
+ def normalize_mode_fields(entry):
14
+ # Treat entries with SPA markers as converted tools, even if mode is
15
+ # omitted. Legacy server tools do not include these fields.
16
+ is_converted = any(
17
+ entry.get(key) for key in ("route", "component_key", "vite_entry")
18
+ )
19
+ mode = entry.get("mode", "server")
20
+ if mode not in {"server", "spa"}:
21
+ mode = "server"
22
+ if is_converted:
23
+ mode = "spa"
24
+
25
+ route = entry.get("route")
26
+ component_key = entry.get("component_key")
27
+ # Converted tools are SPA-only; full reload is not supported for them.
28
+ requires_full_reload = False
29
+
30
+ # A SPA entry must declare both route and component_key. Converted tools
31
+ # that fail this contract are dropped from the Vue registry.
32
+ if mode == "spa" and not (route and component_key):
33
+ logger.warning(
34
+ "Skipping invalid SPA supporttools registry entry %r: "
35
+ "route and component_key are required for converted tools.",
36
+ entry.get("id") or entry.get("url_name") or entry.get("label"),
37
+ )
38
+ return None
39
+
40
+ return {
41
+ "mode": mode,
42
+ "route": route,
43
+ "component_key": component_key,
44
+ "requires_full_reload": requires_full_reload,
45
+ }
46
+
47
+
48
+ def _resolve_url(url_name, url_args=None, url_kwargs=None):
49
+ try:
50
+ return reverse(url_name, args=url_args or (), kwargs=url_kwargs or {})
51
+ except NoReverseMatch:
52
+ return None
53
+
54
+
55
+ def _default_view_registry(request):
56
+ entries = []
57
+ defaults = [
58
+ (10, "Support Home", "supporttools_home"),
59
+ (20, "User Override", "userservice_override"),
60
+ (30, "Status", "status_app.views.status"),
61
+ (40, "Persistent Messages", "manage_persistent_messages"),
62
+ (50, "Browse Student Web Service", "restclients_proxy",
63
+ ("sws", "student/v5.json"), {}),
64
+ (60, "Browse Person Web Service", "restclients_proxy",
65
+ ("pws", "identity/v2.json"), {}),
66
+ ]
67
+
68
+ for row in defaults:
69
+ if len(row) == 3:
70
+ order, label, url_name = row
71
+ url_args = ()
72
+ url_kwargs = {}
73
+ else:
74
+ order, label, url_name, url_args, url_kwargs = row
75
+
76
+ url = _resolve_url(url_name, url_args=url_args, url_kwargs=url_kwargs)
77
+ if url:
78
+ entries.append({
79
+ "id": url_name,
80
+ "section": "general",
81
+ "order": order,
82
+ "label": label,
83
+ "url_name": url_name,
84
+ "url": url,
85
+ "url_args": list(url_args),
86
+ "url_kwargs": url_kwargs,
87
+ "mode": "server",
88
+ "route": None,
89
+ "component_key": None,
90
+ "requires_full_reload": False,
91
+ })
92
+
93
+ return entries
94
+
95
+
96
+ def _extra_views_registry(request):
97
+ entries = []
98
+ extra_views = getattr(settings, "SUPPORTTOOLS_EXTRA_VIEWS", {})
99
+
100
+ for label, url_name in extra_views.items():
101
+ url = _resolve_url(url_name)
102
+ if not url:
103
+ continue
104
+
105
+ entries.append({
106
+ "id": url_name,
107
+ "section": "application",
108
+ "order": 100,
109
+ "label": label,
110
+ "url_name": url_name,
111
+ "url": url,
112
+ "url_args": [],
113
+ "url_kwargs": {},
114
+ "mode": "server",
115
+ "route": None,
116
+ "component_key": None,
117
+ "requires_full_reload": False,
118
+ })
119
+
120
+ return entries
121
+
122
+
123
+ def _settings_view_registry(request):
124
+ entries = []
125
+ raw_registry = getattr(settings, "SUPPORTTOOLS_VIEW_REGISTRY", [])
126
+
127
+ for entry in raw_registry:
128
+ if not isinstance(entry, dict):
129
+ continue
130
+
131
+ label = entry.get("label")
132
+ url_name = entry.get("url_name")
133
+ if not label or not url_name:
134
+ continue
135
+
136
+ url_args = entry.get("url_args", [])
137
+ url_kwargs = entry.get("url_kwargs", {})
138
+ url = _resolve_url(url_name, url_args=url_args, url_kwargs=url_kwargs)
139
+ if not url:
140
+ continue
141
+
142
+ mode_fields = normalize_mode_fields(entry)
143
+ if not mode_fields:
144
+ continue
145
+ entries.append({
146
+ "id": entry.get("id") or url_name,
147
+ "section": entry.get("section") or "application",
148
+ "explicit": True,
149
+ "order": int(entry.get("order", 100)),
150
+ "label": label,
151
+ "url_name": url_name,
152
+ "url": url,
153
+ "url_args": list(url_args),
154
+ "url_kwargs": dict(url_kwargs),
155
+ **mode_fields,
156
+ })
157
+
158
+ return entries
159
+
160
+
161
+ def _effective_view_registry(request):
162
+ # Structured VIEW_REGISTRY (preferred) and legacy EXTRA_VIEWS are both
163
+ # always included so that enabling SUPPORTTOOLS_VUE_ENABLED alone is
164
+ # sufficient for apps that already have SUPPORTTOOLS_EXTRA_VIEWS set.
165
+ # VIEW_REGISTRY entries take precedence; duplicates are dropped by url_name.
166
+ structured = _settings_view_registry(request)
167
+ legacy = _extra_views_registry(request)
168
+
169
+ seen = {e["url_name"] for e in structured}
170
+ merged = structured + [e for e in legacy if e["url_name"] not in seen]
171
+
172
+ seen.update(e["url_name"] for e in merged)
173
+ defaults = _default_view_registry(request)
174
+ combined = [e for e in defaults if e["url_name"] not in seen] + merged
175
+ return sorted(combined, key=lambda e: (e["section"], e["order"],
176
+ e["label"].lower()))
177
+
178
+
179
+ def supportools_globals(request):
180
+ user = UserService().get_original_user()
181
+ view_registry = _effective_view_registry(request)
182
+ user_agent = getattr(request, "user_agent", None)
183
+
184
+ params = {
185
+ "supporttools_user": user,
186
+ "supporttools_parent_app": getattr(settings,
187
+ "SUPPORTTOOLS_PARENT_APP", ""),
188
+ "supporttools_parent_app_url": getattr(settings,
189
+ "SUPPORTTOOLS_PARENT_APP_URL",
190
+ "/"),
191
+ "supporttools_extra_views": getattr(settings,
192
+ "SUPPORTTOOLS_EXTRA_VIEWS", {}),
193
+ "supporttools_vue_enabled": getattr(settings,
194
+ "SUPPORTTOOLS_VUE_ENABLED",
195
+ False),
196
+ "supporttools_view_registry": view_registry,
197
+ "supporttools_vue_context": {
198
+ "parent_app": getattr(settings, "SUPPORTTOOLS_PARENT_APP", ""),
199
+ "parent_app_url": getattr(settings,
200
+ "SUPPORTTOOLS_PARENT_APP_URL", "/"),
201
+ "user": user,
202
+ "is_mobile": bool(getattr(user_agent, "is_mobile", False)),
203
+ "is_tablet": bool(getattr(user_agent, "is_tablet", False)),
204
+ "is_desktop": bool(getattr(user_agent, "is_pc", False)),
205
+ "links": view_registry,
206
+ },
207
+ }
208
+ return (params)
209
+
210
+
211
+ def has_less_compiled(request):
212
+ """ See if django-compressor is being used to precompile less
213
+ """
214
+ key = getattr(settings, "COMPRESS_PRECOMPILERS", None)
215
+ has_less_precompiler = False
216
+ if key is not None and len(key) > 0:
217
+ for entry in key:
218
+ if entry[0] == "text/less":
219
+ has_less_precompiler = True
220
+ return {"has_less_compiled": has_less_precompiler}
221
+
222
+
223
+ def has_google_analytics(request):
224
+ ga_key = getattr(settings, 'GOOGLE_ANALYTICS_KEY', False)
225
+ return {
226
+ 'GOOGLE_ANALYTICS_KEY': ga_key,
227
+ 'has_google_analytics': ga_key
228
+ }