1.1 --- a/imipweb/event.py Tue Oct 06 18:38:45 2015 +0200
1.2 +++ b/imipweb/event.py Tue Oct 06 18:43:29 2015 +0200
1.3 @@ -574,8 +574,9 @@
1.4
1.5 if first:
1.6 page.td(rowspan=len(periods))
1.7 + self.control("accept-%d" % i, "submit", "Accept")
1.8 self.control("decline-%d" % i, "submit", "Decline")
1.9 - self.control("decline", "hidden", attendee)
1.10 + self.control("counter", "hidden", attendee)
1.11 page.td.close()
1.12
1.13 page.tr.close()
1.14 @@ -714,9 +715,10 @@
1.15 cancel = args.has_key("cancel")
1.16 ignore = args.has_key("ignore")
1.17 save = args.has_key("save")
1.18 - decline = filter(None, [(arg.startswith("decline-") and arg[len("decline-"):]) for arg in args.keys()])
1.19 + accept = self.prefixed_args("accept-", int)
1.20 + decline = self.prefixed_args("decline-", int)
1.21
1.22 - have_action = reply or discard or create or cancel or ignore or save or decline
1.23 + have_action = reply or discard or create or cancel or ignore or save or accept or decline
1.24
1.25 if not have_action:
1.26 return ["action"]
1.27 @@ -787,7 +789,7 @@
1.28 # Process the object and remove it from the list of requests.
1.29
1.30 if reply and self.process_received_request():
1.31 - self.remove_request(self.uid, self.recurrenceid)
1.32 + self.remove_request()
1.33
1.34 elif self.is_organiser() and (invite or cancel):
1.35
1.36 @@ -796,39 +798,53 @@
1.37 if self.process_created_request(
1.38 invite and "REQUEST" or "CANCEL", to_cancel, to_unschedule):
1.39
1.40 - self.remove_request(self.uid, self.recurrenceid)
1.41 + self.remove_request()
1.42
1.43 # Save single user events.
1.44
1.45 elif save:
1.46 self.store.set_event(self.user, self.uid, self.recurrenceid, node=self.obj.to_node())
1.47 self.update_event_in_freebusy()
1.48 - self.remove_request(self.uid, self.recurrenceid)
1.49 + self.remove_request()
1.50
1.51 # Remove the request and the object.
1.52
1.53 elif discard:
1.54 self.remove_event_from_freebusy()
1.55 - self.remove_event(self.uid, self.recurrenceid)
1.56 - self.remove_request(self.uid, self.recurrenceid)
1.57 + self.remove_event()
1.58 + self.remove_request()
1.59 +
1.60 + # Update counter-proposal records synchronously instead of assuming
1.61 + # that the outgoing handler will have done so before the form is
1.62 + # refreshed.
1.63 +
1.64 + # Accept a counter-proposal and decline all others, sending a new
1.65 + # request to all attendees.
1.66 +
1.67 + elif accept:
1.68
1.69 - # Decline a counter-proposal.
1.70 + # Take the first accepted proposal, although there should be only
1.71 + # one anyway.
1.72 +
1.73 + for i in accept:
1.74 + attendee_uri = get_uri(args.get("counter", [])[i])
1.75 + obj = self.get_stored_object(self.uid, self.recurrenceid, "counters", attendee_uri)
1.76 + self.obj.set_periods(self.get_periods(obj))
1.77 + break
1.78 +
1.79 + # Remove counter-proposals and issue a new invitation.
1.80 +
1.81 + attendees = uri_values(args.get("counter", []))
1.82 + self.remove_counters(attendees)
1.83 + self.process_created_request("REQUEST")
1.84 +
1.85 + # Decline a counter-proposal individually.
1.86
1.87 elif decline:
1.88 - for s in decline:
1.89 - try:
1.90 - i = int(s)
1.91 - except (IndexError, ValueError):
1.92 - pass
1.93 - else:
1.94 - attendee_uri = get_uri(args.get("decline", [])[i])
1.95 - self.process_declined_counter(attendee_uri)
1.96 -
1.97 - # Update the counter-proposals synchronously instead of
1.98 - # assuming that the outgoing handler will have done so
1.99 - # before the form is refreshed.
1.100 -
1.101 - self.remove_counter(attendee_uri)
1.102 + for i in decline:
1.103 + attendee_uri = get_uri(args.get("counter", [])[i])
1.104 + self.process_declined_counter(attendee_uri)
1.105 + self.remove_counter(attendee_uri)
1.106
1.107 # Redirect to the event.
1.108
1.109 @@ -870,7 +886,7 @@
1.110 start = self.get_date_control_values("dtstart")
1.111 end = self.get_date_control_values("dtend")
1.112
1.113 - period = FormPeriod(start, end, dtend_enabled, dttimes_enabled, self.get_tzid())
1.114 + period = FormPeriod(start, end, dtend_enabled, dttimes_enabled, self.get_tzid(), "DTSTART")
1.115
1.116 # Handle absent main period details.
1.117