-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: David Venhoff <[email protected]> Co-authored-by: Peter Nerlich <[email protected]>
- Loading branch information
1 parent
85d4c0d
commit e01c256
Showing
22 changed files
with
722 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -958,7 +958,7 @@ | |
"fields": { | ||
"title": "Integrationsbeauftragte", | ||
"name": "Martina Musterfrau", | ||
"poi": 6, | ||
"location": 6, | ||
"email": "[email protected]", | ||
"phone_number": "0123456789", | ||
"website": "", | ||
|
@@ -973,7 +973,7 @@ | |
"fields": { | ||
"title": "Integrationsberaterin", | ||
"name": "Melanie Musterfrau", | ||
"poi": 6, | ||
"location": 6, | ||
"email": "[email protected]", | ||
"phone_number": "0987654321", | ||
"website": "www.random-page.com", | ||
|
@@ -988,7 +988,7 @@ | |
"fields": { | ||
"title": "Integrationsbeauftragte", | ||
"name": "Mariana Musterfrau", | ||
"poi": 6, | ||
"location": 6, | ||
"email": "[email protected]", | ||
"phone_number": "0123456789", | ||
"website": "https://integreat-app.de/", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
""" | ||
Forms for creating and modifying contact objects | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import TYPE_CHECKING | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from ...models import Contact | ||
from ..custom_model_form import CustomModelForm | ||
|
||
if TYPE_CHECKING: | ||
from typing import Any | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ContactForm(CustomModelForm): | ||
""" | ||
Form for creating and modifying contact objects | ||
""" | ||
|
||
class Meta: | ||
""" | ||
This class contains additional meta configuration of the form class, see the :class:`django.forms.ModelForm` | ||
for more information. | ||
""" | ||
|
||
#: The model of this :class:`django.forms.ModelForm` | ||
model = Contact | ||
#: The fields of the model which should be handled by this form | ||
fields = [ | ||
"title", | ||
"name", | ||
"location", | ||
"email", | ||
"phone_number", | ||
"website", | ||
] | ||
|
||
error_messages = { | ||
"location": {"invalid_choice": _("Location cannot be empty.")} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Generated by Django 4.2.13 on 2024-08-20 16:10 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
""" | ||
Make the fields "title" and "name" not mandatory. | ||
Rename the field from "poi" to "location". | ||
""" | ||
|
||
dependencies = [ | ||
("cms", "0105_languagetreenode_languagetreenode_unique_lft_tree_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="contact", | ||
name="title", | ||
field=models.CharField(blank=True, max_length=200, verbose_name="title"), | ||
), | ||
migrations.AlterField( | ||
model_name="contact", | ||
name="name", | ||
field=models.CharField(blank=True, max_length=200, verbose_name="name"), | ||
), | ||
migrations.RenameField( | ||
model_name="contact", | ||
old_name="poi", | ||
new_name="location", | ||
), | ||
migrations.AlterField( | ||
model_name="contact", | ||
name="location", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.PROTECT, | ||
related_name="contacts", | ||
to="cms.poi", | ||
verbose_name="location", | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="contact", | ||
constraint=models.UniqueConstraint( | ||
models.F("location"), | ||
condition=models.Q(("title", "")), | ||
name="contact_singular_empty_title_per_location", | ||
violation_error_message="Only one contact per location can have an empty title.", | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="contact", | ||
constraint=models.CheckConstraint( | ||
check=models.Q( | ||
models.Q(("title", ""), _negated=True), | ||
models.Q(("name", ""), _negated=True), | ||
models.Q(("email", ""), _negated=True), | ||
models.Q(("phone_number", ""), _negated=True), | ||
models.Q(("website", ""), _negated=True), | ||
_connector="OR", | ||
), | ||
name="contact_non_empty", | ||
violation_error_message="One of the following fields must be filled: title, name, e-mail, phone number, website.", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.