Skip to content

Commit

Permalink
✨ [#1866] Enable category personalization based on KvK number
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Nov 27, 2023
1 parent 031c980 commit c788c6b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/open_inwoner/accounts/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class DigidUserFactory(UserFactory):
is_prepopulated = True


class eHerkenningUserFactory(UserFactory):
login_type = LoginTypeChoices.eherkenning
kvk = "12345678"
is_prepopulated = True


class TokenFactory(factory.django.DjangoModelFactory):
class Meta:
model = "authtoken.Token"
Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/pdc/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def draft(self):

def visible_for_user(self, user: User):
if user.is_authenticated:
if getattr(user, "bsn", None):
if user.bsn:
return self.filter(visible_for_citizens=True)
elif getattr(user, "kvk", None):
elif user.kvk:
return self.filter(visible_for_companies=True)
return self.filter(visible_for_authenticated=True)
return self.filter(visible_for_anonymous=True)
Expand Down
10 changes: 6 additions & 4 deletions src/open_inwoner/pdc/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from django.test import TestCase, override_settings
from django.urls import reverse

from open_inwoner.accounts.tests.factories import DigidUserFactory, UserFactory
from open_inwoner.accounts.tests.factories import (
DigidUserFactory,
UserFactory,
eHerkenningUserFactory,
)
from open_inwoner.configurations.models import SiteConfiguration

from .factories import CategoryFactory
Expand Down Expand Up @@ -121,12 +125,10 @@ def test_category_list_view_visibility_for_digid_user(self):
list(response.context["object_list"]), [self.category2, self.category3]
)

@skip("eHerkenning is not implemented yet")
def test_category_list_view_visibility_for_eherkenning_user(self):
url = reverse("products:category_list")

# TODO should be eHerkenningUserFactory
user = DigidUserFactory()
user = eHerkenningUserFactory()
self.client.force_login(user)

# request with eHerkenning user
Expand Down

0 comments on commit c788c6b

Please sign in to comment.