Skip to content

Commit

Permalink
add department
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Jan 8, 2024
1 parent 2b7e671 commit 220e399
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
23 changes: 23 additions & 0 deletions metadata_catalogue/nina/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.contrib.admin import ModelAdmin, register

from .models import Category, Department, Project, Topic


@register(Project)
class ProjectAdmin(ModelAdmin):
pass


@register(Department)
class DepartmentAdmin(ModelAdmin):
pass


@register(Category)
class CategoryAdmin(ModelAdmin):
pass


@register(Topic)
class TopicAdmin(ModelAdmin):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated by Django 4.2.8 on 2024-01-08 09:35

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


class Migration(migrations.Migration):
dependencies = [
("organizations", "0006_alter_organization_slug"),
("nina", "0001_initial"),
]

operations = [
migrations.CreateModel(
name="Department",
fields=[
(
"organization_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="organizations.organization",
),
),
],
options={
"verbose_name": "organization",
"verbose_name_plural": "organizations",
"ordering": ["name"],
"abstract": False,
},
bases=("organizations.organization",),
),
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",
),
),
]
8 changes: 8 additions & 0 deletions metadata_catalogue/nina/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from organizations.models import Organization
from taggit.managers import TaggableManager

from metadata_catalogue.projects.models import BaseProject
Expand All @@ -13,6 +14,9 @@ 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"
)

tags = TaggableManager()

Expand All @@ -32,3 +36,7 @@ class Category(models.Model):

class Meta:
constraints = [models.UniqueConstraint("name", name="unique category name")]


class Department(Organization):
pass

0 comments on commit 220e399

Please sign in to comment.