-
Notifications
You must be signed in to change notification settings - Fork 3
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
Django initialized, connected to postgres. #72
base: django
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM python:3.8-alpine | ||
|
||
WORKDIR /app | ||
|
||
RUN apk add --no-cache \ | ||
libxslt-dev \ | ||
libxml2 \ | ||
libxml2-dev \ | ||
g++ | ||
|
||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
|
||
ADD requirements.txt . | ||
|
||
RUN pip3 install -r requirements.txt | ||
|
||
RUN apk del g++ | ||
|
||
ADD . . | ||
|
||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "wsgi"] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
|
||
from .models import SubstitutionModel |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class MainConfig(AppConfig): | ||
name = 'main' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 3.0.3 on 2020-02-28 19:01 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='SubstitutionModel', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('lesson_number', models.IntegerField()), | ||
('absent_teacher', models.CharField(max_length=30)), | ||
('class_tag', models.CharField(max_length=30)), | ||
('subject_name', models.CharField(max_length=30)), | ||
('classroom', models.CharField(max_length=30)), | ||
('substitute_teacher', models.CharField(max_length=30)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Date not present in initial migration, just add it manually |
||
], | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
class SubstitutionModel(models.Model): | ||
lesson_number = models.IntegerField() | ||
absent_teacher = models.CharField(max_length=30) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be
|
||
class_tag = models.CharField(max_length=30) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
subject_name = models.CharField(max_length=30) | ||
classroom = models.CharField(max_length=30) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that classroom id will be ever longer than |
||
substitute_teacher = models.CharField(max_length=30) | ||
pniedzwiedzinski marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python | ||
"""Django's command-line utility for administrative tasks.""" | ||
import os | ||
import sys | ||
|
||
|
||
def main(): | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'substitutions.settings') | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) from exc | ||
execute_from_command_line(sys.argv) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
flask | ||
jinja2 | ||
beautifulsoup4 | ||
flask_cors | ||
pniedzwiedzinski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
gunicorn | ||
django | ||
psycopg2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for substitutions 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.0/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'substitutions.settings') | ||
|
||
application = get_asgi_application() |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,125 @@ | ||||||
""" | ||||||
Django settings for substitutions project. | ||||||
|
||||||
Generated by 'django-admin startproject' using Django 3.0.3. | ||||||
|
||||||
For more information on this file, see | ||||||
https://docs.djangoproject.com/en/3.0/topics/settings/ | ||||||
|
||||||
For the full list of settings and their values, see | ||||||
https://docs.djangoproject.com/en/3.0/ref/settings/ | ||||||
""" | ||||||
|
||||||
import os | ||||||
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||||||
|
||||||
|
||||||
# Quick-start development settings - unsuitable for production | ||||||
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ | ||||||
|
||||||
# SECURITY WARNING: keep the secret key used in production secret! | ||||||
SECRET_KEY = 'cy2c)7^99=i9uu=62-#97!juz)5p=o%(q9-!tfn&bylsf@1l&j' | ||||||
|
||||||
# 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', | ||||||
'main.apps.MainConfig', | ||||||
] | ||||||
|
||||||
MIDDLEWARE = [ | ||||||
'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 = 'substitutions.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 = 'substitutions.wsgi.application' | ||||||
|
||||||
|
||||||
# Database | ||||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases | ||||||
|
||||||
DATABASES = { | ||||||
'default': { | ||||||
'ENGINE': 'django.db.backends.postgresql', | ||||||
'NAME': 'substitutions', | ||||||
'USER': 'postgres', | ||||||
'PASSWORD': 'postgres', | ||||||
'HOST': 'localhost', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use docker built-in DNS so we don't need to bind Postgres to the host port. This will prevent accessing the Postgres instance from the local network - which we don't need and don't want. Also add postgres to
Suggested change
|
||||||
'PORT': '5432' | ||||||
} | ||||||
} | ||||||
|
||||||
|
||||||
# Password validation | ||||||
# https://docs.djangoproject.com/en/3.0/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.0/topics/i18n/ | ||||||
|
||||||
LANGUAGE_CODE = 'en-us' | ||||||
|
||||||
TIME_ZONE = 'UTC' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
USE_I18N = True | ||||||
|
||||||
USE_L10N = True | ||||||
|
||||||
USE_TZ = True | ||||||
|
||||||
|
||||||
# Static files (CSS, JavaScript, Images) | ||||||
# https://docs.djangoproject.com/en/3.0/howto/static-files/ | ||||||
|
||||||
STATIC_URL = '/static/' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""substitutions URL Configuration | ||
|
||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/3.0/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 | ||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for substitutions 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.0/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'substitutions.settings') | ||
|
||
application = get_wsgi_application() |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,6 @@ services: | |
context: backend | ||
dockerfile: Dockerfile.dev | ||
ports: | ||
- 5000:5000 | ||
- 8000:8000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The backend is actually ported through nginx, so we need to update also the nginx configuration. |
||
volumes: | ||
- ./backend:/app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange file name