-
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.
[#3362] Add a migration to clean up urls
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 3.2.21 on 2023-11-16 14:57 | ||
from django.db import migrations | ||
from django.db.migrations.state import StateApps | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
|
||
from furl import furl | ||
|
||
|
||
def cleanup_submission_urls( | ||
apps: StateApps, schema_editor: BaseDatabaseSchemaEditor | ||
) -> None: | ||
|
||
Submission = apps.get_model("submissions", "Submission") | ||
|
||
for submission in Submission.objects.all(): | ||
f = furl(submission.form_url) | ||
f.remove(fragment=True) | ||
submission.form_url = f.url | ||
|
||
submission.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("submissions", "0078_submission_finalised_registration_backend_key"), | ||
] | ||
|
||
operations = [migrations.RunPython(cleanup_submission_urls)] |