Skip to content

Commit 9d56784

Browse files
Fix contact insertion (#3305)
* Fix contact insertion On the testserver, we have multiple possible backend urls. So instead of using full urls, we can just use relative urls (For some reason called absolute urls in our codebase) * Just use `reverse` instead of manually coding url * Only save the absolute path --------- Co-authored-by: charludo <github@charlotteharludo.com>
1 parent e4698a1 commit 9d56784

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def search_contact_ajax(
5454
{
5555
"data": [
5656
{
57-
"url": result.full_url,
57+
"url": result.absolute_url,
5858
"name": result.get_repr_short,
5959
}
6060
for result in results

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ window.addEventListener("load", () => {
106106
link_target_list: false,
107107
link_default_target: "",
108108
document_base_url: tinymceConfig.getAttribute("data-webapp-url"),
109-
relative_urls: false,
109+
convert_urls: false,
110110
remove_script_host: false,
111111
branding: false,
112112
paste_as_text: true,

0 commit comments

Comments
 (0)