Skip to content

Commit

Permalink
Backend opportunity model init (#545)
Browse files Browse the repository at this point in the history
* Pgdb connected

- added configs in django.settings
- installed psycopg2-binary **for development only**
- psycopg2 for production requires certain system depdencies

* init Opportunities model

- Recreated from previous PR
- Renamed post model to "opportunities"
- did migration

* Load sample data into database

- Added fixtures
- make sure to 'python manage.py loaddata ctjbackend/fixtures/*.json'
  • Loading branch information
bennyv8 authored Jun 28, 2024
1 parent 31ad971 commit affa11a
Show file tree
Hide file tree
Showing 6 changed files with 325 additions and 5 deletions.
10 changes: 7 additions & 3 deletions backend/api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ctjbackend'
]

MIDDLEWARE = [
Expand Down Expand Up @@ -75,12 +76,15 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'yourdatabase',
'USER': 'yourusername',
'PASSWORD': 'yourpassword',
'HOST': 'localhost',
'PORT': 5432, #default port you don't need to mention in docker-compose
}
}


# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators

Expand Down
182 changes: 182 additions & 0 deletions backend/ctjbackend/fixtures/opportunities_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
[
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ac6",
"fields": {
"role": "Software Engineer",
"subrole": "Frontend Developer",
"project": "E-commerce Website",
"meetings_times": [],
"difficulty_level": 3,
"details": {
"requirements": "Proficiency in React.js",
"deadline": "2024-07-15"
},
"created_at": "2024-04-20T10:00:00Z",
"updated_at": "2024-04-20T10:00:00Z",
"updated_by_or_token": "admin"
}
},
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ac2",
"fields": {
"role": "Data Scientist",
"subrole": "Machine Learning Engineer",
"project": "Predictive Analytics Platform",
"meetings_times": ["Monday 10:00 AM", "Wednesday 2:00 PM"],
"difficulty_level": 5,
"details": {
"requirements": "Experience with TensorFlow",
"deadline": "2024-08-30"
},
"created_at": "2024-04-21T09:30:00Z",
"updated_at": "2024-04-21T09:30:00Z",
"updated_by_or_token": "admin"
}
},
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ac3",
"fields": {
"role": "Project Manager",
"subrole": "Scrum Master",
"project": "Agile Development Team",
"meetings_times": ["Monday 9:00 AM", "Thursday 3:00 PM"],
"difficulty_level": 4,
"details": {
"requirements": "Certified ScrumMaster (CSM)",
"deadline": "2024-07-31"
},
"created_at": "2024-04-22T14:45:00Z",
"updated_at": "2024-04-22T14:45:00Z",
"updated_by_or_token": "admin"
}
},
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ac4",
"fields": {
"role": "UX Designer",
"subrole": "UI Developer",
"project": "Mobile App Redesign",
"meetings_times": ["Tuesday 11:00 AM", "Friday 2:00 PM"],
"difficulty_level": 3,
"details": {
"requirements": "Proficiency in Adobe XD",
"deadline": "2024-08-15"
},
"created_at": "2024-04-23T11:20:00Z",
"updated_at": "2024-04-23T11:20:00Z",
"updated_by_or_token": "admin"
}
},
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ac5",
"fields": {
"role": "Backend Developer",
"subrole": "Database Administrator",
"project": "Enterprise Resource Planning System",
"meetings_times": ["Wednesday 3:00 PM", "Friday 10:00 AM"],
"difficulty_level": 4,
"details": {
"requirements": "Experience with SQL Server",
"deadline": "2024-09-30"
},
"created_at": "2024-04-24T13:10:00Z",
"updated_at": "2024-04-24T13:10:00Z",
"updated_by_or_token": "admin"
}
},
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ac7",
"fields": {
"role": "DevOps Engineer",
"subrole": "Cloud Architect",
"project": "Microservices Migration",
"meetings_times": ["Tuesday 2:00 PM", "Thursday 10:00 AM"],
"difficulty_level": 5,
"details": {
"requirements": "Experience with AWS and Docker",
"deadline": "2024-09-15"
},
"created_at": "2024-04-25T09:45:00Z",
"updated_at": "2024-04-25T09:45:00Z",
"updated_by_or_token": "admin"
}
},
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ac8",
"fields": {
"role": "Quality Assurance Engineer",
"subrole": "Automation Tester",
"project": "Mobile Game Testing",
"meetings_times": ["Monday 11:00 AM", "Wednesday 3:00 PM"],
"difficulty_level": 3,
"details": {
"requirements": "Experience with Appium",
"deadline": "2024-07-31"
},
"created_at": "2024-04-26T10:30:00Z",
"updated_at": "2024-04-26T10:30:00Z",
"updated_by_or_token": "admin"
}
},
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ac9",
"fields": {
"role": "Technical Writer",
"subrole": "Documentation Specialist",
"project": "Software User Manuals",
"meetings_times": [],
"difficulty_level": 2,
"details": {
"requirements": "Proficiency in Markdown",
"deadline": "2024-08-10"
},
"created_at": "2024-04-27T08:50:00Z",
"updated_at": "2024-04-27T08:50:00Z",
"updated_by_or_token": "admin"
}
},
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ac0",
"fields": {
"role": "Network Engineer",
"subrole": "Security Specialist",
"project": "Cybersecurity Infrastructure Upgrade",
"meetings_times": ["Wednesday 9:00 AM", "Friday 1:00 PM"],
"difficulty_level": 4,
"details": {
"requirements": "Certified Information Systems Security Professional (CISSP)",
"deadline": "2024-09-30"
},
"created_at": "2024-04-28T14:15:00Z",
"updated_at": "2024-04-28T14:15:00Z",
"updated_by_or_token": "admin"
}
},
{
"model": "ctjbackend.Opportunities",
"pk": "e04c5cc3-79a2-4a5e-9f2e-904938f08ad6",
"fields": {
"role": "Business Analyst",
"subrole": "Data Analyst",
"project": "Market Research Initiative",
"meetings_times": ["Monday 2:00 PM", "Thursday 11:00 AM"],
"difficulty_level": 3,
"details": {
"requirements": "Proficiency in Excel and SQL",
"deadline": "2024-08-31"
},
"created_at": "2024-04-29T11:40:00Z",
"updated_at": "2024-04-29T11:40:00Z",
"updated_by_or_token": "admin"
}
}
]
34 changes: 34 additions & 0 deletions backend/ctjbackend/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 5.0.6 on 2024-06-28 01:39

import django.utils.timezone
import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Opportunities',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('role', models.CharField(max_length=255)),
('subrole', models.CharField(max_length=255)),
('project', models.CharField(max_length=255)),
('meetings_times', models.JSONField(default=list)),
('difficulty_level', models.IntegerField()),
('details', models.JSONField(default=dict)),
('created_at', models.DateTimeField(default=django.utils.timezone.now)),
('updated_at', models.DateTimeField(default=django.utils.timezone.now)),
('updated_by_or_token', models.CharField(max_length=255)),
],
options={
'db_table': 'opportunities',
},
),
]
20 changes: 19 additions & 1 deletion backend/ctjbackend/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
from django.db import models
from django.utils import timezone

# Create your models here.
import uuid



class Opportunities(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
role = models.CharField(max_length=255)
subrole = models.CharField(max_length=255)
project = models.CharField(max_length=255)
meetings_times = models.JSONField(default=list)
difficulty_level = models.IntegerField()
details = models.JSONField(default=dict)
created_at = models.DateTimeField(default=timezone.now)
updated_at = models.DateTimeField(default=timezone.now)
updated_by_or_token = models.CharField(max_length=255)

class Meta:
db_table = "Opportunities"
Loading

0 comments on commit affa11a

Please sign in to comment.