Skip to content

Commit

Permalink
allow more departments for each project
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Jan 9, 2024
1 parent 24bacef commit 3ee0063
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
5 changes: 2 additions & 3 deletions metadata_catalogue/nina/libs/harvesters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ def _process_project(project: dict):
p.customer, _ = Organization.objects.get_or_create(name=project.get("customer"))

for group in project.get("groups"):
p.department_group, _ = Department.objects.get_or_create(
d, _ = Department.objects.get_or_create(
extid=group.get("id"),
defaults={
"name": group.get("title"),
"slug": project.get("id"),
"description": group.get("description"),
},
)
# We expect only one department for project
break
p.departments.add(d)

p.save()

Expand Down
14 changes: 4 additions & 10 deletions metadata_catalogue/nina/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.8 on 2024-01-09 08:51
# Generated by Django 4.2.8 on 2024-01-09 10:51

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -9,9 +9,9 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
("taggit", "0006_rename_taggeditem_content_type_object_id_taggit_tagg_content_8fc721_idx"),
("organizations", "0006_alter_organization_slug"),
("datasets", "0006_content_valid"),
("taggit", "0006_rename_taggeditem_content_type_object_id_taggit_tagg_content_8fc721_idx"),
]

operations = [
Expand Down Expand Up @@ -91,14 +91,8 @@ class Migration(migrations.Migration):
),
migrations.AddField(
model_name="project",
name="department_group",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="projects",
to="nina.department",
),
name="departments",
field=models.ManyToManyField(blank=True, related_name="projects", to="nina.department"),
),
migrations.AddField(
model_name="project",
Expand Down
4 changes: 1 addition & 3 deletions metadata_catalogue/nina/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class Project(BaseProject):
status = models.CharField(max_length=50, null=True, blank=True)
category = models.ForeignKey("nina.Category", null=True, blank=True, on_delete=models.SET_NULL)
topics = models.ManyToManyField("nina.Topic", blank=True)
department_group = models.ForeignKey(
"nina.Department", null=True, blank=True, on_delete=models.SET_NULL, related_name="projects"
)
departments = models.ManyToManyField("nina.Department", blank=True, related_name="projects")
customer = models.ForeignKey("datasets.Organization", blank=True, on_delete=models.SET_NULL, null=True)

tags = TaggableManager()
Expand Down

0 comments on commit 3ee0063

Please sign in to comment.