Skip to content

Commit

Permalink
handle custom status message in prenotazione_print
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Jul 26, 2023
1 parent 8146927 commit 318312c
Show file tree
Hide file tree
Showing 5 changed files with 384 additions and 278 deletions.
39 changes: 35 additions & 4 deletions src/redturtle/prenotazioni/browser/prenotazione_print.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from plone import api
from plone.memoize.view import memoize
from plone.protect.utils import addTokenToUrl
from Products.CMFCore.utils import getToolByName
Expand All @@ -16,10 +17,40 @@ class PrenotazionePrint(BrowserView):

print_action = "javascript:this.print();"

description = _(
"confirm_booking_waiting_message",
"Your booking has to be confirmed by the administrators",
)
@property
def get_status_message(self):
review_state = api.content.get_state(obj=self.prenotazione)
messages_mapping = {
"pending": {
"text": _(
"confirm_booking_waiting_message",
"Your booking has to be confirmed by the administrators.",
),
"type": "info",
"role": "status",
},
"confirmed": {
"text": _(
"confirm_booking_confirmed_message",
"Your booking has been confirmed.",
),
"type": "info",
"role": "status",
},
"refused": {
"text": _(
"confirm_booking_refused_message",
"Your booking has been refused.",
),
"type": "warning",
"role": "alert",
},
}
return messages_mapping.get(review_state, "")

@property
def is_plone_6(self):
return api.env.plone_version() >= "6.0"

@property
@memoize
Expand Down
24 changes: 21 additions & 3 deletions src/redturtle/prenotazioni/browser/templates/prenotazione_print.pt
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,33 @@ i18n:domain="redturtle.prenotazioni">
<metal:content fill-slot="main"
tal:define="prenotazione nocall:view/prenotazione;
prenotazioni_folder prenotazione/getPrenotazioniFolder;
toLocalizedTime nocall:context/@@plone/toLocalizedTime"
toLocalizedTime nocall:context/@@plone/toLocalizedTime;
status_message view/get_status_message;
is_plone_6 view/is_plone_6"
>
<div tabindex="0">
<h1 class="documentFirstHeading" tal:content="view/label">
Booking request
</h1>
<div class="documentDescription" tal:content="view/description">
<tal:alert condition="status_message">
<tal:old condition="not: is_plone_6">
<div class="portalMessage ${status_message/type}"
role="${status_message/role}"
tabindex="-1"
tal:condition="status_message">
${status_message/text}
</div>
</tal:old>
<tal:new condition="is_plone_6">
<div class="alert alert-${status_message/type}" role="alert">
${status_message/text}
</div>
</tal:new>
</tal:alert>
<!-- <div class="documentDescription" tal:content="view/description">
Booking description
</div>
</div> -->

<p>
Gentile <b tal:content="prenotazione/Title">Fullname</b>,
di seguito sono elencati i dati relativi alla sua prenotazione:
Expand Down
Loading

0 comments on commit 318312c

Please sign in to comment.