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.
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:
janeway/src/templates/admin/core/manager/users/list.html
Lines 28 to 33 in 6982329
You can do
request.press.site_urlorjournal.press.site_urlin 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_urlalso does not work because, on path mode, it prepends the journal code.janeway/src/core/templatetags/fqdn.py
Lines 33 to 44 in 6982329
This means the formed URL will always refer back to the journal. If you do
{% site_url "press_all_users" %}that will just put outexample.org/JOURNAL/press/user/all.Proposed solution
An additional template tag
press_urlthat allows you to reverse any press url, regardless of current page / request context. It could be used like this:Alternative considered
An additional argument on the
site_urltemplate tag for a boolean calledpress. IfTrue, the tag will use press as thesite_typerather than thesite_typeof the request.