Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Oct 26, 2023
1 parent 965fae3 commit 22bfb5d
Show file tree
Hide file tree
Showing 90 changed files with 3,615 additions and 2,393 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
2.1.4 (unreleased)
------------------

- Convert bookgig types to c.t.
[folix-01]

- Change bookings default limit to 0.
[folix-01]

Expand Down
13 changes: 11 additions & 2 deletions src/redturtle/prenotazioni/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@
from plone.api.exc import UserNotFoundError
from plone.app.event.base import default_timezone
from six.moves import map
from zope.globalrequest import getRequest
from zope.i18nmessageid import MessageFactory

from redturtle.prenotazioni.utils import is_migration

logger = getLogger("redturtle.prenotazioni")
_ = MessageFactory("redturtle.prenotazioni")

prenotazioniMessageFactory = MessageFactory("redturtle.prenotazioni")
prenotazioniFileLogger = getLogger("redturtle.prenotazioni.file")

try:
from collective.exportimport.interfaces import IMigrationMarker
except ImportError:
IMigrationMarker = None


def is_migration():
"""Returns True if the current reqeust provides the migration marker"""
return IMigrationMarker and IMigrationMarker.providedBy(getRequest())


def tznow():
"""Return a timezone aware now"""
Expand Down
35 changes: 23 additions & 12 deletions src/redturtle/prenotazioni/browser/custom_radio_input.pt
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal"
tal:omit-tag="">
<span class="option"
tal:repeat="item view/items">
<label for=""
tal:attributes="for item/id">
<input tal:replace="structure python:view.renderForValue(item['value'], item['index'])"
/>
<span class="label" tal:content="item/label">Label</span>
</label>
</span>
<input name="field-empty-marker" type="hidden" value="1"
tal:attributes="name string:${view/name}-empty-marker" />
tal:omit-tag=""
>
<span class="option"
tal:repeat="item view/items"
>
<label for=""
tal:attributes="
for item/id;
"
>
<input tal:replace="structure python:view.renderForValue(item['value'], item['index'])" />
<span class="label"
tal:content="item/label"
>Label</span>
</label>
</span>
<input name="field-empty-marker"
type="hidden"
value="1"
tal:attributes="
name string:${view/name}-empty-marker;
"
/>
</html>
11 changes: 3 additions & 8 deletions src/redturtle/prenotazioni/browser/prenotazioni_context_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,15 +824,10 @@ def booking_type_durations(self):
}
"""

def get_duration(duration):
if isinstance(duration, tuple):
return int(duration[0])
return int(duration)

return {
typ["name"]: get_duration(typ["duration"])
for typ in getattr(self.context, "booking_types", [])
if typ["duration"]
typ.title: typ.duration
for typ in self.context.get_booking_types()
if typ.duration
}

def get_booking_type_duration(self, booking_type):
Expand Down
24 changes: 14 additions & 10 deletions src/redturtle/prenotazioni/browser/stats/booking_stats.pt
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
metal:use-macro="context/main_template/macros/master"
i18n:domain="redturtle.prenotazioni">
<head>
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
metal:use-macro="context/main_template/macros/master"
i18n:domain="redturtle.prenotazioni"
>
<head>
<metal:block fill-slot="top_slot"
tal:define="disable_column_one python:request.set('disable_plone.leftcolumn',1);
disable_column_two python:request.set('disable_plone.rightcolumn',1);" />
</head>
tal:define="
disable_column_one python:request.set('disable_plone.leftcolumn',1);
disable_column_two python:request.set('disable_plone.rightcolumn',1);
"
/>
</head>

<body>
<metal:main fill-slot="main">
<!-- -->
<!-- -->
</metal:main>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,61 +1,86 @@
<div
metal:define-macro="widget-wrapper"
i18n:domain="plone"
tal:define="widget nocall:context;
hidden python:widget.mode == 'hidden';
error widget/error;
error_class python:error and ' error' or '';
empty_values python: (None, '', [], ('', '', '', '00', '00', ''), ('', '', ''));
empty_class python: (widget.value in empty_values) and ' empty' or '';
wrapper_css_class widget/wrapper_css_class|nothing;
fieldname_class string:kssattr-fieldname-${widget/name};"
data-pat-inlinevalidation='{"type":"z3c.form"}'
tal:attributes="class string:field pat-inlinevalidation ${fieldname_class}${error_class}${empty_class} ${wrapper_css_class};
data-fieldname widget/name;
id string:formfield-${widget/id};">
<label for="" class="horizontal"
tal:attributes="for widget/id;
aria-label python: widget.get_radio_message(widget.label)"
tal:condition="python: not hidden and widget.label"
tabindex="0"
aria-label="Selezionare un elemento dalla check list seguente">
<span i18n:translate="" tal:replace="widget/label">label</span>
<span class="required horizontal" title="Required"
tal:condition="python:widget.required and widget.mode == 'input'"
i18n:attributes="title title_required;">&nbsp;</span>
<div metal:define-macro="widget-wrapper"
data-pat-inlinevalidation='{"type":"z3c.form"}'
tal:define="
widget nocall:context;
hidden python:widget.mode == 'hidden';
error widget/error;
error_class python:error and ' error' or '';
empty_values python: (None, '', [], ('', '', '', '00', '00', ''), ('', '', ''));
empty_class python: (widget.value in empty_values) and ' empty' or '';
wrapper_css_class widget/wrapper_css_class|nothing;
fieldname_class string:kssattr-fieldname-${widget/name};
"
tal:attributes="
class string:field pat-inlinevalidation ${fieldname_class}${error_class}${empty_class} ${wrapper_css_class};
data-fieldname widget/name;
id string:formfield-${widget/id};
"
i18n:domain="plone"
>
<label class="horizontal"
aria-label="Selezionare un elemento dalla check list seguente"
for=""
tabindex="0"
tal:condition="python: not hidden and widget.label"
tal:attributes="
for widget/id;
aria-label python: widget.get_radio_message(widget.label);
"
>
<span tal:replace="widget/label"
i18n:translate=""
>label</span>
<span class="required horizontal"
title="Required"
tal:condition="python:widget.required and widget.mode == 'input'"
i18n:attributes="title title_required;"
>&nbsp;</span>

<span class="formHelp"
tal:define="description python: getattr(widget, 'description', widget.field.description)"
i18n:translate=""
tal:content="structure description"
tal:condition="python:description and not hidden"
>field description
</span>
</label>
<div class="fieldErrorBox"
tal:content="structure error/render|nothing">
<span class="formHelp"
tal:define="
description python: getattr(widget, 'description', widget.field.description);
"
tal:condition="python:description and not hidden"
tal:content="structure description"
i18n:translate=""
>field description
</span>
</label>
<div class="fieldErrorBox"
tal:content="structure error/render|nothing"
>
Error
</div>
<input type="text" tal:replace="structure widget/render"
metal:define-slot="widget" />
<div class="unbookable"
tal:define="unbookable_items nocall:view/unbookable_items"
tal:condition="unbookable_items"
i18n:domain="redturtle.prenotazioni">
<p class="formHelp" i18n:translate="booking_type_widget_warn_unavailable">
</div>
<input metal:define-slot="widget"
type="text"
tal:replace="structure widget/render"
/>
<div class="unbookable"
tal:define="
unbookable_items nocall:view/unbookable_items;
"
tal:condition="unbookable_items"
i18n:domain="redturtle.prenotazioni"
>
<p class="formHelp"
i18n:translate="booking_type_widget_warn_unavailable"
>
The following tipologies will not fit the time you selected:
</p>
<ul>
<li tal:repeat="item unbookable_items">
<tal:li replace="item/title">Vocabulary title</tal:li>
</li>
</ul>
<div class="visualClear"></div>
<p class="formHelp">
<a tal:attributes="href view/prenotazione_add/back_to_booking_url"
i18n:translate="booking_type_widget_suggest_reselect">
</p>
<ul>
<li tal:repeat="item unbookable_items">
<tal:li replace="item/title">Vocabulary title</tal:li>
</li>
</ul>
<div class="visualClear"></div>
<p class="formHelp">
<a tal:attributes="
href view/prenotazione_add/back_to_booking_url;
"
i18n:translate="booking_type_widget_suggest_reselect"
>
You may want to select another time slot to book one of these.
</a>
</p>
</div>
</a>
</p>
</div>
</div>
87 changes: 51 additions & 36 deletions src/redturtle/prenotazioni/browser/templates/custom_dgf_input.pt
Original file line number Diff line number Diff line change
@@ -1,40 +1,55 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal"
tal:omit-tag="">
tal:omit-tag=""
>

<label tal:content="view/value" />
<input id="" name="" class="" title="" lang="" disabled=""
readonly="" alt="" tabindex="" accesskey="" size="" maxlength=""
style="" value="" type="hidden"
tal:attributes="id view/id;
name view/name;
class view/klass;
style view/style;
title view/title;
lang view/lang;
onclick view/onclick;
ondblclick view/ondblclick;
onmousedown view/onmousedown;
onmouseup view/onmouseup;
onmouseover view/onmouseover;
onmousemove view/onmousemove;
onmouseout view/onmouseout;
onkeypress view/onkeypress;
onkeydown view/onkeydown;
onkeyup view/onkeyup;
value view/value;
disabled view/disabled;
tabindex view/tabindex;
onfocus view/onfocus;
onblur view/onblur;
onchange view/onchange;
readonly view/readonly;
alt view/alt;
accesskey view/accesskey;
onselect view/onselect;
size view/size;
maxlength view/maxlength;
placeholder view/placeholder;
autocapitalize view/autocapitalize;" />
<label tal:content="view/value"></label>
<input class=""
id=""
accesskey=""
alt=""
disabled
lang=""
maxlength=""
name=""
readonly
size=""
style=""
tabindex=""
title=""
type="hidden"
value=""
tal:attributes="
id view/id;
name view/name;
class view/klass;
style view/style;
title view/title;
lang view/lang;
onclick view/onclick;
ondblclick view/ondblclick;
onmousedown view/onmousedown;
onmouseup view/onmouseup;
onmouseover view/onmouseover;
onmousemove view/onmousemove;
onmouseout view/onmouseout;
onkeypress view/onkeypress;
onkeydown view/onkeydown;
onkeyup view/onkeyup;
value view/value;
disabled view/disabled;
tabindex view/tabindex;
onfocus view/onfocus;
onblur view/onblur;
onchange view/onchange;
readonly view/readonly;
alt view/alt;
accesskey view/accesskey;
onselect view/onselect;
size view/size;
maxlength view/maxlength;
placeholder view/placeholder;
autocapitalize view/autocapitalize;
"
/>
</html>

Loading

0 comments on commit 22bfb5d

Please sign in to comment.