Skip to content
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

Reversing press URLs on journal sites in path mode #4577

Open
joemull opened this issue Jan 10, 2025 · 0 comments
Open

Reversing press URLs on journal sites in path mode #4577

joemull opened this issue Jan 10, 2025 · 0 comments

Comments

@joemull
Copy link
Member

joemull commented Jan 10, 2025

Problem description

When forming Janeway URLs in path mode, the press level of a site is often identified by the absence of a journal code, rather than the presence of a key or argument or path segment.

As a result, there is currently no way to dynamically build a named URL at the press level when working within the context of a journal page. This makes it difficult to create journal-level interfaces that refer to press interfaces and guide users between them.

Example:

<p> Note: This page lists all users with a role in
<i>{{ request.journal.name }}</i>. If a broader search is needed,
try <a href="{{ request.press.url }}/user/all/">All Users
at the press level</a>.</p>
{% comment %} The above URL is hardcoded because there is no other
way to form a press URL on a journal page at the moment. {% endcomment %}

You can do request.press.site_url or journal.press.site_url in most cases, but these are just context variables pointing to the press landing page. They do not take arguments and so cannot be used to reverse named urls.

The template tag site_url also does not work because, on path mode, it prepends the journal code.

@register.simple_tag(takes_context=True)
def site_url(context, url_name=None, *args):
request = context.get('request')
if url_name is not None:
path = reverse(url_name, args=args)
else:
path = None
if request and request.site_type:
return request.site_type.site_url(path=path)
else:
return path

This means the formed URL will always refer back to the journal. If you do {% site_url "press_all_users" %} that will just put out example.org/JOURNAL/press/user/all.

Proposed solution

An additional template tag press_url that allows you to reverse any press url, regardless of current page / request context. It could be used like this:

If a broader search is needed,
          try <a href="{% press_url 'press_all_users' %}">All Users
          at the press level</a>.

Alternative considered

An additional argument on the site_url template tag for a boolean called press. If True, the tag will use press as the site_type rather than the site_type of the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant