Skip to content

Commit

Permalink
Merge pull request #4491 from open-formulieren/release/4486-squash-mi…
Browse files Browse the repository at this point in the history
…grations

Squash migrations for the 2.7 release
  • Loading branch information
sergei-maertens authored Jul 4, 2024
2 parents ca65f8a + 8db60ef commit 953b717
Show file tree
Hide file tree
Showing 42 changed files with 1,206 additions and 1,759 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Generated by Django 4.2.11 on 2024-07-04 14:21

import django.db.models.deletion
from django.db import migrations, models

import django_jsonform.models.fields

import openforms.appointments.contrib.qmatic.models


class Migration(migrations.Migration):

replaces = [
("qmatic", "0001_initial"),
("qmatic", "0002_qmaticconfig_required_customer_fields"),
("qmatic", "0003_strip_qmatic_service_v1"),
]

initial = True

dependencies = [
("zgw_consumers", "0012_auto_20210104_1039"),
]

operations = [
migrations.CreateModel(
name="QmaticConfig",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"service",
models.OneToOneField(
help_text="The Qmatic Orchestra Calendar Public Appointment API service. Example: https://example.com:8443/calendar-backend/public/api/v1/",
limit_choices_to={"api_type": "orc"},
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="zgw_consumers.service",
verbose_name="Calendar API",
),
),
(
"required_customer_fields",
django_jsonform.models.fields.ArrayField(
base_field=models.CharField(
choices=[
("firstName", "First name"),
("lastName", "Last name"),
("email", "Email address"),
("phone", "Phone number"),
("addressLine1", "Street name and number"),
("addressLine2", "Address line 2"),
("addressCity", "City"),
("addressState", "State"),
("addressZip", "Postal code"),
("addressCountry", "Country"),
("identificationNumber", "Identification number"),
(
"externalId",
"Unique customer identification/account number",
),
("dateOfBirth", "Birthday"),
],
max_length=50,
),
default=openforms.appointments.contrib.qmatic.models.get_default_customer_fields,
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.",
size=None,
verbose_name="Required customer fields",
),
),
],
options={
"verbose_name": "Qmatic configuration",
},
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,11 @@
from django.db import migrations


def strip_v1_suffix(apps, _):
QmaticConfig = apps.get_model("qmatic", "QmaticConfig")
config = QmaticConfig.objects.first()
if config is None or not config.service:
return

# zgw-consumers normalizes api_root to add a trailing slash
if not (base := config.service.api_root).endswith("/v1/"):
return

head, _ = base.rsplit("v1", 1)
config.service.api_root = head
config.service.save()


def readd_v1_suffix(apps, _):
QmaticConfig = apps.get_model("qmatic", "QmaticConfig")
config = QmaticConfig.objects.first()
if config is None or not config.service:
return

if (base := config.service.api_root).endswith("/v1/"):
return

# zgw-consumers normalizes api_root to add a trailing slash
config.service.api_root = f"{base}v1/"
config.service.save()


class Migration(migrations.Migration):

dependencies = [
("qmatic", "0002_qmaticconfig_required_customer_fields"),
]

operations = [migrations.RunPython(strip_v1_suffix, readd_v1_suffix)]
# Removed as part of Open Forms 2.7 release cycle
operations = []
57 changes: 0 additions & 57 deletions src/openforms/appointments/contrib/qmatic/tests/test_migrations.py

This file was deleted.

1 change: 0 additions & 1 deletion src/openforms/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@
"openforms.submissions",
"openforms.logging.apps.LoggingAppConfig",
"openforms.contrib.brk",
"openforms.contrib.brp",
"openforms.contrib.digid_eherkenning",
"openforms.contrib.haal_centraal",
"openforms.contrib.kadaster",
Expand Down
15 changes: 1 addition & 14 deletions src/openforms/config/migrations/0054_enable_new_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,10 @@
from django.db import migrations


def enable_new_builder(apps, _):
GlobalConfiguration = apps.get_model("config", "GlobalConfiguration")
# there can only ever be one record
config = GlobalConfiguration.objects.first()
if config is None or config.enable_react_formio_builder:
return

config.enable_react_formio_builder = True
config.save()


class Migration(migrations.Migration):

dependencies = [
("config", "0001_initial_to_v250"),
]

operations = [
migrations.RunPython(enable_new_builder, migrations.RunPython.noop),
]
operations = []
Loading

0 comments on commit 953b717

Please sign in to comment.