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

fix: add new logic #79

Merged
merged 5 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion backend/app.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
runtime: python311
runtime: python38
instance_class: F2
service: REPLACE_ME

Expand Down
15 changes: 8 additions & 7 deletions backend/portal/views/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ def teacher_or_indy_reset_password_tracker(request, activity_today, email):
get_user = Teacher.objects.filter(
new_user__email=email
) or Student.objects.filter(new_user__email=email)
user = get_user[0]
if blocked_and_not_expired(user):
if "teacher" in request.path:
activity_today.teacher_lockout_resets += 1
elif "student" in request.path:
activity_today.indy_lockout_resets += 1
activity_today.save()
if get_user.exists():
user = get_user[0]
if blocked_and_not_expired(user):
if "teacher" in request.path:
activity_today.teacher_lockout_resets += 1
elif "student" in request.path:
activity_today.indy_lockout_resets += 1
activity_today.save()


def handle_reset_password_tracking(
Expand Down
52 changes: 35 additions & 17 deletions backend/service/production_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
# "deploy.middleware.screentime_warning.ScreentimeWarningMiddleware",
]

ROOT_URLCONF = 'service.urls'
ROOT_URLCONF = "service.urls"

TEMPLATES = [
{
Expand Down Expand Up @@ -113,16 +113,16 @@
},
]

WSGI_APPLICATION = 'service.wsgi.application'
WSGI_APPLICATION = "service.wsgi.application"


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

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
if DEBUG
else {
Expand All @@ -139,16 +139,16 @@

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",
},
]

Expand All @@ -173,7 +173,7 @@
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_ROOT = BASE_DIR / "static"
STATIC_URL = '/static/'
STATIC_URL = "/static/"
STATICFILES_DIRS = [BASE_DIR / "portal/static"]
MEDIA_ROOT = STATIC_URL + "/email_media/"

Expand All @@ -183,7 +183,9 @@
PIPELINE = {}

# Gets all the static files from the apps mentioned above in INSTALLED_APPS
STATICFILES_FINDERS = ["django.contrib.staticfiles.finders.AppDirectoriesFinder"]
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.AppDirectoriesFinder"
]

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
Expand All @@ -208,14 +210,24 @@
EMAIL_ADDRESS = "no-reply@codeforlife.education"

DOTMAILER_CREATE_CONTACT_URL = os.getenv("DOTMAILER_CREATE_CONTACT_URL", "")
DOTMAILER_MAIN_ADDRESS_BOOK_URL = os.getenv("DOTMAILER_MAIN_ADDRESS_BOOK_URL", "")
DOTMAILER_TEACHER_ADDRESS_BOOK_URL = os.getenv("DOTMAILER_TEACHER_ADDRESS_BOOK_URL", "")
DOTMAILER_STUDENT_ADDRESS_BOOK_URL = os.getenv("DOTMAILER_STUDENT_ADDRESS_BOOK_URL", "")
DOTMAILER_MAIN_ADDRESS_BOOK_URL = os.getenv(
"DOTMAILER_MAIN_ADDRESS_BOOK_URL", ""
)
DOTMAILER_TEACHER_ADDRESS_BOOK_URL = os.getenv(
"DOTMAILER_TEACHER_ADDRESS_BOOK_URL", ""
)
DOTMAILER_STUDENT_ADDRESS_BOOK_URL = os.getenv(
"DOTMAILER_STUDENT_ADDRESS_BOOK_URL", ""
)
DOTMAILER_NO_ACCOUNT_ADDRESS_BOOK_URL = os.getenv(
"DOTMAILER_NO_ACCOUNT_ADDRESS_BOOK_URL", ""
)
DOTMAILER_GET_USER_BY_EMAIL_URL = os.getenv("DOTMAILER_GET_USER_BY_EMAIL_URL", "")
DOTMAILER_DELETE_USER_BY_ID_URL = os.getenv("DOTMAILER_DELETE_USER_BY_ID_URL", "")
DOTMAILER_GET_USER_BY_EMAIL_URL = os.getenv(
"DOTMAILER_GET_USER_BY_EMAIL_URL", ""
)
DOTMAILER_DELETE_USER_BY_ID_URL = os.getenv(
"DOTMAILER_DELETE_USER_BY_ID_URL", ""
)
DOTMAILER_PUT_CONSENT_DATA_URL = os.getenv("DOTMAILER_PUT_CONSENT_DATA_URL", "")
DOTMAILER_SEND_CAMPAIGN_URL = os.getenv("DOTMAILER_SEND_CAMPAIGN_URL", "")
DOTMAILER_THANKS_FOR_STAYING_CAMPAIGN_ID = os.getenv(
Expand Down Expand Up @@ -297,6 +309,7 @@
IS_CLOUD_SCHEDULER_FUNCTION = is_cloud_scheduler
CLOUD_STORAGE_PREFIX = "https://storage.googleapis.com/codeforlife-assets/"


# Domain
def domain():
"""Returns the full domain depending on whether it's local, dev, staging or prod."""
Expand All @@ -313,6 +326,7 @@ def domain():
CSP_DEFAULT_SRC = ("self",)
CSP_CONNECT_SRC = (
"'self'",
"https://api.pwnedpasswords.com",
"https://*.onetrust.com/",
"https://euc-widget.freshworks.com/",
"https://codeforlife.freshdesk.com/",
Expand Down Expand Up @@ -354,6 +368,7 @@ def domain():
"https://pyodide-cdn2.iodide.io/v0.15.0/full/",
f"{domain()}/static/portal/",
f"{domain()}/static/common/",
"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js",
)
CSP_STYLE_SRC = (
"'self'",
Expand Down Expand Up @@ -394,7 +409,10 @@ def domain():
f"{domain()}/static/game/js/blockly/media/",
f"{domain()}/static/icons/",
)
CSP_OBJECT_SRC = (f"{domain()}/static/common/img/", f"{domain()}/static/game/image/")
CSP_OBJECT_SRC = (
f"{domain()}/static/common/img/",
f"{domain()}/static/game/image/",
)
CSP_MEDIA_SRC = (
f"{domain()}/static/game/sound/",
f"{domain()}/static/game/js/blockly/media/",
Expand Down
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.11.12",
"@reduxjs/toolkit": "^1.9.3",
"codeforlife": "github:ocadotechnology/codeforlife-package-javascript#v1.25.2",
"codeforlife": "github:ocadotechnology/codeforlife-package-javascript#v1.25.4",
"country-list": "^2.3.0",
"crypto-js": "^4.1.1",
"formik": "^2.2.9",
"hamburger-react": "^2.5.0",
"qs": "^6.11.2",
Expand All @@ -48,6 +49,7 @@
"@cypress/code-coverage": "^3.10.0",
"@cypress/instrument-cra": "^1.4.0",
"@types/country-list": "^2.1.1",
"@types/crypto-js": "^4.1.1",
"@types/node": "^17.0.45",
"@types/parcel-bundler": "^1.12.5",
"@types/react": "^18.0.28",
Expand Down
101 changes: 0 additions & 101 deletions frontend/src/components/CflPasswordFields.tsx

This file was deleted.

Loading