-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ [#4320] Refactor cosign state into dedicated datastructure
The cosign information/state was smeared out across the form and submission model, and is consulted in a number of places to control template/feedback behaviour. The implementation details of how cosign works are now properly encapsulated in a data structure, which also allows us to prepare for cosign v3 which will most-likely not be Formio based.
- Loading branch information
1 parent
2084974
commit 6b62c56
Showing
22 changed files
with
383 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
from typing import NotRequired, TypedDict | ||
|
||
from django import template | ||
from django.template.loader import render_to_string | ||
|
||
from openforms.submissions.models import Submission | ||
|
||
register = template.Library() | ||
|
||
|
||
class CosignInformationContext(TypedDict): | ||
_submission: Submission | ||
rendering_text: NotRequired[bool] | ||
|
||
|
||
@register.simple_tag(takes_context=True) | ||
def cosign_information(context): | ||
def cosign_information(context: CosignInformationContext) -> str: | ||
submission = context["_submission"] | ||
if not (cosign := submission.cosign_state).is_required: | ||
return "" | ||
|
||
if context.get("rendering_text"): | ||
template_name = "emails/templatetags/cosign_information.txt" | ||
else: | ||
template_name = "emails/templatetags/cosign_information.html" | ||
|
||
tag_context = { | ||
"cosign_complete": submission.cosign_complete, | ||
"waiting_on_cosign": submission.waiting_on_cosign, | ||
"cosigner_email": submission.cosigner_email, | ||
"cosign_complete": cosign.is_signed, | ||
"waiting_on_cosign": cosign.is_waiting, | ||
"cosigner_email": cosign.email, | ||
} | ||
return render_to_string(template_name, tag_context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.