Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump pillow from 9.1.1 to 9.3.0 in /backend #307

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
all: clean deploy logs

build:
docker compose -f docker-compose.yml -f docker-compose.override.yml build

deploy:
docker compose -f docker-compose.yml -f docker-compose.override.yml up -d

logs:
docker compose logs -f

logs-backend:
docker logs -f backend-dev

logs-frontend:
docker logs -f frontend-dev

shell-backend:
docker exec -it backend-dev /bin/bash

clean:
docker compose -f docker-compose.yml -f docker-compose.override.yml down --remove-orphans
7 changes: 6 additions & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ DATABASE_USER =
DATABASE_PASSWORD =
DATABASE_HOST = localhost
DATABASE_PORT = 5432
DJANGO_DEBUG = True

SECRET_KEY = "secret"
DJANGO_DEBUG = True

# If multiple hosts, they should be separated by commas. (ex: "localhost,arquimedia.pt,admin.aquimedia.pt")
ALLOWED_HOSTS = "localhost"
195 changes: 105 additions & 90 deletions backend/Arquimedia/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
from dotenv import load_dotenv
from celery.schedules import crontab

load_dotenv()

SITE_ID = 1
Expand All @@ -29,86 +30,92 @@
SECRET_KEY = os.getenv("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = (os.getenv("DJANGO_DEBUG", True) == "True")
DEBUG = os.getenv("DJANGO_DEBUG", True) == "True"

ALLOWED_HOSTS = [os.getenv("ALLOWED_HOSTS")]
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS").split(",")
print(type(ALLOWED_HOSTS))
print(ALLOWED_HOSTS)


# Application definition

INSTALLED_APPS = [
'corsheaders',
'users',
'exams',
'api',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'rest_auth.registration',
'django_celery_beat',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles'
"corsheaders",
"users",
"exams",
"api",
"rest_framework",
"rest_framework.authtoken",
"rest_auth",
"django.contrib.sites",
"allauth",
"allauth.account",
"allauth.socialaccount",
"rest_auth.registration",
"django_celery_beat",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]

CORS_ALLOWED_ORIGINS = ["http://localhost:3000", "https://arquimedia.pt", "http://localhost" ]
CORS_ALLOWED_ORIGINS = [
"http://localhost:3000",
"https://arquimedia.pt",
"http://localhost",
]

CORS_ALLOW_CREDENTIALS = True


MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = 'Arquimedia.urls'
ROOT_URLCONF = "Arquimedia.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
# insert your TEMPLATE_DIRS here
os.path.join(BASE_DIR, 'Arquimedia/templates'),
os.path.join(BASE_DIR, "Arquimedia/templates"),
],
'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',
"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 = 'Arquimedia.wsgi.application'
WSGI_APPLICATION = "Arquimedia.wsgi.application"


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.getenv("DATABASE_NAME"),
'USER': os.getenv("DATABASE_USER"),
'PASSWORD': os.getenv("DATABASE_PASSWORD"),
'HOST': os.getenv("DATABASE_HOST"),
'PORT': os.getenv("DATABASE_PORT"),
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": os.getenv("DATABASE_NAME"),
"USER": os.getenv("DATABASE_USER"),
"PASSWORD": os.getenv("DATABASE_PASSWORD"),
"HOST": os.getenv("DATABASE_HOST"),
"PORT": os.getenv("DATABASE_PORT"),
}
}

Expand All @@ -118,29 +125,33 @@

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework.authentication.TokenAuthentication',],}
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework.authentication.TokenAuthentication",
],
}


# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"

USE_I18N = True

Expand All @@ -152,24 +163,24 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'
STATIC_URL = "/static/"

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)
# Login and logout redirect
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
#Login Path for Login required Decorators
LOGIN_URL = '^login/$'
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"
# Login Path for Login required Decorators
LOGIN_URL = "^login/$"

# Disables the verification email sent by allauth
ACCOUNT_EMAIL_VERIFICATION = "none"
LOGOUT_ON_PASSWORD_CHANGE = False
OLD_PASSWORD_FIELD_ENABLED = True

# SMTP Settings
EMAIL_BACKEND = os.getenv('EMAIL_BACKEND')
EMAIL_BACKEND = os.getenv(
"EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend"
)
EMAIL_USE_TLS = True
EMAIL_HOST = os.getenv("SMTP_HOST")
EMAIL_PORT = os.getenv("SMTP_PORT")
Expand All @@ -180,42 +191,46 @@
MEDIA_ROOT = os.path.join(BASE_DIR, "static/images")
MEDIA_URL = "/images/"

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

# Celery settings
BROKER_URL = os.getenv("REDIS_URL")
CELERY_RESULT_BACKEND = os.getenv("REDIS_URL")
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Europe/Lisbon'
CELERY_ACCEPT_CONTENT = ["application/json"]
CELERY_TASK_SERIALIZER = "json"
CELERY_RESULT_SERIALIZER = "json"
CELERY_TIMEZONE = "Europe/Lisbon"

# Logging Configuration

# Clear prev config
LOGGING_CONFIG = None

# Get loglevel from env
LOGLEVEL = os.getenv('DJANGO_LOGLEVEL', 'info').upper()

logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'console': {
'format': '%(asctime)s %(levelname)s [%(name)s:%(lineno)s] %(module)s %(process)d %(thread)d %(message)s',
LOGLEVEL = os.getenv("DJANGO_LOGLEVEL", "info").upper()

logging.config.dictConfig(
{
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"console": {
"format": "%(asctime)s %(levelname)s [%(name)s:%(lineno)s] %(module)s %(process)d %(thread)d %(message)s",
},
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'console',
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "console",
},
},
},
'loggers': {
'': {
'level': LOGLEVEL,
'handlers': ['console',],
"loggers": {
"": {
"level": LOGLEVEL,
"handlers": [
"console",
],
},
},
},
})
}
)
14 changes: 6 additions & 8 deletions backend/Arquimedia/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""
from django.contrib import admin
from django.urls import path, re_path
from django.conf.urls import url, include
from django.conf.urls import include
from django.contrib.auth import views as auth_views
from .views import CustomLoginView, index, CustomRegisterView
from django.conf import settings
Expand All @@ -25,16 +25,14 @@
from api.views import VerifyEmailView

urlpatterns = [
path('', include("users.urls")),
path('admin/', admin.site.urls),
url(r'^$', index),
url('exame/', include('exams.urls')),
re_path(r'^$', index),
path("api/", include("api.urls")),
url(r'^rest-auth/login/', CustomLoginView.as_view()),
url(r'^rest-auth/registration/', CustomRegisterView.as_view()),
url(r'^rest-auth/', include('rest_auth.urls')),
re_path(r'^rest-auth/login/', CustomLoginView.as_view()),
re_path(r'^rest-auth/registration/', CustomRegisterView.as_view()),
re_path(r'^rest-auth/', include('rest_auth.urls')),
path('rest-auth/password/reset/confirm/<uidb64>/<token>/', views.PasswordResetConfirmView.as_view(), name="password_reset_confirm"),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
re_path(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
]

# Allows to fetch images
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3
FROM python:3.10

ENV PYTHONDONTWRITEBYTECODE=1

Expand Down
Loading