Skip to content

Commit 4b482f7

Browse files
committed
Only save the absolute path
1 parent fbc9834 commit 4b482f7

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

integreat_cms/cms/models/contact/contact.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def referring_page_translations(self) -> QuerySet[PageTranslation]:
182182
return PageTranslation.objects.filter(
183183
id__in=(
184184
Link.objects.filter(
185-
url__url=self.full_url,
185+
url__url=self.absolute_url,
186186
content_type=PageTranslationLinklist.content_type(),
187187
).values("object_id")
188188
),
@@ -200,7 +200,7 @@ def referring_poi_translations(self) -> QuerySet[POITranslation]:
200200
return POITranslation.objects.filter(
201201
id__in=(
202202
Link.objects.filter(
203-
url__url=self.full_url,
203+
url__url=self.absolute_url,
204204
content_type=POITranslationLinklist.content_type(),
205205
).values("object_id")
206206
),
@@ -218,7 +218,7 @@ def referring_event_translations(self) -> QuerySet[EventTranslation]:
218218
return EventTranslation.objects.filter(
219219
id__in=(
220220
Link.objects.filter(
221-
url__url=self.full_url,
221+
url__url=self.absolute_url,
222222
content_type=EventTranslationLinklist.content_type(),
223223
).values("object_id")
224224
),
@@ -232,7 +232,8 @@ def referring_objects(self) -> Generator[AbstractContentTranslation]:
232232
:return: all objects referring to this contact
233233
"""
234234
return (
235-
link.content_object for link in Link.objects.filter(url__url=self.full_url)
235+
link.content_object
236+
for link in Link.objects.filter(url__url=self.absolute_url)
236237
)
237238

238239
def archive(self) -> None:
@@ -258,13 +259,13 @@ def copy(self) -> None:
258259
self.save()
259260

260261
@cached_property
261-
def full_url(self) -> str:
262+
def absolute_url(self) -> str:
262263
"""
263-
This property returns the full url of this contact
264+
This property returns the absolute url of this contact
264265
265266
:return: The full url
266267
"""
267-
return f"{settings.BASE_URL}/{self.location.region.slug}/contact/{self.id}/"
268+
return f"/{self.location.region.slug}/contact/{self.id}/"
268269

269270
class Meta:
270271
verbose_name = _("contact")

integreat_cms/cms/templates/contacts/contact_card.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
{% spaceless %}
44
<div contenteditable="false"
55
data-contact-id="{{ contact.pk }}"
6-
data-contact-url="{{ contact.full_url }}"
6+
data-contact-url="{{ contact.absolute_url }}"
77
class="contact-card notranslate"
88
dir="ltr"
99
translate="no">
1010
{# djlint:off H021 #}
11-
<a href="{{ contact.full_url }}" style="display: none">Contact</a>
11+
<a href="{{ contact.absolute_url }}" style="display: none">Contact</a>
1212
{# djlint:on #}
1313
{% if contact %}
1414
{% if contact.name or contact.point_of_contact_for %}

integreat_cms/cms/views/utils/contact_utils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from django.core.exceptions import PermissionDenied
88
from django.http import HttpResponse, JsonResponse
99
from django.shortcuts import get_object_or_404, render
10-
from django.urls import reverse
1110
from django.views.decorators.http import require_POST
1211

1312
from ...decorators import permission_required
@@ -53,10 +52,7 @@ def search_contact_ajax(
5352
{
5453
"data": [
5554
{
56-
"url": reverse(
57-
"get_contact",
58-
kwargs={"contact_id": result.id, "region_slug": region_slug},
59-
),
55+
"url": result.absolute_url,
6056
"name": result.get_repr_short,
6157
}
6258
for result in results

integreat_cms/static/src/js/forms/tinymce-init.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ window.addEventListener("load", () => {
107107
link_default_target: "",
108108
document_base_url: tinymceConfig.getAttribute("data-webapp-url"),
109109
relative_urls: false,
110+
convert_urls: false,
110111
remove_script_host: false,
111112
branding: false,
112113
paste_as_text: true,

0 commit comments

Comments
 (0)