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

✨ [#1866] Enable category personalization based on KvK number #859

Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading