Skip to content

Commit

Permalink
Merge pull request #1154 from maykinmedia/fix/2248-eherkenning-profil…
Browse files Browse the repository at this point in the history
…e-edit

[#2248] Make contact details editable for eHerkenning user
  • Loading branch information
alextreme authored Apr 19, 2024
2 parents a18f746 + 0d9ecba commit a9637ba
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
16 changes: 14 additions & 2 deletions src/open_inwoner/accounts/tests/test_profile_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_info_eherkenning_user(self):
doc = PQ(response.content)

business_section = doc.find("#business-overview")[0]
self.assertEqual(business_section.text, "Bedrijfsgegevens")
self.assertEqual(business_section.text.strip(), "Bedrijfsgegevens")

# check personal overview section not displayed
personal_section = doc.find("#personal-overview")
Expand Down Expand Up @@ -290,6 +290,7 @@ def setUp(self):
self.url = reverse("profile:edit")
self.return_url = reverse("profile:detail")
self.user = UserFactory()
self.eherkenning_user = eHerkenningUserFactory()

def upload_test_image_to_profile_edit_page(self, img_bytes):
response = self.app.get(self.url, user=self.user, status=200)
Expand Down Expand Up @@ -394,6 +395,17 @@ def test_modify_email_succeeds(self):
self.assertEqual(response.url, self.return_url)
self.assertEqual(self.user.email, "[email protected]")

def test_modify_contact_details_eherkenning_succeeds(self):
response = self.app.get(self.url, user=self.eherkenning_user)
form = response.forms["profile-edit"]
form["email"] = "[email protected]"
form["phonenumber"] = "0612345678"
response = form.submit()
self.eherkenning_user.refresh_from_db()
self.assertEqual(response.url, self.return_url)
self.assertEqual(self.eherkenning_user.email, "[email protected]")
self.assertEqual(self.eherkenning_user.phonenumber, "0612345678")

def test_updating_a_field_without_modifying_email_succeeds(self):
initial_email = self.user.email
initial_first_name = self.user.first_name
Expand Down Expand Up @@ -633,7 +645,7 @@ def test_modify_phone_updates_klant_api_but_skip_unchanged_email(self, m):
)

@requests_mock.Mocker()
def test_modify_phone_updates_klant_api_but_skip_unchanged_phone(self, m):
def test_modify_email_updates_klant_api_but_skip_unchanged_phone(self, m):
MockAPIReadPatchData.setUpServices()
data = MockAPIReadPatchData().install_mocks(m)

Expand Down
5 changes: 4 additions & 1 deletion src/open_inwoner/templates/pages/profile/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ <h1 class="h1" id="title">
{% csrf_token %}

{% with request.user as user %}
{% if user.is_digid_user_with_brp %}
{% if user.is_eherkenning_user %}
{% input form.email %}
{% input form.phonenumber %}
{% elif user.is_digid_user_with_brp %}
{% input form.display_name %}
{% input form.email %}
{% input form.phonenumber %}
Expand Down
14 changes: 13 additions & 1 deletion src/open_inwoner/templates/pages/profile/me.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ <h1 class="h1" id="title">{% trans "Welkom" %}{% if not user.is_eherkenning_user
{# Business information #}
<section class="tabled tabled--flexible profile-section profile-section--bordered profile-section__business-overview">
<div class="tabled__section">
<h2 class="h2 title" id="business-overview">{% trans "Bedrijfsgegevens" %}</h2>
<h2 class="h2 title" id="business-overview">{% trans "Bedrijfsgegevens" %}
<div class="tabled__item--force-right tabled__item--mobile-big">
{% button href="profile:edit" text=_("Bewerk") icon="edit" transparent=True icon_outlined=True %}
</div>
</h2>
</div>
<div class="tabled__row tabled__row--blank">
<div class="tabled__item tabled__key">{% trans "Handelsnaam" %}</div>
Expand All @@ -38,6 +42,14 @@ <h2 class="h2 title" id="business-overview">{% trans "Bedrijfsgegevens" %}</h2>
<div>{{ user.postcode }} {{ user.city }}</div>
</div>
</div>
<div class="tabled__row tabled__row--blank">
<div class="tabled__item tabled__key">{% trans "E-mail adres" %}</div>
<div class="tabled__item tabled__value">{{ user.email }}</div>
</div>
<div class="tabled__row tabled__row--blank">
<div class="tabled__item tabled__key">{% trans "Telefoonnummer" %}</div>
<div class="tabled__item tabled__value">{{ user.phonenumber }}</div>
</div>
</section>
{% else %}
{# Personal information #}
Expand Down

0 comments on commit a9637ba

Please sign in to comment.