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

Last developed features #112

Merged
merged 39 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3b8880a
Remove upgrade step
folix-01 Oct 13, 2023
39073d2
Squashed commit of the following:
folix-01 Oct 13, 2023
c00a081
Resect hidden types from bookign schema
folix-01 Oct 13, 2023
abe9d1a
Squashed commit of the following:
folix-01 Oct 13, 2023
2702a46
Merge branch 'master' into develop
folix-01 Oct 17, 2023
5f6c61f
Add booking_refuse_message to stringinterp vars (#105)
folix-01 Oct 17, 2023
a0e36bf
Squashed commit of the following:
folix-01 Oct 17, 2023
b70fe02
Squashed commit of the following:
folix-01 Oct 17, 2023
db59ae7
Merge branch 'develop' into change_max_default
cekk Oct 18, 2023
5e86978
Merge pull request #104 from RedTurtle/change_max_default
cekk Oct 18, 2023
16d3cd8
Merge branch 'master' into develop
folix-01 Oct 20, 2023
3115bd4
Permissions fix (#106)
folix-01 Oct 20, 2023
965fae3
Update definition.xml
folix-01 Oct 20, 2023
b5e87d5
Fix Bookings Manager permissions
folix-01 Oct 23, 2023
a49d484
Update changelog
folix-01 Oct 24, 2023
bc8371d
Zpretty
folix-01 Oct 26, 2023
04145f0
Merge pull request #107 from RedTurtle/fix_premissions
cekk Oct 27, 2023
323f603
Squashed commit of the following:
folix-01 Oct 30, 2023
b5c52aa
Fix upgrade step
folix-01 Oct 30, 2023
7cfee69
Add bookign_types to PrenotazioniFolder serialized to JSON
folix-01 Oct 30, 2023
5851670
Squashed commit of the following:
folix-01 Oct 31, 2023
a8fcb20
Squashed commit of the following:
folix-01 Oct 31, 2023
1589503
Squashed commit of the following:
folix-01 Oct 31, 2023
7829bc6
Squashed commit of the following:
folix-01 Oct 31, 2023
2cd0032
Squashed commit of the following:
folix-01 Oct 31, 2023
7aba157
Squashed commit of the following:
folix-01 Oct 31, 2023
1a516c1
Squashed commit of the following:
folix-01 Oct 31, 2023
1cdf5cb
Squashed commit of the following:
folix-01 Nov 2, 2023
b49a0f8
Squashed commit of the following:
folix-01 Nov 2, 2023
e1de2d3
Squashed commit of the following:
folix-01 Nov 2, 2023
8d711dd
Squashed commit of the following:
folix-01 Nov 2, 2023
6600a6b
Extend booking duration to 180min.
folix-01 Nov 2, 2023
f099862
Cangelog
folix-01 Nov 2, 2023
4ebe8af
Skip tests by date
folix-01 Nov 2, 2023
e49a587
Squashed commit of the following:
folix-01 Nov 2, 2023
fc21332
Merge pull request #111 from RedTurtle/extended_booking_duration
cekk Nov 3, 2023
5738f12
Formatting
folix-01 Nov 8, 2023
79889af
Squashed commit of the following:
folix-01 Nov 8, 2023
5375fc6
Fix test
folix-01 Nov 8, 2023
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
18 changes: 16 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@ Changelog
2.1.4 (unreleased)
------------------

- Nothing changed yet.
- Extend the booking duration limit to 180 min.
[folix-01]
- Allow Bookings Manager to create, move the bookings and create the vacations.
[folix-01]
- Convert booking types to c.t.
[folix-01]

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

- Fix Bookings Manager permission in according to expected behavior
[folix-01]

- Add booking_refuse_message to Prenotazione stringinterp variables.
[folix-01]


2.1.3 (2023-10-13)
------------------

- Resect hiddent booking types from @booking-schema.
- Resect hidden booking types from @booking-schema.
[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 request provides the migration marker"""
return IMigrationMarker and IMigrationMarker.providedBy(getRequest())


def tznow():
"""Return a timezone aware now"""
Expand Down
8 changes: 7 additions & 1 deletion src/redturtle/prenotazioni/adapters/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
name="booking_time"
/>
<adapter
factory=".stringinterp.BookingTypeSubstitution"
factory=".stringinterp.PrenotazioneTypeSubstitution"
provides="plone.stringinterp.interfaces.IStringSubstitution"
for="*"
name="booking_type"
Expand Down Expand Up @@ -153,6 +153,12 @@
for="*"
name="booking_url_with_delete_token"
/>
<adapter
factory=".stringinterp.BookingRefuseMessage"
provides="plone.stringinterp.interfaces.IStringSubstitution"
for="*"
name="booking_refuse_message"
/>

<!-- ical adapters -->
<adapter
Expand Down
26 changes: 25 additions & 1 deletion src/redturtle/prenotazioni/adapters/stringinterp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
from plone import api
from plone.app.event.base import default_timezone
from plone.app.layout.viewlets.content import ContentHistoryViewlet
from plone.stringinterp.adapters import BaseSubstitution
from zope.component import adapter
from zope.globalrequest import getRequest
from zope.interface import Interface

from redturtle.prenotazioni import _, logger
Expand Down Expand Up @@ -78,7 +81,7 @@ def safe_call(self):


@adapter(Interface)
class BookingTypeSubstitution(BaseSubstitution):
class PrenotazioneTypeSubstitution(BaseSubstitution):
category = _("Booking")
description = _("The booking type.")

Expand Down Expand Up @@ -238,3 +241,24 @@ class BookingOperatorUrlSubstitution(BaseSubstitution):

def safe_call(self):
return self.context.absolute_url()


@adapter(Interface)
class BookingRefuseMessage(BaseSubstitution):
category = _("Booking")
description = _("The booking refuse message")

def safe_call(self):
content_history_viewlet = ContentHistoryViewlet(
self.context, getRequest(), None, None
)
site_url = api.portal.get().absolute_url()
content_history_viewlet.navigation_root_url = site_url
content_history_viewlet.site_url = site_url
history = content_history_viewlet.workflowHistory()

refuse_history = [i for i in history if i.get("action", "") == "refuse"]

refuse_message = refuse_history and refuse_history[0].get("comments") or ""

return refuse_message
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>
26 changes: 11 additions & 15 deletions src/redturtle/prenotazioni/browser/prenotazioni_context_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from redturtle.prenotazioni.adapters.slot import BaseSlot, ISlot
from redturtle.prenotazioni.config import PAUSE_PORTAL_TYPE, PAUSE_SLOT
from redturtle.prenotazioni.content.pause import Pause
from redturtle.prenotazioni.content.prenotazione_type import PrenotazioneType
from redturtle.prenotazioni.utilities.dateutils import hm2DT, hm2seconds
from redturtle.prenotazioni.utilities.urls import urlify

Expand Down Expand Up @@ -824,27 +825,22 @@ 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):
"""Return the seconds for this booking_type"""
if isinstance(booking_type, dict):
return int(booking_type["duration"]) * 60
if isinstance(booking_type, six.string_types) and not isinstance(
booking_type, six.text_type
):
booking_type = booking_type
if type(booking_type) is PrenotazioneType:
return int(booking_type.duration) * 60

if type(booking_type) is str:
return int(self.booking_type_durations.get(booking_type, 1))

# XXX: se il booking_type non esiste, ritorna 1 minuto, è corretto ????
return self.booking_type_durations.get(booking_type, 1)
return 1

@memoize
def booking_types_bookability(self, booking_date):
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>
Loading
Loading