-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V20230103 CS50x Final Project. Pure JavaScript.
- Loading branch information
celestino.frc
committed
Jan 3, 2023
1 parent
0c7edb9
commit 284a0c4
Showing
65 changed files
with
7,439 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ESC/docker/esc_app/esc_db/data/* | ||
**/__pycache__ | ||
**/migrations | ||
**/node_modules | ||
ESC_Backend/esc/storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Python: Django", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "${workspaceFolder}\\ESC_Backend\\esc\\manage.py", | ||
"args": [ | ||
"runserver" | ||
], | ||
"django": true, | ||
"justMyCode": true | ||
}, | ||
{ | ||
"type": "firefox", | ||
"request": "attach", | ||
"name": "Attach" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "start db", | ||
"type": "shell", | ||
"isBackground": true, | ||
"command": "docker-compose up -d", | ||
"options": { | ||
"cwd": "./ESC/docker/esc_app" | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "stop db", | ||
"type": "shell", | ||
"isBackground": true, | ||
"command": "docker-compose down --remove-orphans", | ||
"options": { | ||
"cwd": "./ESC/docker/esc_app" | ||
}, | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "." | ||
} | ||
], | ||
"settings": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
python manage.py makemigrations | ||
python manage.py migrate | ||
python manage.py createsuperuser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: '3' | ||
services: | ||
dbserver.esc: | ||
build: | ||
context: ./esc_db | ||
ports: | ||
- '5432:5432' | ||
volumes: | ||
- ./esc_db/data:/var/lib/postgresql/data | ||
env_file: | ||
- ./esc_db/env.db | ||
dbadmin: | ||
image: adminer | ||
depends_on: | ||
- dbserver.esc | ||
restart: always | ||
ports: | ||
- target: 8080 | ||
published: 8081 | ||
protocol: tcp | ||
mode: host | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM postgres:13.5 | ||
COPY ./scripts/init.sql /docker-entrypoint-initdb.d/ | ||
WORKDIR /usr/esc_app | ||
#ENV POSTGRES_USER esc | ||
#ENV POSTGRES_PASSWORD mysecret | ||
#ENV POSTGRES_DB esc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Remove-Item '.\data\*' -Recurse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
POSTGRES_USER=esc | ||
POSTGRES_PASSWORD=segredo | ||
POSTGRES_DB=esc | ||
TZ='America/Sao_Paulo' | ||
PGTZ='America/Sao_Paulo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER ROLE esc SET client_encoding TO 'utf8'; | ||
ALTER ROLE esc SET default_transaction_isolation TO 'read committed'; | ||
ALTER ROLE esc SET timezone TO 'America/Sao_Paulo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docker-compose down --remove-orphans |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for esc project. | ||
It exposes the ASGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'esc.settings') | ||
|
||
application = get_asgi_application() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
""" | ||
Django settings for esc project. | ||
Generated by 'django-admin startproject' using Django 3.2.11. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/3.2/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/3.2/ref/settings/ | ||
""" | ||
|
||
from pathlib import Path | ||
import os | ||
from datetime import timedelta | ||
|
||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
BASE_DIR = Path(__file__).resolve().parent.parent | ||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = 'django-insecure-eg0(64)_@hqakyh_q3yh!5^tkhrn%*50tt5y^)h(d@*)wv70qd' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = [] | ||
|
||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'esc_app', | ||
'rest_framework', | ||
'rest_framework_simplejwt', | ||
# 'corsheaders', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
#"corsheaders.middleware.CorsMiddleware", | ||
'django.middleware.common.CommonMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
|
||
] | ||
|
||
ROOT_URLCONF = 'esc.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'esc.wsgi.application' | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.postgresql"), | ||
"NAME": os.environ.get("SQL_DATABASE", 'esc'), | ||
"USER": os.environ.get("SQL_USER", 'esc'), | ||
"PASSWORD": os.environ.get("SQL_PASSWORD", 'segredo'), | ||
"HOST": os.environ.get("SQL_HOST", 'dbserver.esc'), | ||
"PORT": os.environ.get("SQL_PORT", '5432'), | ||
} | ||
} | ||
|
||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators | ||
|
||
AUTH_PASSWORD_VALIDATORS = [ | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
}, | ||
] | ||
|
||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/3.2/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
TIME_ZONE = 'America/Sao_Paulo' | ||
|
||
USE_I18N = True | ||
|
||
USE_L10N = True | ||
|
||
USE_TZ = True | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/3.2/howto/static-files/ | ||
|
||
STATIC_URL = '/static/' | ||
|
||
# STATIC_ROOT = BASE_DIR / 'static' | ||
|
||
# STATICFILES_DIRS = [ | ||
# "/home/special.polls.com/polls/static", | ||
# "/home/polls.com/polls/static", | ||
# "/opt/webfiles/common", | ||
# ] | ||
|
||
STATICFILES_DIRS = [ | ||
os.path.join(BASE_DIR,"static"), | ||
] | ||
|
||
|
||
# print("base dir") | ||
# print(BASE_DIR) | ||
# print(STATIC_ROOT) | ||
|
||
# Default primary key field type | ||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field | ||
|
||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' | ||
|
||
REST_FRAMEWORK = { | ||
# Use Django's standard `django.contrib.auth` permissions, | ||
# or allow read-only access for unauthenticated users. | ||
'DEFAULT_PERMISSION_CLASSES': [ | ||
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' | ||
], | ||
'DEFAULT_AUTHENTICATION_CLASSES': ( | ||
'rest_framework_simplejwt.authentication.JWTAuthentication', | ||
'rest_framework.authentication.BasicAuthentication', | ||
'rest_framework.authentication.SessionAuthentication' | ||
), | ||
'COERCE_DECIMAL_TO_STRING': False, | ||
'DEFAULT_PARSER_CLASSES': [ | ||
'rest_framework.parsers.JSONParser', | ||
] | ||
} | ||
|
||
X_FRAME_OPTIONS = 'SAMEORIGIN' | ||
|
||
CSRF_USE_SESSIONS = False | ||
CSRF_COOKIE_HTTPONLY = False | ||
|
||
#PENDENTE - Temporariamente o token de autenticação está com tempo de vida elevado | ||
#Futuramente, ao integrar na DTI, será interessante utilizar o conceito de refresh token também. | ||
SIMPLE_JWT = { | ||
'ACCESS_TOKEN_LIFETIME': timedelta(days=1), | ||
'REFRESH_TOKEN_LIFETIME': timedelta(days=1) | ||
} | ||
|
||
# CORS_ALLOWED_ORIGINS = [ | ||
# "https://example.com", | ||
# "https://sub.example.com", | ||
# "http://localhost:8080", | ||
# "http://127.0.0.1:9000", | ||
# ] | ||
|
||
# CORS_ALLOWED_ORIGIN_REGEXES = [ | ||
# r"^http://localhost.*$", | ||
# ] | ||
# CORS_ALLOW_ALL_ORIGINS: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""esc URL Configuration | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/3.2/topics/http/urls/ | ||
Examples: | ||
Function views | ||
1. Add an import: from my_app import views | ||
2. Add a URL to urlpatterns: path('', views.home, name='home') | ||
Class-based views | ||
1. Add an import: from other_app.views import Home | ||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') | ||
Including another URLconf | ||
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, include | ||
from . import settings | ||
from django.conf.urls.static import static | ||
from rest_framework_simplejwt.views import ( | ||
TokenObtainPairView, | ||
TokenRefreshView, | ||
) | ||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path('esc/', include("esc_app.urls")), | ||
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), | ||
path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), | ||
|
||
#REST_REFATORADA | ||
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')), | ||
] | ||
# + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for esc project. | ||
It exposes the WSGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'esc.settings') | ||
|
||
application = get_wsgi_application() |
Empty file.
Oops, something went wrong.