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

[6958] apps/budgeting: display map or list as back link text depending on mo… #4879

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions meinberlin/apps/budgeting/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from urllib.parse import parse_qs
from urllib.parse import urlparse

import django_filters
Expand Down Expand Up @@ -135,13 +136,22 @@ def get_back(self):
parsed_url = urlparse(referer)
match = resolve(parsed_url.path)
if match.url_name == "project-detail" or match.url_name == "module-detail":
return referer + "#proposal_{}".format(self.object.id)
return None
return None
back_mode = None
back_string = _("map")
if "mode" in parse_qs(parsed_url.query):
back_mode = parse_qs(parsed_url.query)["mode"][0]
if back_mode == "list":
back_string = _("list")
back_link = referer + "#proposal_{}".format(self.object.id)
return back_link, back_string
return None, None
return None, None

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["back"] = self.get_back()
back_link, back_string = self.get_back()
context["back"] = back_link
context["back_string"] = back_string
return context


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
<li>
{% if back %}
<a href="{{ back }}">
<i class="fa fa-arrow-left" aria-hidden="true"></i>
{% if back_string %}
{{ back_string }}
{% else %}
{% translate 'map' %}
{% endif %}
</a>
{% else %}
<a href="{{ module.get_detail_url }}">
{% endif %}
<i class="fa fa-arrow-left" aria-hidden="true"></i>
{% translate 'list' %}
{% translate 'back' %}
</a>
{% endif %}
</li>
</ul>
</nav>
Expand Down