Skip to content

Commit

Permalink
Merge pull request hackforla#619 from LoTerence/fix/react-router
Browse files Browse the repository at this point in the history
Fix/react router
  • Loading branch information
LoTerence authored Dec 6, 2024
2 parents 525da2f + 203e34f commit a3ecc9c
Show file tree
Hide file tree
Showing 14 changed files with 495 additions and 515 deletions.
2 changes: 1 addition & 1 deletion backend/ctj_api/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin

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

# Register your models here.
admin.site.register(Opportunities)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Generated by Django 5.1.2 on 2024-12-06 00:13

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


class Migration(migrations.Migration):

dependencies = [
("ctj_api", "0001_initial"),
]

operations = [
migrations.CreateModel(
name="CommunityOfPractice",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
(
"practice_area",
models.CharField(
choices=[
("data_science", "Data Science"),
("engineering", "Engineering"),
("ops", "Ops"),
("project_management", "Project/Product Management"),
("ui_ux", "UI/UX"),
],
max_length=50,
),
),
("description", models.TextField()),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Community of Practice",
"verbose_name_plural": "Communities of Practice",
"db_table": "community_of_practice",
},
),
migrations.CreateModel(
name="Project",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("people_depot_project_id", models.CharField(max_length=255)),
("name", models.CharField(max_length=50)),
("meeting_times", models.JSONField(blank=True, null=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "projects",
},
),
migrations.CreateModel(
name="Role",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("title", models.CharField(max_length=50)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"community_of_practice",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="roles",
to="ctj_api.communityofpractice",
),
),
],
options={
"db_table": "roles",
},
),
migrations.CreateModel(
name="Skill",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("name", models.CharField(max_length=50)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"roles",
models.ManyToManyField(related_name="skills", to="ctj_api.role"),
),
],
options={
"db_table": "skills",
},
),
]
23 changes: 14 additions & 9 deletions backend/ctj_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ class Meta:
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'
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()
Expand All @@ -46,21 +47,25 @@ def __str__(self):
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")
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()})"
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')
roles = models.ManyToManyField("Role", related_name="skills")
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

Expand Down
16 changes: 11 additions & 5 deletions backend/ctj_api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework import serializers

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


class OpportunitiesSerializer(serializers.ModelSerializer):
Expand All @@ -12,26 +12,32 @@ class Meta:
class CommunityOfPracticeSerializer(serializers.ModelSerializer):
class Meta:
model = CommunityOfPractice
fields = ['id', 'practice_area', 'description', 'created_at', 'updated_at']
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']
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']
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']
fields = [
"id",
"people_depot_project_id",
"meeting_times",
"created_at",
"updated_at",
]
3 changes: 2 additions & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ profile = "black"
line_length = 88
multi_line_output = 3
include_trailing_comma = true
known_third_party = ["django"]
known_third_party = ["django"]
skip = [".gitignore", ".dockerignore","__pycache__", "migrations", "frontend"]
Loading

0 comments on commit a3ecc9c

Please sign in to comment.