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

🗃️(dashboard) refactor DeliveryPoint and Entity models #243

Merged
merged 1 commit into from
Nov 28, 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
2 changes: 1 addition & 1 deletion src/dashboard/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ name = "pypi"
Django = "==5.1.3"
django-dsfr = "==1.4.3"
django-environ = "==0.11.2"
django-extensions = "==3.2.3"
gunicorn = "==23.0.0"
psycopg = {extras = ["pool", "binary"], version = "==3.2.3"}
whitenoise = "==6.8.2"

[dev-packages]
black = "==24.10.0"
django-extensions = "==3.2.3"
django-stubs = {extras = ["compatible-mypy"], version = "==5.1.1"}
djlint = "==1.36.1"
factory-boy = "==3.3.1"
Expand Down
152 changes: 76 additions & 76 deletions src/dashboard/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dashboard/apps/consent/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1.3 on 2024-11-21 11:26
# Generated by Django 5.1.3 on 2024-11-26 16:35

import django.db.models.deletion
import django.utils.timezone
Expand Down
22 changes: 11 additions & 11 deletions src/dashboard/apps/core/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ def users(self, create, extracted, **kwargs):
# Add the iterable of groups using bulk addition
self.users.add(*extracted)

@factory.post_generation
def proxy_for(self, create, extracted, **kwargs):
"""Method to add `proxy_for` after the entity is created."""
if not create or not extracted:
# Simple build, or nothing to add, do nothing.
return

self.proxy_for.add(*extracted)


class DeliveryPointFactory(factory.django.DjangoModelFactory):
"""Factory class for creating instances of the DeliveryPoint model."""

class Meta: # noqa: D106
model = DeliveryPoint

provider_id = factory.Sequence(lambda n: "provider_%d" % n)

@factory.post_generation
def entities(self, create, extracted, **kwargs):
"""Method to add entities after the delivery point is created."""
if not create or not extracted:
# Simple build, or nothing to add, do nothing.
return

# Add the iterable of groups using bulk addition
self.entities.add(*extracted)
provider_assigned_id = factory.Sequence(lambda n: "dp_%d" % n)
entity = factory.SubFactory(EntityFactory)
44 changes: 33 additions & 11 deletions src/dashboard/apps/core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Generated by Django 5.1.3 on 2024-11-21 11:26
# Generated by Django 5.1.3 on 2024-11-26 16:35

import django.db.models.deletion
import django.utils.timezone
import django_extensions.db.fields
import uuid
from django.conf import settings
from django.db import migrations, models
Expand Down Expand Up @@ -41,10 +43,26 @@ class Migration(migrations.Migration):
blank=True, null=True, verbose_name="updated at"
),
),
(
"slug",
django_extensions.db.fields.AutoSlugField(
blank=True,
editable=False,
populate_from="name",
unique=True,
verbose_name="slug",
),
),
(
"name",
models.CharField(max_length=64, unique=True, verbose_name="name"),
),
(
"proxy_for",
models.ManyToManyField(
blank=True, to="qcd_core.entity", verbose_name="proxy for"
),
),
(
"users",
models.ManyToManyField(
Expand All @@ -53,8 +71,8 @@ class Migration(migrations.Migration):
),
],
options={
"verbose_name": "Entity",
"verbose_name_plural": "Entities",
"verbose_name": "entity",
"verbose_name_plural": "entities",
"ordering": ["name"],
},
),
Expand Down Expand Up @@ -85,24 +103,28 @@ class Migration(migrations.Migration):
),
),
(
"provider_id",
models.CharField(max_length=64, verbose_name="provider id"),
"provider_assigned_id",
models.CharField(
max_length=64, verbose_name="provider assigned id"
),
),
(
"is_active",
models.BooleanField(default=True, verbose_name="is active"),
),
(
"entities",
models.ManyToManyField(
to="qcd_core.entity", verbose_name="entities"
"entity",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="qcd_core.entity",
verbose_name="entity",
),
),
],
options={
"verbose_name": "Delivery point",
"verbose_name_plural": "Delivery points",
"ordering": ["provider_id"],
"verbose_name": "delivery point",
"verbose_name_plural": "delivery points",
"ordering": ["provider_assigned_id"],
},
),
]
Loading
Loading