Skip to content

Commit

Permalink
Merge pull request #74 from forza-mor-rotterdam/custom-user-model
Browse files Browse the repository at this point in the history
username to email
  • Loading branch information
mguikema authored Jun 29, 2023
2 parents cf60b27 + 37ec118 commit a9de6a6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
9 changes: 8 additions & 1 deletion app/apps/meldingen/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import requests
from django.conf import settings
from django.core.cache import cache
from django.core.exceptions import ValidationError
from django.core.validators import validate_email


class MeldingAuthResponseException(Exception):
Expand All @@ -10,10 +12,15 @@ class MeldingAuthResponseException(Exception):
def get_meldingen_token():
meldingen_token = cache.get("meldingen_token2")
if not meldingen_token:
email = settings.MELDINGEN_USERNAME
try:
validate_email(email)
except ValidationError:
email = f"{settings.MELDINGEN_USERNAME}@forzamor.nl"
token_response = requests.post(
settings.MELDINGEN_TOKEN_API,
json={
"username": settings.MELDINGEN_USERNAME,
"username": email,
"password": settings.MELDINGEN_PASSWORD,
},
)
Expand Down
2 changes: 0 additions & 2 deletions app/apps/regie/templatetags/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
# SPDX-License-Identifier: MPL-2.0
# Copyright (C) 2018 - 2021 Gemeente Amsterdam
2 changes: 1 addition & 1 deletion app/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
],
DEFAULT_SCHEMA_CLASS="drf_spectacular.openapi.AutoSchema",
DEFAULT_VERSIONING_CLASS="rest_framework.versioning.NamespaceVersioning",
# DEFAULT_PERMISSION_CLASSES=("rest_framework.permissions.IsAuthenticated",),
DEFAULT_PERMISSION_CLASSES=("rest_framework.permissions.IsAuthenticated",),
DEFAULT_AUTHENTICATION_CLASSES=(
"rest_framework.authentication.TokenAuthentication",
),
Expand Down
8 changes: 4 additions & 4 deletions app/deploy/docker-entrypoint.development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ set -x

rm -rf /static/*

echo "Start with a fresh database"
export PGPASSWORD=${DATABASE_PASSWORD}
psql -h ${DATABASE_HOST_OVERRIDE} -p 5432 -d ${DATABASE_NAME} -U ${DATABASE_USER} -c "drop schema public cascade;"
psql -h ${DATABASE_HOST_OVERRIDE} -p 5432 -d ${DATABASE_NAME} -U ${DATABASE_USER} -c "create schema public;"
# echo "Start with a fresh database"
# export PGPASSWORD=${DATABASE_PASSWORD}
# psql -h ${DATABASE_HOST_OVERRIDE} -p 5432 -d ${DATABASE_NAME} -U ${DATABASE_USER} -c "drop schema public cascade;"
# psql -h ${DATABASE_HOST_OVERRIDE} -p 5432 -d ${DATABASE_NAME} -U ${DATABASE_USER} -c "create schema public;"

echo Apply migrations
python manage.py migrate --noinput
Expand Down
8 changes: 4 additions & 4 deletions app/deploy/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ set -u # crash on missing env variables
set -e # stop on any error
set -x

echo "Start with a fresh database"
export PGPASSWORD=${DATABASE_PASSWORD}
psql -h ${DATABASE_HOST_OVERRIDE} -p 5432 -d ${DATABASE_NAME} -U ${DATABASE_USER} -c "drop schema public cascade;"
psql -h ${DATABASE_HOST_OVERRIDE} -p 5432 -d ${DATABASE_NAME} -U ${DATABASE_USER} -c "create schema public;"
# echo "Start with a fresh database"
# export PGPASSWORD=${DATABASE_PASSWORD}
# psql -h ${DATABASE_HOST_OVERRIDE} -p 5432 -d ${DATABASE_NAME} -U ${DATABASE_USER} -c "drop schema public cascade;"
# psql -h ${DATABASE_HOST_OVERRIDE} -p 5432 -d ${DATABASE_NAME} -U ${DATABASE_USER} -c "create schema public;"

echo Apply migrations
python manage.py migrate --noinput
Expand Down

0 comments on commit a9de6a6

Please sign in to comment.