Skip to content

Commit

Permalink
Refactor ctj-backend to a stable foundation
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyjuareza committed Jul 13, 2024
1 parent 11ad034 commit 611fe41
Show file tree
Hide file tree
Showing 25 changed files with 256 additions and 231 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ app/staticfiles

dev/linter.env
.DS_store

data
.idea
4 changes: 4 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.venv
.idea
DCIM
data
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ COPY pyproject.toml poetry.lock /app/
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi

# Copy the entire Django project to the working directory
COPY . /app/
COPY . /app

# Expose the port your application will run on
EXPOSE 8000
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions backend/api/asgi.py → backend/backend/asgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
ASGI config for api project.
ASGI config for backend project.
It exposes the ASGI callable as a module-level variable named ``application``.
Expand All @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'api.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')

application = get_asgi_application()
18 changes: 10 additions & 8 deletions backend/api/settings.py → backend/backend/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Django settings for api project.
Django settings for backend project.
Generated by 'django-admin startproject' using Django 5.0.6.
Expand All @@ -20,7 +20,7 @@
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-!ph@!3)-3@c(eh0usp&wypxs+@*tdbkoy9_e)+e&jp5-7*(ih_'
SECRET_KEY = 'django-insecure-nh^$8a9bz71oax2_j(_x4^&6_s8au=+l(g$0c^d905(+vyf=4&'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand All @@ -31,13 +31,13 @@
# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ctjbackend'
'ctj_api.apps.CtjApiConfig',
'rest_framework'
]

MIDDLEWARE = [
Expand All @@ -50,12 +50,13 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'api.urls'
ROOT_URLCONF = 'backend.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [BASE_DIR / 'templates']
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand All @@ -68,7 +69,7 @@
},
]

WSGI_APPLICATION = 'api.wsgi.application'
WSGI_APPLICATION = 'backend.wsgi.application'


# Database
Expand All @@ -81,10 +82,11 @@
'USER': 'yourusername',
'PASSWORD': 'yourpassword',
'HOST': 'localhost',
'PORT': 5432, #default port you don't need to mention in docker-compose
'PORT': '5432'
}
}


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

Expand Down
9 changes: 5 additions & 4 deletions backend/api/urls.py → backend/backend/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
URL configuration for api project.
URL configuration for backend project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.0/topics/http/urls/
Expand All @@ -14,9 +14,10 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
# from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
# path('admin/', admin.site.urls),
path('api/', include('ctj_api.urls')),
]
4 changes: 2 additions & 2 deletions backend/api/wsgi.py → backend/backend/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
WSGI config for api project.
WSGI config for backend project.
It exposes the WSGI callable as a module-level variable named ``application``.
Expand All @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'api.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')

application = get_wsgi_application()
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions backend/ctjbackend/apps.py → backend/ctj_api/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import AppConfig


class CtjbackendConfig(AppConfig):
class CtjApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'ctjbackend'
name = 'ctj_api'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.0.6 on 2024-06-28 01:39
# Generated by Django 5.0.6 on 2024-07-13 10:05

import django.utils.timezone
import uuid
Expand All @@ -17,15 +17,15 @@ class Migration(migrations.Migration):
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)),
('role', models.CharField(default='default-role', max_length=255)),
('subrole', models.CharField(default='default-subrole', max_length=255)),
('project', models.CharField(default='default-project', max_length=255)),
('meetings_times', models.JSONField(default=list)),
('difficulty_level', models.IntegerField()),
('difficulty_level', models.IntegerField(default=0)),
('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)),
('updated_by', models.CharField(max_length=255)),
],
options={
'db_table': 'opportunities',
Expand Down
File renamed without changes.
13 changes: 6 additions & 7 deletions backend/ctjbackend/models.py → backend/ctj_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
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)
role = models.CharField(max_length=255, default="default-role")
subrole = models.CharField(max_length=255, default="default-subrole")
project = models.CharField(max_length=255, default="default-project")
meetings_times = models.JSONField(default=list)
difficulty_level = models.IntegerField()
difficulty_level = models.IntegerField(default=0)
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)
updated_by = models.CharField(max_length=255)

class Meta:
db_table = "Opportunities"
db_table = "opportunities"
7 changes: 7 additions & 0 deletions backend/ctj_api/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from rest_framework import serializers
from ctj_api.models import Opportunities

class OpportunitiesSerializer(serializers.ModelSerializer):
class Meta:
model = Opportunities
fields = ['id','role', 'subrole','project']
File renamed without changes.
8 changes: 8 additions & 0 deletions backend/ctj_api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path
from ctj_api import views


urlpatterns = [
path('opportunities/', views.OpportunitiesList.as_view()),
path('opportunities/<uuid:pk>/', views.OpportunitiesDetails.as_view())
]
13 changes: 13 additions & 0 deletions backend/ctj_api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from rest_framework import generics
from ctj_api.models import Opportunities
from ctj_api.serializers import OpportunitiesSerializer


class OpportunitiesList(generics.ListCreateAPIView):
queryset = Opportunities.objects.all()
serializer_class = OpportunitiesSerializer


class OpportunitiesDetails(generics.RetrieveUpdateDestroyAPIView):
queryset = Opportunities.objects.all()
serializer_class = OpportunitiesSerializer
Loading

0 comments on commit 611fe41

Please sign in to comment.