-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from maykinmedia/feature/register-necessary-f…
…ields Feature/register necessary fields
- Loading branch information
Showing
14 changed files
with
312 additions
and
76 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
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,26 @@ | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
|
||
|
||
class NecessaryFieldsMiddleware: | ||
""" | ||
Redirect the user to a view to fill in necessary fields | ||
""" | ||
|
||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
|
||
def __call__(self, request): | ||
user = request.user | ||
if user.is_authenticated: | ||
necessary_fields_url = reverse("accounts:registration_necessary") | ||
|
||
# If the user is currently not editing their information, but it is required | ||
# redirect to that view. | ||
if ( | ||
not request.path.startswith((necessary_fields_url, reverse("logout"))) | ||
and request.user.require_necessary_fields() | ||
): | ||
return HttpResponseRedirect(necessary_fields_url) | ||
|
||
return self.get_response(request) |
30 changes: 30 additions & 0 deletions
30
src/open_inwoner/accounts/migrations/0043_change_digid_email.py
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,30 @@ | ||
from django.db import migrations | ||
from open_inwoner.utils.hash import generate_email_from_string | ||
from ..choices import LoginTypeChoices | ||
|
||
|
||
def change_bsn_email_to_hash(apps, _): | ||
User = apps.get_model("accounts", "User") | ||
|
||
for user in User.objects.filter(login_type=LoginTypeChoices.digid).all(): | ||
if user.email == f"user-{user.bsn}@bsn.com": | ||
user.email = generate_email_from_string(user.bsn) | ||
user.save() | ||
|
||
|
||
def change_hash_email_to_bsn(apps, _): | ||
User = apps.get_model("accounts", "User") | ||
|
||
for user in User.objects.filter(login_type=LoginTypeChoices.digid).all(): | ||
if user.email == generate_email_from_string(user.bsn): | ||
user.email = f"user-{user.bsn}@bsn.com" | ||
user.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [("accounts", "0042_alter_invite_invitee_email")] | ||
|
||
operations = [ | ||
migrations.RunPython(change_bsn_email_to_hash, change_hash_email_to_bsn) | ||
] |
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
15 changes: 15 additions & 0 deletions
15
src/open_inwoner/accounts/templates/accounts/registration_necessary.html
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,15 @@ | ||
{% extends 'master.html' %} | ||
{% load i18n static form_tags card_tags grid_tags %} | ||
|
||
{% block content %} | ||
|
||
{% render_grid %} | ||
{% render_column span=9 %} | ||
{% render_card tinted=True %} | ||
<h1 class="h1">{% trans "Registratie voltooien" %}</h1><br> | ||
{% form form_object=form method="POST" id="necessary-form" %} | ||
{% endrender_card %} | ||
{% endrender_column %} | ||
{% endrender_grid %} | ||
|
||
{% endblock content %} |
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
Oops, something went wrong.