Skip to content

Commit

Permalink
Remove contact data fields from poi
Browse files Browse the repository at this point in the history
  • Loading branch information
lunars97 committed Nov 25, 2024
1 parent 1e6dde2 commit 8a1c879
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 16 deletions.
3 changes: 0 additions & 3 deletions integreat_cms/cms/forms/pois/poi_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ class Meta:
"longitude",
"location_on_map",
"icon",
"website",
"email",
"phone_number",
"category",
"opening_hours",
"temporarily_closed",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Generated by Django 4.2.16 on 2024-11-06 12:57
from __future__ import annotations

from typing import TYPE_CHECKING
from django.db import migrations

if TYPE_CHECKING:
from django.apps.registry import Apps


def create_primary_contact(apps: Apps) -> None:
"""
Create primary contact from the poi contact data
:param apps: The configuration of installed applications
"""
POI = apps.get_model("cms", "POI")
Contact = apps.get_model("cms", "Contact")
for poi in POI.objects.all():
if poi.email or poi.phone_number or poi.website:
primary_contact = Contact.objects.create(
primary_email=poi.email,
primary_phone_number=poi.phone_number,
primary_website=poi.website,
point_of_contact_for="",
name="",
location=poi,
)
primary_contact.save()


class Migration(migrations.Migration):
"""
Migrate contact data from poi to contacts model
"""

dependencies = [
("cms", "0108_rename_contact_title_to_point_of_contact_for"),
]

operations = [
migrations.RunPython(create_primary_contact),
migrations.RemoveField(
model_name="poi",
name="email",
),
migrations.RemoveField(
model_name="poi",
name="phone_number",
),
migrations.RemoveField(
model_name="poi",
name="website",
),
]
8 changes: 0 additions & 8 deletions integreat_cms/cms/models/pois/poi.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ class POI(AbstractContentModel):
verbose_name=_("archived"),
help_text=_("Whether or not the location is read-only and hidden in the API."),
)
website = models.URLField(max_length=250, blank=True, verbose_name=_("website"))
email = models.EmailField(
blank=True,
verbose_name=_("email address"),
)
phone_number = models.CharField(
max_length=250, blank=True, verbose_name=_("phone number")
)
category = models.ForeignKey(
POICategory,
on_delete=models.PROTECT,
Expand Down
1 change: 0 additions & 1 deletion integreat_cms/cms/templates/pois/poi_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ <h3 class="font-bold text-black heading">
</div>
<div id="right-sidebar-column"
class="flex flex-col flex-wrap 3xl:col-end-3 4xl:col-end-auto md:w-full">
{% include "./poi_form_sidebar/contact_box.html" with box_id="poi-contact" %}
{% include "./poi_form_sidebar/opening_hours_box.html" with box_id="poi-opening-hours" no_padding=True %}
{% include "./poi_form_sidebar/category_box.html" with box_id="poi-category" %}
{% include "./poi_form_sidebar/icon_box.html" with box_id="poi-icon" %}
Expand Down
7 changes: 3 additions & 4 deletions integreat_cms/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2733,16 +2733,15 @@ msgstr "Name"
msgid "location"
msgstr "Ort"

#: cms/models/contact/contact.py cms/models/pois/poi.py
#: cms/models/contact/contact.py
msgid "email address"
msgstr "E-Mail-Adresse"

#: cms/models/contact/contact.py cms/models/pois/poi.py
#: cms/models/contact/contact.py
msgid "phone number"
msgstr "Telefonnummer"

#: cms/models/contact/contact.py cms/models/pois/poi.py
#: cms/models/users/organization.py
#: cms/models/contact/contact.py cms/models/users/organization.py
msgid "website"
msgstr "Webseite"

Expand Down

0 comments on commit 8a1c879

Please sign in to comment.