1.1 --- a/docs/preferences.txt Tue Oct 27 18:44:26 2015 +0100
1.2 +++ b/docs/preferences.txt Tue Oct 27 18:46:48 2015 +0100
1.3 @@ -219,7 +219,8 @@
1.4 to the permitted_times setting (see
1.5 above), if configured, and attempt to schedule the
1.6 event according to the free/busy records for the
1.7 - resource, seeking the next available free period for
1.8 + resource and for any attendees for whom records are
1.9 + available, seeking the next available free period for
1.10 each period that conflicts with an existing event
1.11
1.12 The scheduling mechanism can be extended by implementing additional scheduling
2.1 --- a/imiptools/handlers/scheduling.py Tue Oct 27 18:44:26 2015 +0100
2.2 +++ b/imiptools/handlers/scheduling.py Tue Oct 27 18:46:48 2015 +0100
2.3 @@ -19,8 +19,9 @@
2.4 this program. If not, see <http://www.gnu.org/licenses/>.
2.5 """
2.6
2.7 +from imiptools.data import uri_values
2.8 from imiptools.dates import ValidityError, to_timezone
2.9 -from imiptools.period import invert_freebusy, periods_from
2.10 +from imiptools.period import get_common_periods, invert_freebusy, periods_from
2.11
2.12 def schedule_in_freebusy(handler):
2.13
2.14 @@ -97,9 +98,17 @@
2.15 return scheduled
2.16
2.17 # Find free periods, update the object with the details.
2.18 + # There should already be free/busy information for the user.
2.19
2.20 - freebusy = handler.store.get_freebusy(handler.user)
2.21 - free = invert_freebusy(freebusy)
2.22 + all_free = [invert_freebusy(handler.store.get_freebusy(handler.user))]
2.23 +
2.24 + for attendee in uri_values(handler.obj.get_values("ATTENDEE")):
2.25 + if attendee != handler.user:
2.26 + freebusy = handler.store.get_freebusy_for_other(handler.user, attendee)
2.27 + if freebusy:
2.28 + all_free.append(invert_freebusy(freebusy))
2.29 +
2.30 + free = get_common_periods(all_free)
2.31 permitted_values = handler.get_permitted_values()
2.32 periods = []
2.33
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/tests/templates/fb-publish-conflicts.txt Tue Oct 27 18:46:48 2015 +0100
3.3 @@ -0,0 +1,32 @@
3.4 +Content-Type: multipart/alternative; boundary="===============0945993647=="
3.5 +MIME-Version: 1.0
3.6 +From: paul.boddie@example.com
3.7 +To: resource-room-sauna@example.com
3.8 +Subject: Availability
3.9 +
3.10 +--===============0945993647==
3.11 +Content-Type: text/plain; charset="us-ascii"
3.12 +MIME-Version: 1.0
3.13 +Content-Transfer-Encoding: 7bit
3.14 +
3.15 +This message contains a free/busy object.
3.16 +--===============0945993647==
3.17 +Content-Type: text/calendar; charset="us-ascii"; method="PUBLISH"
3.18 +MIME-Version: 1.0
3.19 +Content-Transfer-Encoding: 7bit
3.20 +
3.21 +BEGIN:VCALENDAR
3.22 +PRODID:-//imip-agent/test//EN
3.23 +METHOD:PUBLISH
3.24 +VERSION:2.0
3.25 +BEGIN:VFREEBUSY
3.26 +ORGANIZER:mailto:paul.boddie@example.com
3.27 +ATTENDEE:mailto:resource-room-sauna@example.com
3.28 +UID:mailto:resource-room-sauna@example.com
3.29 +DTSTAMP:20140301T163916Z
3.30 +FREEBUSY;FBTYPE=BUSY:20141126T160000Z/20141126T170000Z
3.31 +FREEBUSY;FBTYPE=BUSY:20141126T180000Z/20141126T190000Z
3.32 +END:VFREEBUSY
3.33 +END:VCALENDAR
3.34 +
3.35 +--===============0945993647==--
4.1 --- a/tests/test_resource_invitation_constraints_next_free.sh Tue Oct 27 18:44:26 2015 +0100
4.2 +++ b/tests/test_resource_invitation_constraints_next_free.sh Tue Oct 27 18:46:48 2015 +0100
4.3 @@ -14,6 +14,7 @@
4.4 SENDER="mailto:paul.boddie@example.com"
4.5 RIVALSENDER="mailto:vincent.vole@example.com"
4.6 FBFILE="$STORE/$USER/freebusy"
4.7 +FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER"
4.8 FBOFFERFILE="$STORE/$USER/freebusy-offers"
4.9 FBSENDERFILE="$STORE/$SENDER/freebusy"
4.10 FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER"
4.11 @@ -79,6 +80,17 @@
4.12 | "$SHOWMAIL" \
4.13 > out2.tmp
4.14
4.15 +# Publish some conflicting periods as busy.
4.16 +
4.17 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-publish-conflicts.txt" 2>> $ERROR \
4.18 +| "$SHOWMAIL" \
4.19 +> out3.tmp
4.20 +
4.21 + grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOTHERFILE" \
4.22 +&& grep -q "^20141126T180000Z${TAB}20141126T190000Z" "$FBOTHERFILE" \
4.23 +&& echo "Success" \
4.24 +|| echo "Failed"
4.25 +
4.26 # Attempt to schedule an event with the resource.
4.27
4.28 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR
4.29 @@ -88,7 +100,8 @@
4.30 || echo "Failed"
4.31
4.32 # Present the request to the resource. This should cause the event to be
4.33 -# proposed one hour later.
4.34 +# proposed not just after the requested period, but also after the busy periods
4.35 +# published to the resource.
4.36
4.37 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR \
4.38 | tee out6r.tmp \
4.39 @@ -101,7 +114,11 @@
4.40 || echo "Failed"
4.41
4.42 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \
4.43 -&& grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \
4.44 +&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \
4.45 +&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \
4.46 +&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \
4.47 +&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \
4.48 +&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \
4.49 && echo "Success" \
4.50 || echo "Failed"
4.51
4.52 @@ -135,7 +152,7 @@
4.53 "$OUTGOING_SCRIPT" $ARGS < out8.tmp 2>> $ERROR
4.54
4.55 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
4.56 -&& grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \
4.57 +&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBSENDERFILE" \
4.58 && echo "Success" \
4.59 || echo "Failed"
4.60
4.61 @@ -152,17 +169,21 @@
4.62 > out9.tmp
4.63
4.64 grep -q 'METHOD:REPLY' out9.tmp \
4.65 -&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' out9.tmp \
4.66 +&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out9.tmp \
4.67 && echo "Success" \
4.68 || echo "Failed"
4.69
4.70 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \
4.71 && ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \
4.72 +&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \
4.73 +&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \
4.74 +&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \
4.75 +&& ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \
4.76 && echo "Success" \
4.77 || echo "Failed"
4.78
4.79 [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \
4.80 && [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \
4.81 -&& grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \
4.82 +&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \
4.83 && echo "Success" \
4.84 || echo "Failed"