-
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.
- Loading branch information
1 parent
10386b9
commit 5a4dda3
Showing
10 changed files
with
86 additions
and
96 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 @@ | ||
[label .gitignore] | ||
db.sqlite3 | ||
*.pyc | ||
.venv/* | ||
.env |
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
Binary file not shown.
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 |
---|---|---|
@@ -1,36 +1,26 @@ | ||
""" | ||
Django settings for iridisite project. | ||
Generated by 'django-admin startproject' using Django 5.0.2. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/5.0/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/5.0/ref/settings/ | ||
""" | ||
|
||
from pathlib import Path | ||
from django.core.management.utils import get_random_secret_key | ||
import os | ||
import sys | ||
import dj_database_url | ||
|
||
# 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/5.0/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = 'django-insecure-4mv49k@ao+x=c37soeh@+r5&^v0*ue_e&kzc(&!gt&g@+u$n++' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = [] | ||
SECRET_KEY = SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", get_random_secret_key()) | ||
ALLOWED_HOSTS = os.getenv("DJANGO_ALLOWED_HOSTS", "127.0.0.1,localhost").split(",") | ||
DEBUG = os.getenv("DEBUG", "False") == "True" | ||
|
||
EMAIL_HOST = "mail.iridiumtutoring.org" | ||
EMAIL_HOST_USER = "[email protected]" | ||
EMAIL_HOST_PASSWORD = "123456" | ||
EMAIL_PORT = 587 | ||
EMAIL_HOST = os.getenv("EMAIL_HOST") | ||
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER") | ||
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD") | ||
EMAIL_PORT = os.getenv("EMAIL_PORT") | ||
|
||
# Application definition | ||
|
||
|
@@ -77,14 +67,21 @@ | |
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': BASE_DIR / 'db.sqlite3', | ||
DEVELOPMENT_MODE = os.getenv("DEVELOPMENT_MODE", "False") == "True" | ||
|
||
if DEVELOPMENT_MODE is True: | ||
DATABASES = { | ||
"default": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
"NAME": os.path.join(BASE_DIR, "db.sqlite3"), | ||
} | ||
} | ||
elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic': | ||
if os.getenv("DATABASE_URL", None) is None: | ||
raise Exception("DATABASE_URL environment variable not defined") | ||
DATABASES = { | ||
"default": dj_database_url.parse(os.environ.get("DATABASE_URL")), | ||
} | ||
} | ||
|
||
|
||
# Password validation | ||
|
@@ -128,9 +125,9 @@ | |
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/5.0/howto/static-files/ | ||
|
||
STATIC_URL = 'static/' | ||
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") | ||
|
||
# Default primary key field type | ||
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field | ||
|
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 |
---|---|---|
@@ -1,41 +1,9 @@ | ||
absl-py==2.1.0 | ||
asgiref==3.7.2 | ||
astunparse==1.6.3 | ||
certifi==2024.2.2 | ||
charset-normalizer==3.3.2 | ||
Django==5.0.2 | ||
dm-tree==0.1.8 | ||
flatbuffers==23.5.26 | ||
gast==0.5.4 | ||
google-pasta==0.2.0 | ||
grpcio==1.62.0 | ||
h5py==3.10.0 | ||
idna==3.6 | ||
joblib==1.3.2 | ||
libclang==16.0.6 | ||
Markdown==3.5.2 | ||
markdown-it-py==3.0.0 | ||
MarkupSafe==2.1.5 | ||
mdurl==0.1.2 | ||
ml-dtypes==0.3.2 | ||
namex==0.0.7 | ||
numpy==1.26.4 | ||
opt-einsum==3.3.0 | ||
dj-database-url==2.1.0 | ||
Django==5.0.3 | ||
gunicorn==21.2.0 | ||
packaging==23.2 | ||
protobuf==4.25.3 | ||
Pygments==2.17.2 | ||
requests==2.31.0 | ||
rich==13.7.1 | ||
scipy==1.12.0 | ||
setuptools==69.1.1 | ||
six==1.16.0 | ||
psycopg2-binary==2.9.9 | ||
sqlparse==0.4.4 | ||
termcolor==2.4.0 | ||
threadpoolctl==3.3.0 | ||
typing_extensions==4.10.0 | ||
tzdata==2024.1 | ||
urllib3==2.2.1 | ||
Werkzeug==3.0.1 | ||
wheel==0.42.0 | ||
wrapt==1.16.0 | ||
pre-commit |
Binary file not shown.
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
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
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,19 @@ | ||
import threading | ||
from django.core.mail import EmailMessage | ||
|
||
|
||
class EmailThread(threading.Thread): | ||
def __init__(self, subject, html_content, recipient_list, sender): | ||
self.subject = subject | ||
self.recipient_list = recipient_list | ||
self.html_content = html_content | ||
self.sender = sender | ||
threading.Thread.__init__(self) | ||
|
||
def run(self): | ||
msg = EmailMessage(self.subject, self.html_content, self.sender, self.recipient_list) | ||
msg.content_subtype = 'html' | ||
msg.send() | ||
|
||
def send_html_mail(subject, html_content, recipient_list, sender): | ||
EmailThread(subject, html_content, recipient_list, sender).start() |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
from django.contrib.auth.models import User | ||
from django.contrib.auth import login, logout | ||
from django.contrib.auth.decorators import login_required, user_passes_test | ||
from django.core.mail import send_mail | ||
from .utils import send_html_mail | ||
from .backends import TutorBackend, StudentBackend | ||
from .models import * | ||
|
||
|
@@ -218,17 +218,11 @@ def sessionConfirmation(request): | |
html = loader.render_to_string( | ||
"tutoring_student/sessionConfirmation.html", context | ||
) | ||
# send_mail( | ||
# "Iridium Tutoring | Tutoring Session Confirmation", | ||
# "", | ||
# "[email protected]", | ||
# [email], | ||
# html_message=html, | ||
# ) | ||
send_html_mail("Iridium Tutoring | Tutoring Session Confirmation", html, [email], "[email protected]") | ||
t.save() | ||
except: | ||
context["error_message"] = ( | ||
"There was an error confirming the session. Try again or contact us for support." | ||
"There was an error confirming the session or sending the email. Try again or contact us for support." | ||
) | ||
context["button"] = True | ||
return render(request, "tutoring_student/sessionConfirmation.html", context) |