-
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.
Merge pull request #4888 from open-formulieren/chore/4320-refactor-co…
…sign-state Refactor (accessing) the cosign state
- Loading branch information
Showing
23 changed files
with
545 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.