# HG changeset patch # User Paul Boddie # Date 1444058430 -7200 # Node ID 1a3b529fc4fd2bf7576848378695d6579e863b75 # Parent c9ec64bc5f7957beefa28d603765ea5d284afa2e Added support for DECLINECOUNTER to the person handlers. diff -r c9ec64bc5f79 -r 1a3b529fc4fd imiptools/handlers/person.py --- a/imiptools/handlers/person.py Mon Oct 05 17:19:54 2015 +0200 +++ b/imiptools/handlers/person.py Mon Oct 05 17:20:30 2015 +0200 @@ -105,6 +105,20 @@ return True + def _declinecounter(self): + + "Revoke any counter-proposal recorded as a free/busy offer." + + # Obtain valid organiser and attendee details. + + oa = self.require_organiser_and_attendees() + if not oa: + return False + + self.remove_event_from_freebusy_offers() + + return True + def _record(self, from_organiser=True, queue=False, cancel=False): """ @@ -264,13 +278,14 @@ "Record a counter-proposal to a proposed event." if self._counter(): - return self.wrap("A counter proposal to an event invitation has been received.", link=False) + return self.wrap("A counter proposal to an event invitation has been received.", link=True) def declinecounter(self): - # NOTE: Queue a rejected modification to any active event. + "Record a rejection of a counter-proposal." - return self.wrap("Your counter proposal to an event invitation has been declined.", link=False) + if self._declinecounter(): + return self.wrap("Your counter proposal to an event invitation has been declined.", link=True) def publish(self): diff -r c9ec64bc5f79 -r 1a3b529fc4fd imiptools/handlers/person_outgoing.py --- a/imiptools/handlers/person_outgoing.py Mon Oct 05 17:19:54 2015 +0200 +++ b/imiptools/handlers/person_outgoing.py Mon Oct 05 17:20:30 2015 +0200 @@ -205,6 +205,20 @@ return True + def _declinecounter(self): + + "Remove any counter-proposals for the given event." + + if not Client.is_participating(self): + return False + + # Check for event using UID. + + if not self.have_new_object(): + return False + + self.store.dequeue_request(self.user, self.uid, self.recurrenceid) + class Event(PersonHandler): "An event handler." @@ -229,9 +243,9 @@ def declinecounter(self): - "Declined counter-proposals are advisory and do not change events." + "Expire any offer made by a counter-proposal." - pass + self._declinecounter() def publish(self): diff -r c9ec64bc5f79 -r 1a3b529fc4fd tests/test_person_invitation_counter.sh --- a/tests/test_person_invitation_counter.sh Mon Oct 05 17:19:54 2015 +0200 +++ b/tests/test_person_invitation_counter.sh Mon Oct 05 17:20:30 2015 +0200 @@ -120,3 +120,73 @@ grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \ && echo "Success" \ || echo "Failed" + +# Present the response to the organiser. + + "$PERSON_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR \ +| tee out3r.tmp \ +| "$SHOWMAIL" \ +> out3.tmp + + ! [ -e "$FBSENDEROTHERFILE" ] \ +|| ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDEROTHERFILE" \ + && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBSENDEROTHERFILE" ) \ +&& echo "Success" \ +|| echo "Failed" + + grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' "$STORE/$SENDER/objects/event6@example.com" \ +&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' "$STORE/$SENDER/objects/event6@example.com" \ +&& echo "Success" \ +|| echo "Failed" + + grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' "$STORE/$SENDER/counters/objects/event6@example.com/$USER" \ +&& echo "Success" \ +|| echo "Failed" + + grep -q 'event6@example.com' "$FBSENDERREQUESTS" \ +&& echo "Success" \ +|| echo "Failed" + +# Check the free/busy state of the recipient so far. + + "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ +| "$SHOWMAIL" \ +> out4.tmp + + grep -q 'METHOD:REPLY' out4.tmp \ +&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T160000Z' out4.tmp \ +&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T160000Z/20141126T170000Z' out4.tmp \ +&& echo "Success" \ +|| echo "Failed" + +# Decline the counter-proposal. + + sed 's/COUNTER/DECLINECOUNTER/' < out2.tmp \ +| sed 's/^From: calendar/To: vincent.vole/' \ +| sed 's/^To: paul.boddie/From: paul.boddie/' \ +> out5.tmp + +"$OUTGOING_SCRIPT" $ARGS < out5.tmp 2>> $ERROR + + ! [ -e "$STORE/$SENDER/counters/objects/event6@example.com/$USER" ] \ +&& echo "Success" \ +|| echo "Failed" + + ! grep -q 'event6@example.com' "$FBSENDERREQUESTS" \ +&& echo "Success" \ +|| echo "Failed" + + "$PERSON_SCRIPT" $ARGS < out5.tmp 2>> $ERROR \ +| "$SHOWMAIL" \ +> out6.tmp + + ! [ -e "$FBFILE" ] \ +|| ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ + && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \ +&& echo "Success" \ +|| echo "Failed" + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBOFFERFILE" \ +&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \ +&& echo "Success" \ +|| echo "Failed"