1.1 --- a/imipweb/event.py Mon Sep 28 23:12:58 2015 +0200
1.2 +++ b/imipweb/event.py Mon Sep 28 23:22:54 2015 +0200
1.3 @@ -191,7 +191,7 @@
1.4
1.5 # Obtain basic event information, generating any necessary editing controls.
1.6
1.7 - attendees = self.update_current_attendees()
1.8 + attendees = self.get_current_attendees()
1.9 period = self.get_current_main_period()
1.10 self.show_object_datetime_controls(period)
1.11
1.12 @@ -409,7 +409,7 @@
1.13 # Obtain the periods associated with the event.
1.14 # NOTE: Add a control to add recurrences here.
1.15
1.16 - recurrences = self.update_current_recurrences()
1.17 + recurrences = self.get_current_recurrences()
1.18
1.19 if len(recurrences) < 1:
1.20 return
1.21 @@ -590,8 +590,10 @@
1.22 for participant in self.get_current_attendees():
1.23 if participant == self.user:
1.24 freebusy = self.store.get_freebusy(participant)
1.25 + elif participant:
1.26 + freebusy = self.store.get_freebusy_for_other(self.user, participant)
1.27 else:
1.28 - freebusy = self.store.get_freebusy_for_other(self.user, participant)
1.29 + continue
1.30
1.31 if not freebusy:
1.32 continue
1.33 @@ -866,6 +868,32 @@
1.34
1.35 return periods
1.36
1.37 + def set_recurrences_in_page(self, recurrences):
1.38 +
1.39 + "Set the recurrences defined in the event form."
1.40 +
1.41 + args = self.env.get_args()
1.42 +
1.43 + args["dtend-control-recur"] = []
1.44 + args["dttimes-control-recur"] = []
1.45 + args["recur-origin"] = []
1.46 +
1.47 + all_starts = []
1.48 + all_ends = []
1.49 +
1.50 + for index, period in enumerate(recurrences):
1.51 + if period.end_enabled:
1.52 + args["dtend-control-recur"].append(str(index))
1.53 + if period.times_enabled:
1.54 + args["dttimes-control-recur"].append(str(index))
1.55 + args["recur-origin"].append(period.origin or "")
1.56 +
1.57 + all_starts.append(period.get_form_start())
1.58 + all_ends.append(period.get_form_end())
1.59 +
1.60 + self.set_date_control_values("dtstart-recur", all_starts)
1.61 + self.set_date_control_values("dtend-recur", all_ends, tzid_name="dtstart-recur")
1.62 +
1.63 def get_removed_periods(self, periods):
1.64
1.65 """
1.66 @@ -894,25 +922,18 @@
1.67 def get_attendees_from_page(self):
1.68
1.69 """
1.70 - Return attendees from the request, normalised for iCalendar purposes,
1.71 - and without duplicates.
1.72 + Return attendees from the request, normalised for iCalendar purposes.
1.73 """
1.74
1.75 args = self.env.get_args()
1.76 -
1.77 - attendees = args.get("attendee", [])
1.78 - unique_attendees = set()
1.79 - ordered_attendees = []
1.80 + attendees = []
1.81
1.82 - for attendee in attendees:
1.83 - if not attendee.strip():
1.84 - continue
1.85 - attendee = get_uri(attendee)
1.86 - if attendee not in unique_attendees:
1.87 - unique_attendees.add(attendee)
1.88 - ordered_attendees.append(attendee)
1.89 + for attendee in args.get("attendee", []):
1.90 + if attendee.strip():
1.91 + attendee = get_uri(attendee)
1.92 + attendees.append(attendee)
1.93
1.94 - return ordered_attendees
1.95 + return attendees
1.96
1.97 def update_attendees_from_page(self):
1.98
1.99 @@ -944,6 +965,7 @@
1.100
1.101 args["remove"] = still_to_remove
1.102
1.103 + args["attendee"] = attendees
1.104 return attendees
1.105
1.106 def update_recurrences_from_page(self):
1.107 @@ -975,6 +997,7 @@
1.108
1.109 args["recur-remove"] = still_to_remove
1.110
1.111 + self.set_recurrences_in_page(recurrences)
1.112 return recurrences
1.113
1.114 # Access to current object information.
1.115 @@ -1052,6 +1075,9 @@
1.116 if not errors:
1.117 return True
1.118
1.119 + self.update_current_attendees()
1.120 + self.update_current_recurrences()
1.121 +
1.122 self.new_page(title="Event")
1.123 self.show_object_on_page(errors)
1.124
2.1 --- a/imipweb/resource.py Mon Sep 28 23:12:58 2015 +0200
2.2 +++ b/imipweb/resource.py Mon Sep 28 23:22:54 2015 +0200
2.3 @@ -548,11 +548,12 @@
2.4 def get_date_control_values(self, name, multiple=False, tzid_name=None):
2.5
2.6 """
2.7 - Return a dictionary containing date, time and tzid entries for fields
2.8 - starting with 'name'. If 'multiple' is set to a true value, many
2.9 - dictionaries will be returned corresponding to a collection of
2.10 - datetimes. If 'tzid_name' is specified, the time zone information will
2.11 - be acquired from a field starting with 'tzid_name' instead of 'name'.
2.12 + Return a form date object representing fields starting with 'name'. If
2.13 + 'multiple' is set to a true value, many date objects will be returned
2.14 + corresponding to a collection of datetimes.
2.15 +
2.16 + If 'tzid_name' is specified, the time zone information will be acquired
2.17 + from fields starting with 'tzid_name' instead of 'name'.
2.18 """
2.19
2.20 args = self.env.get_args()
2.21 @@ -583,4 +584,22 @@
2.22
2.23 return all_values
2.24
2.25 + def set_date_control_values(self, name, formdates, tzid_name=None):
2.26 +
2.27 + """
2.28 + Replace form fields starting with 'name' using the values of the given
2.29 + 'formdates'.
2.30 +
2.31 + If 'tzid_name' is specified, the time zone information will be stored in
2.32 + fields starting with 'tzid_name' instead of 'name'.
2.33 + """
2.34 +
2.35 + args = self.env.get_args()
2.36 +
2.37 + args["%s-date" % name] = [d.date for d in formdates]
2.38 + args["%s-hour" % name] = [d.hour for d in formdates]
2.39 + args["%s-minute" % name] = [d.minute for d in formdates]
2.40 + args["%s-second" % name] = [d.second for d in formdates]
2.41 + args["%s-tzid" % (tzid_name or name)] = [d.tzid for d in formdates]
2.42 +
2.43 # vim: tabstop=4 expandtab shiftwidth=4