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

Fixes prompted by prep for demo 2024 11 12 #1493

Merged
merged 7 commits into from
Nov 13, 2024
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
2 changes: 1 addition & 1 deletion src/open_inwoner/accounts/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def update_user_from_klant_on_login(sender, user, request, *args, **kwargs):
fetch_params=fetch_params, user=user
)
if partij and not created:
service.update_user_from_partij(partij_uuid=partij.uuid, user=user)
service.update_user_from_partij(partij_uuid=partij["uuid"], user=user)

# eSuite
try:
Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/accounts/views/contactmoments.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class VragenService(Protocol):
def list_questions(
self,
fetch_params: FetchParameters,
user: User | None = None,
user: User,
) -> Iterable[Question]: # noqa: E704
...

Expand All @@ -89,7 +89,7 @@ def get_fetch_parameters(
class KlantContactMomentBaseView(
CommonPageMixin, BaseBreadcrumbMixin, KlantContactMomentAccessMixin, TemplateView
):
def get_service(self, service_type: str) -> VragenService:
def get_service(self, service_type: KlantenServiceType) -> VragenService:
if service_type == KlantenServiceType.ESUITE:
return eSuiteVragenService()
elif service_type == KlantenServiceType.OPENKLANT2:
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/accounts/views/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_or_create_klant_for_new_user(

# OpenKlant2
# TODO: replace with proper config and refactor branching
use_ok2 = getattr(settings, "OPENKLANT2_ACTIVE", None)
use_ok2 = getattr(settings, "OPENKLANT2_CONFIG", None)
if use_ok2 and (openklant2_config := OpenKlant2Config.from_django_settings()):
try:
service = OpenKlant2Service(config=openklant2_config)
Expand Down
16 changes: 8 additions & 8 deletions src/open_inwoner/openklant/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ def find_organisatie_for_vestigingsnummer(

def get_or_create_partij_for_user(
self, fetch_params: FetchParameters, user: User
) -> (Partij | None, bool):
) -> tuple[Partij | None, bool]:
partij = None
created = False

Expand Down Expand Up @@ -1247,10 +1247,10 @@ def questions_for_partij(self, partij_uuid: str) -> list[OpenKlant2Question]:
def list_questions(
self, fetch_params: FetchParameters, user: User
) -> list[Question]:
if bsn := fetch_params.get("user_bsn"):
partij = self.find_persoon_for_bsn(bsn)
elif kvk_or_rsin := fetch_params.get("user_kvk_or_rsin"):
partij = self.find_organisatie_for_kvk(kvk_or_rsin)
partij, created = self.get_or_create_partij_for_user(fetch_params, user)
if not partij:
# Will be logged by get_or_create_partij_for_user
return []

questions = self.questions_for_partij(partij_uuid=partij["uuid"])
return self._reformat_questions(questions, user)
Expand All @@ -1265,7 +1265,7 @@ def _reformat_questions(
) -> list[Question]:
questions = []
for q in questions_ok2:
answer_metadata = KlantContactMomentAnswer.objects.get_or_create(
answer_metadata, _ = KlantContactMomentAnswer.objects.get_or_create(
user=user, contactmoment_url=q.url
)
question = {
Expand All @@ -1274,7 +1274,7 @@ def _reformat_questions(
"subject": q.onderwerp,
"registered_date": q.plaatsgevonden_op,
"question_text": q.question,
"answer_text": q.answer.answer,
"answer_text": getattr(q.answer, "answer", None),
"status": "",
"channel": q.kanaal,
"case_detail_url": "",
Expand All @@ -1287,7 +1287,7 @@ def _reformat_questions(
return [QuestionValidator.validate_python(q) for q in questions]

def _has_new_answer_available(
self, question: Question, answer: KlantContactMomentAnswer
self, question: OpenKlant2Question, answer: KlantContactMomentAnswer
) -> bool:
answer_is_recent = instance_is_new(
question.answer,
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/templates/pages/contactmoment/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2 class="utrecht-heading-2">{% trans "Stel een vraag" %}</h2>

{# grid with questions #}
<div class="contactmomenten">
{% if vragen %}
{% if contactmomenten %}
<h2 class="contactmomenten__title">{% trans "Eerder gestelde vragen" %}</h2>
{% else %}
<h2>{% trans "U heeft op dit moment nog geen vragen." %}</h2>
Expand Down
Loading