-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate static urls #11571
base: dev/8.0.x
Are you sure you want to change the base?
Generate static urls #11571
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Principle makes sense. Noticed one behavior change I think we should look into. Will kick the tires again after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cross-checked this against the new listurls
feature likely to land in Django 5.2 and noticed that by keying the dict on name
, we're overwriting and losing additional routes that lack a name, e.g. tileserver/<path>
.
Line 692 in dbd103a
re_path(r"^tileserver/(?P<path>.*)$", TileserverProxyView.as_view()), |
Maybe we can have an additional data structure to hold unnamed routes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can arches_urls.htm
be removed from the project template?
|
||
1. Then update your project: | ||
``` | ||
python manage.py updateproject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to let people know that they can delete their arches_urls.htm
file (I'd suggest using update project, but that might be a little intrusive)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, just circling back here. I think the issue I mentioned above about unnamed routes is not so serious, given that we weren't using them on the front end before.
But there's a similar issue with routes we do use on the frontend like plugins
.
There are four routes named "plugins". This is fine, since reverse()
matches on the number and names of args:
Lines 652 to 655 in f3390ef
path("plugins/<uuid:pluginid>", PluginView.as_view(), name="plugins"), | |
path("plugins/<uuid:pluginid>/<path:path>", PluginView.as_view(), name="plugins"), | |
path("plugins/<slug:slug>", PluginView.as_view(), name="plugins"), | |
path("plugins/<slug:slug>/<path:path>", PluginView.as_view(), name="plugins"), |
But since we're keying on name, we can hold at most one. The one that wins out is:
"plugins": "/plugins/{slug}/{path}",
That's the form we happen to be using in the controlled list manager, e.g. /plugins/controlled-list-manager/item/pk
However, the bulk data manager uses
/plugins/bulk-data-manager,
And I don't think a client could generate the URL for that, if this test case is right:
diff --git a/arches/app/src/arches/utils/generate-arches-url.test.ts b/arches/app/src/arches/utils/generate-arches-url.test.ts
index 68fab4bf88..d7f752450f 100644
--- a/arches/app/src/arches/utils/generate-arches-url.test.ts
+++ b/arches/app/src/arches/utils/generate-arches-url.test.ts
@@ -7,9 +7,14 @@ global.ARCHES_URLS = {
another_url: "/admin/another/{id}",
multi_interpolation_url:
"/{language_code}/resource/{resource_id}/edit/{field_id}/version/{version_id}",
+ plugins: "/plugins/{slug}/{path}",
};
describe("generateArchesURL", () => {
+ it("should return simple plugin url", () => {
+ const result = generateArchesURL("plugins", { slug: "bulk-data-manager" });
+ expect(result).toBe("/plugins/bulk-data-manager");
+ });
it("should return a valid URL with specified language code and parameters", () => {
const result = generateArchesURL("example_url", { id: "123" }, "fr");
expect(result).toBe("/fr/admin/example/123");
FAIL arches/app/src/arches/utils/generate-arches-url.test.ts > generateArchesURL > should return simple plugin url
AssertionError: expected '/plugins/bulk-data-manager/{path}' to be '/plugins/bulk-data-manager' // Object.is equality
- Expected
+ Received
- /plugins/bulk-data-manager
+ /plugins/bulk-data-manager/{path}
Do you see the same?
Types of changes
Description of Change
This removes dependency on
arches_urls.htm
for all Vue frontend work.Issues Solved
Closes #11567
Checklist
Accessibility Checklist
Developer Guide
Ticket Background
Further comments