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

#695 fix intrests #270

Merged
merged 3 commits into from
Jun 15, 2022
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
14 changes: 14 additions & 0 deletions src/open_inwoner/pdc/tests/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ def test_all_categories_exist_in_context_when_logged_in(self):
[category, highlighted_category],
)

def test_category_selected(self):
user = UserFactory()
category = CategoryFactory(name="Should be first")
highlighted_category = CategoryFactory(
name="This should be second", highlighted=True
)
selected_category = CategoryFactory(name="This should the only one")
user.selected_themes.add(selected_category)
response = self.app.get(reverse("root"), user=user)
self.assertEqual(
list(response.context["categories"]),
[selected_category],
)


class TestHighlightedQuestionnaire(WebTest):
def setUp(self):
Expand Down
7 changes: 7 additions & 0 deletions src/open_inwoner/pdc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ def get_context_data(self, **kwargs):
)
if not self.request.user.is_authenticated and highlighted_categories:
kwargs.update(categories=highlighted_categories)
if (
self.request.user.is_authenticated
and self.request.user.selected_themes.exists()
):
kwargs.update(
categories=self.request.user.selected_themes.order_by("name")[:3]
)

# Product finder:
if config.show_product_finder:
Expand Down