Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the on_delete value of the homepage_layout FK #93

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion dje/management/commands/flushdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def add_arguments(self, parser):

def handle(self, *args, **options):
super().handle(*args, **options)
dataspace = self.dataspace

models = ALL_MODELS[:] # Making a copy to not impact the original list
models += WORKFLOW_MODELS
Expand All @@ -52,7 +53,11 @@ def handle(self, *args, **options):
Webhook,
])

dataspace = self.dataspace
# Clear the associated_product_relation_status FK values so the
# ProductRelationStatus model can be flushed before the UsagePolicy model.
usage_policies = UsagePolicy.objects.filter(dataspace=dataspace)
usage_policies.update(associated_product_relation_status=None)

for model_class in models:
qs = get_unsecured_manager(model_class).filter(dataspace=dataspace)
if options['verbosity'] > 1:
Expand Down
28 changes: 28 additions & 0 deletions dje/migrations/0003_alter_dejacodeuser_homepage_layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0.3 on 2024-05-08 08:26

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


class Migration(migrations.Migration):

dependencies = [
("dje", "0002_initial"),
("reporting", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="dejacodeuser",
name="homepage_layout",
field=models.ForeignKey(
blank=True,
help_text="Select a Card layout that provides the query results on the DejaCode homepage that are useful and interesting to you.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
serialize=False,
to="reporting.cardlayout",
),
),
]
2 changes: 1 addition & 1 deletion dje/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ class DejacodeUser(AbstractUser):
null=True,
blank=True,
related_name="+",
on_delete=models.CASCADE,
on_delete=models.SET_NULL,
serialize=False,
help_text=_(
"Select a Card layout that provides the query results on the "
Expand Down