Skip to content

Commit

Permalink
[#3688] Add new model
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos authored and sergei-maertens committed Mar 22, 2024
1 parent beb52f2 commit 33bc8b4
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 4.2.10 on 2024-03-21 11:36

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


class Migration(migrations.Migration):

dependencies = [
("submissions", "0004_auto_20231128_1536"),
("registrations_objects_api", "0013_objectsapiregistrationdata"),
]

operations = [
migrations.RemoveField(
model_name="objectsapiregistrationdata",
name="attachment_urls",
),
migrations.CreateModel(
name="ObjectsAPISubmissionAttachment",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"document_url",
models.URLField(
help_text="The URL of the submission attachment registered in the Documents API.",
verbose_name="document_url",
),
),
(
"submission_file_attachment",
models.ForeignKey(
help_text="The submission file attachment.",
on_delete=django.db.models.deletion.CASCADE,
to="submissions.submissionfileattachment",
verbose_name="submission file attachment",
),
),
],
),
]
24 changes: 16 additions & 8 deletions src/openforms/registrations/contrib/objects_api/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError
from django.db import models
from django.template.loader import render_to_string
Expand Down Expand Up @@ -222,12 +221,21 @@ class ObjectsAPIRegistrationData(models.Model):
help_text=_("The CSV URL of the document on the Documents API."),
blank=True,
)
attachment_urls = ArrayField(
models.URLField(
_("attachment url"), help_text=_("The attachment URL on the Documents API.")


class ObjectsAPISubmissionAttachment(models.Model):
"""A utility model to link a submission file attachment with the Documents API URL."""

submission_file_attachment = models.ForeignKey(
"submissions.SubmissionFileAttachment",
on_delete=models.CASCADE,
verbose_name=_("submission file attachment"),
help_text=_("The submission file attachment."),
)

document_url = models.URLField(
_("document_url"),
help_text=_(
"The URL of the submission attachment registered in the Documents API."
),
verbose_name=_("attachment urls"),
help_text=_("The list of attachment URLs on the Documents API."),
blank=True,
default=list,
)

0 comments on commit 33bc8b4

Please sign in to comment.