Skip to content

Commit

Permalink
Added models and serializers for COP, roles, skills and project (hack…
Browse files Browse the repository at this point in the history
…forla#615)

* Added models and serializers for COP, roles, skills and project

* Updated Project model and registered newly added models in admin.py
  • Loading branch information
bzzz-coding authored Dec 4, 2024
1 parent 20f9aea commit 525da2f
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 2 deletions.
6 changes: 5 additions & 1 deletion backend/ctj_api/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from django.contrib import admin

from .models import Opportunities
from .models import Opportunities, CommunityOfPractice, Role, Skill, Project

# Register your models here.
admin.site.register(Opportunities)
admin.site.register(CommunityOfPractice)
admin.site.register(Role)
admin.site.register(Skill)
admin.site.register(Project)
66 changes: 66 additions & 0 deletions backend/ctj_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,69 @@ class Opportunities(models.Model):

class Meta:
db_table = "opportunities"


class CommunityOfPractice(models.Model):

class PracticeAreas(models.TextChoices):
DATA_SCIENCE = 'data_science', 'Data Science'
ENGINEERING = 'engineering', 'Engineering'
OPS = 'ops', 'Ops'
PROJECT_MANAGEMENT = 'project_management', 'Project/Product Management'
UI_UX = 'ui_ux', 'UI/UX'
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
practice_area = models.CharField(max_length=50, choices=PracticeAreas.choices)
description = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
db_table = "community_of_practice"
verbose_name = "Community of Practice"
verbose_name_plural = "Communities of Practice"

def __str__(self):
return f"{self.get_practice_area_display()}"


class Role(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
title = models.CharField(max_length=50)
community_of_practice = models.ForeignKey(CommunityOfPractice, on_delete=models.CASCADE, related_name="roles")
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
db_table = "roles"

def __str__(self):
return f"{self.title} ({self.community_of_practice.get_practice_area_display()})"


class Skill(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=50)
roles = models.ManyToManyField('Role', related_name='skills')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
db_table = "skills"

def __str__(self):
return self.name


class Project(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
people_depot_project_id = models.CharField(max_length=255)
name = models.CharField(max_length=50)
meeting_times = models.JSONField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
db_table = "projects"

def __str__(self):
return self.name
30 changes: 29 additions & 1 deletion backend/ctj_api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
from rest_framework import serializers

from ctj_api.models import Opportunities
from ctj_api.models import Opportunities, CommunityOfPractice, Role, Skill, Project


class OpportunitiesSerializer(serializers.ModelSerializer):
class Meta:
model = Opportunities
fields = ["id", "role", "subrole", "project"]


class CommunityOfPracticeSerializer(serializers.ModelSerializer):
class Meta:
model = CommunityOfPractice
fields = ['id', 'practice_area', 'description', 'created_at', 'updated_at']


class RoleSerializer(serializers.ModelSerializer):
community_of_practice = CommunityOfPracticeSerializer(read_only=True)

class Meta:
model = Role
fields = ['id', 'title', 'community_of_practice', 'created_at', 'updated_at']


class SkillSerializer(serializers.ModelSerializer):
roles = RoleSerializer(many=True, read_only=True)

class Meta:
model = Skill
fields = ['id', 'name', 'roles', 'created_at', 'updated_at']


class ProjectSerializer(serializers.ModelSerializer):
class Meta:
model = Project
fields = ['id', 'people_depot_project_id', 'meeting_times', 'created_at', 'updated_at']

0 comments on commit 525da2f

Please sign in to comment.