Skip to content

Commit c2ff114

Browse files
🗃️ [#4486] Squash payment app migrations
1 parent 943056b commit c2ff114

File tree

2 files changed

+120
-13
lines changed

2 files changed

+120
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Generated by Django 4.2.11 on 2024-07-04 14:13
2+
3+
import uuid
4+
5+
import django.db.models.deletion
6+
from django.db import migrations, models
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
replaces = [
12+
("payments", "0001_initial"),
13+
("payments", "0002_submissionpayment_public_order_id"),
14+
("payments", "0003_set_public_order_id"),
15+
("payments", "0004_auto_20211028_1141"),
16+
("payments", "0005_remove_submissionpayment_form_url"),
17+
("payments", "0006_auto_20211111_1614"),
18+
("payments", "0007_alter_submissionpayment_plugin_options"),
19+
("payments", "0008_auto_20240130_1436"),
20+
]
21+
22+
initial = True
23+
24+
dependencies = [
25+
("submissions", "0001_initial_to_openforms_v230"),
26+
]
27+
28+
operations = [
29+
migrations.CreateModel(
30+
name="SubmissionPayment",
31+
fields=[
32+
(
33+
"id",
34+
models.AutoField(
35+
auto_created=True,
36+
primary_key=True,
37+
serialize=False,
38+
verbose_name="ID",
39+
),
40+
),
41+
(
42+
"uuid",
43+
models.UUIDField(
44+
default=uuid.uuid4, unique=True, verbose_name="UUID"
45+
),
46+
),
47+
("created", models.DateTimeField(auto_now_add=True)),
48+
(
49+
"plugin_id",
50+
models.CharField(max_length=100, verbose_name="Payment backend"),
51+
),
52+
(
53+
"plugin_options",
54+
models.JSONField(
55+
blank=True,
56+
help_text="Copy of payment options at time of initializing payment.",
57+
null=True,
58+
verbose_name="Payment options",
59+
),
60+
),
61+
(
62+
"amount",
63+
models.DecimalField(
64+
decimal_places=2,
65+
default=0,
66+
help_text="Total payment amount.",
67+
max_digits=8,
68+
verbose_name="payment amount",
69+
),
70+
),
71+
(
72+
"status",
73+
models.CharField(
74+
choices=[
75+
("started", "Started by user"),
76+
("processing", "Backend is processing"),
77+
("failed", "Cancelled or failed"),
78+
("completed", "Completed by user"),
79+
("registered", "Completed and registered"),
80+
],
81+
default="started",
82+
help_text="Status of the payment process in the configured backend.",
83+
max_length=32,
84+
verbose_name="payment status",
85+
),
86+
),
87+
(
88+
"submission",
89+
models.ForeignKey(
90+
on_delete=django.db.models.deletion.CASCADE,
91+
related_name="payments",
92+
to="submissions.submission",
93+
),
94+
),
95+
(
96+
"public_order_id",
97+
models.CharField(
98+
blank=True,
99+
help_text="The order ID to be sent to the payment provider. This ID is built by concatenating an optional global prefix, the submission public reference and a unique incrementing ID.",
100+
max_length=32,
101+
verbose_name="Order ID",
102+
),
103+
),
104+
],
105+
options={
106+
"verbose_name": "submission payment details",
107+
"verbose_name_plural": "submission payment details",
108+
},
109+
),
110+
migrations.AddConstraint(
111+
model_name="submissionpayment",
112+
constraint=models.UniqueConstraint(
113+
condition=models.Q(("public_order_id", ""), _negated=True),
114+
fields=("public_order_id",),
115+
name="unique_public_order_id",
116+
),
117+
),
118+
]
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
# Generated by Django 2.2.24 on 2021-10-22 14:44
22

33
from django.db import migrations
4-
from django.db.models import F
5-
6-
7-
def set_public_order_id(apps, _):
8-
SubmissionPayment = apps.get_model("payments", "SubmissionPayment")
9-
qs = SubmissionPayment.objects.filter(public_order_id="", order_id__isnull=False)
10-
11-
# the old order IDs before these public_order_ids are included have the
12-
# year prefix already. We do not need to calculate it (again).
13-
qs.update(public_order_id=F("order_id"))
144

155

166
class Migration(migrations.Migration):
@@ -19,6 +9,5 @@ class Migration(migrations.Migration):
199
("payments", "0002_submissionpayment_public_order_id"),
2010
]
2111

22-
operations = [
23-
migrations.RunPython(set_public_order_id, migrations.RunPython.noop),
24-
]
12+
# Removed as part of Open Forms 2.7 release cycle
13+
operations = []

0 commit comments

Comments
 (0)