Skip to content

Commit fc4a1df

Browse files
🗃️ [#4486] Squashed qmatic appointments plugin migrations
1 parent 9eadbd0 commit fc4a1df

File tree

3 files changed

+87
-87
lines changed

3 files changed

+87
-87
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Generated by Django 4.2.11 on 2024-07-04 14:21
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
6+
import django_jsonform.models.fields
7+
8+
import openforms.appointments.contrib.qmatic.models
9+
10+
11+
class Migration(migrations.Migration):
12+
13+
replaces = [
14+
("qmatic", "0001_initial"),
15+
("qmatic", "0002_qmaticconfig_required_customer_fields"),
16+
("qmatic", "0003_strip_qmatic_service_v1"),
17+
]
18+
19+
initial = True
20+
21+
dependencies = [
22+
("zgw_consumers", "0012_auto_20210104_1039"),
23+
]
24+
25+
operations = [
26+
migrations.CreateModel(
27+
name="QmaticConfig",
28+
fields=[
29+
(
30+
"id",
31+
models.AutoField(
32+
auto_created=True,
33+
primary_key=True,
34+
serialize=False,
35+
verbose_name="ID",
36+
),
37+
),
38+
(
39+
"service",
40+
models.OneToOneField(
41+
help_text="The Qmatic Orchestra Calendar Public Appointment API service. Example: https://example.com:8443/calendar-backend/public/api/v1/",
42+
limit_choices_to={"api_type": "orc"},
43+
null=True,
44+
on_delete=django.db.models.deletion.PROTECT,
45+
related_name="+",
46+
to="zgw_consumers.service",
47+
verbose_name="Calendar API",
48+
),
49+
),
50+
(
51+
"required_customer_fields",
52+
django_jsonform.models.fields.ArrayField(
53+
base_field=models.CharField(
54+
choices=[
55+
("firstName", "First name"),
56+
("lastName", "Last name"),
57+
("email", "Email address"),
58+
("phone", "Phone number"),
59+
("addressLine1", "Street name and number"),
60+
("addressLine2", "Address line 2"),
61+
("addressCity", "City"),
62+
("addressState", "State"),
63+
("addressZip", "Postal code"),
64+
("addressCountry", "Country"),
65+
("identificationNumber", "Identification number"),
66+
(
67+
"externalId",
68+
"Unique customer identification/account number",
69+
),
70+
("dateOfBirth", "Birthday"),
71+
],
72+
max_length=50,
73+
),
74+
default=openforms.appointments.contrib.qmatic.models.get_default_customer_fields,
75+
help_text="Select the customer fields for the contact details step. Fields that you select here are REQUIRED fields for the user making the appointment. You must have at least one field to be able to identify the customer.",
76+
size=None,
77+
verbose_name="Required customer fields",
78+
),
79+
),
80+
],
81+
options={
82+
"verbose_name": "Qmatic configuration",
83+
},
84+
),
85+
]

src/openforms/appointments/contrib/qmatic/migrations/0003_strip_qmatic_service_v1.py

+2-30
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,11 @@
22
from django.db import migrations
33

44

5-
def strip_v1_suffix(apps, _):
6-
QmaticConfig = apps.get_model("qmatic", "QmaticConfig")
7-
config = QmaticConfig.objects.first()
8-
if config is None or not config.service:
9-
return
10-
11-
# zgw-consumers normalizes api_root to add a trailing slash
12-
if not (base := config.service.api_root).endswith("/v1/"):
13-
return
14-
15-
head, _ = base.rsplit("v1", 1)
16-
config.service.api_root = head
17-
config.service.save()
18-
19-
20-
def readd_v1_suffix(apps, _):
21-
QmaticConfig = apps.get_model("qmatic", "QmaticConfig")
22-
config = QmaticConfig.objects.first()
23-
if config is None or not config.service:
24-
return
25-
26-
if (base := config.service.api_root).endswith("/v1/"):
27-
return
28-
29-
# zgw-consumers normalizes api_root to add a trailing slash
30-
config.service.api_root = f"{base}v1/"
31-
config.service.save()
32-
33-
345
class Migration(migrations.Migration):
356

367
dependencies = [
378
("qmatic", "0002_qmaticconfig_required_customer_fields"),
389
]
3910

40-
operations = [migrations.RunPython(strip_v1_suffix, readd_v1_suffix)]
11+
# Removed as part of Open Forms 2.7 release cycle
12+
operations = []

src/openforms/appointments/contrib/qmatic/tests/test_migrations.py

-57
This file was deleted.

0 commit comments

Comments
 (0)