Skip to content

Commit

Permalink
16202 fix mapit button for internationalized decimal seperator
Browse files Browse the repository at this point in the history
  • Loading branch information
arthanson committed May 23, 2024
1 parent 6c51b89 commit 9fe3c9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion netbox/templates/dcim/device.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h5 class="card-header">{% trans "Device" %}</h5>
{% if object.latitude and object.longitude %}
{% if config.MAPS_URL %}
<div class="position-absolute top-50 end-0 translate-middle-y d-print-none">
<a href="{{ config.MAPS_URL }}{{ object.latitude }},{{ object.longitude }}" target="_blank" class="btn btn-primary">
<a href="{{ config.MAPS_URL }}{{ object.latitude|untranslate_decimal_separator }},{{ object.longitude|untranslate_decimal_separator }}" target="_blank" class="btn btn-primary">
<i class="mdi mdi-map-marker"></i> {% trans "Map It" %}
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion netbox/templates/dcim/site.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ <h5 class="card-header">{% trans "Site" %}</h5>
{% if object.latitude and object.longitude %}
{% if config.MAPS_URL %}
<div class="position-absolute top-50 end-0 translate-middle-y d-print-none">
<a href="{{ config.MAPS_URL }}{{ object.latitude }},{{ object.longitude }}" target="_blank" class="btn btn-primary">
<a href="{{ config.MAPS_URL }}{{ object.latitude|untranslate_decimal_separator }},{{ object.longitude|untranslate_decimal_separator }}" target="_blank" class="btn btn-primary">
<i class="mdi mdi-map-marker"></i> {% trans "Map It" %}
</a>
</div>
Expand Down
9 changes: 9 additions & 0 deletions netbox/utilities/templatetags/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from django.template.defaultfilters import date
from django.urls import NoReverseMatch, reverse
from django.utils import timezone
from django.utils.formats import get_format
from django.utils.safestring import mark_safe
from django.utils.translation import get_language

from core.models import ObjectType
from utilities.forms import get_selected_values, TableConfigForm
Expand All @@ -30,6 +32,7 @@
'startswith',
'status_from_tag',
'table_config_form',
'untranslate_decimal_separator',
'utilization_graph',
'validated_viewname',
'viewname',
Expand Down Expand Up @@ -301,3 +304,9 @@ def applied_filters(context, model, form, query_params):
'applied_filters': applied_filters,
'save_link': save_link,
}


@register.filter()
def untranslate_decimal_separator(number: str):
decimal_seperator = get_format('DECIMAL_SEPARATOR', get_language())
return str(number).replace(decimal_seperator, ".")

0 comments on commit 9fe3c9f

Please sign in to comment.