-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4894 from open-formulieren/cleanup/3283-temporary…
…-file-upload-submission-not-nullable 💥 Make TemporaryFileUpload.submission non-nullable
- Loading branch information
Showing
8 changed files
with
85 additions
and
38 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
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,33 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
from pathlib import Path | ||
|
||
import django | ||
|
||
SRC_DIR = Path(__file__).parent.parent / "src" | ||
sys.path.insert(0, str(SRC_DIR.resolve())) | ||
|
||
|
||
def check_for_null_submissions_in_temporary_uploads(): | ||
from openforms.submissions.models import TemporaryFileUpload | ||
|
||
problematic_uploads = TemporaryFileUpload.objects.filter(submission__isnull=True) | ||
if problematic_uploads.exists(): | ||
print("There are still legacy temporary uploads. You must clear those first.") | ||
return False | ||
|
||
return True | ||
|
||
|
||
def main(skip_setup=False) -> bool: | ||
from openforms.setup import setup_env | ||
|
||
if not skip_setup: | ||
setup_env() | ||
django.setup() | ||
|
||
return check_for_null_submissions_in_temporary_uploads() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
32 changes: 32 additions & 0 deletions
32
...ons/migrations/0013_remove_temporaryfileupload_non_legacy_submission_not_null_and_more.py
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,32 @@ | ||
# Generated by Django 4.2.17 on 2024-12-09 15:04 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("submissions", "0012_alter_submission_price"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveConstraint( | ||
model_name="temporaryfileupload", | ||
name="non_legacy_submission_not_null", | ||
), | ||
migrations.RemoveField( | ||
model_name="temporaryfileupload", | ||
name="legacy", | ||
), | ||
migrations.AlterField( | ||
model_name="temporaryfileupload", | ||
name="submission", | ||
field=models.ForeignKey( | ||
help_text="Submission the temporary file upload belongs to.", | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="submissions.submission", | ||
verbose_name="submission", | ||
), | ||
), | ||
] |
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
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