1.1 --- a/imiptools/handlers/person.py Fri Oct 13 16:17:20 2017 +0200
1.2 +++ b/imiptools/handlers/person.py Sat Oct 14 16:44:49 2017 +0200
1.3 @@ -93,6 +93,11 @@
1.4
1.5 self.merge_attendance({attendee : attendees[attendee]})
1.6
1.7 + # Remove any previous counter-proposals for the event from the attendee.
1.8 + # If a parent event is involved, remove all proposed recurrences.
1.9 +
1.10 + self.store.remove_counters(self.user, self.uid, self.recurrenceid, attendee)
1.11 +
1.12 # Queue any counter-proposal for perusal.
1.13
1.14 self.store.set_counter(self.user, attendee, self.obj.to_node(), self.uid, self.recurrenceid)
2.1 --- a/imiptools/stores/common.py Fri Oct 13 16:17:20 2017 +0200
2.2 +++ b/imiptools/stores/common.py Sat Oct 14 16:44:49 2017 +0200
2.3 @@ -512,11 +512,12 @@
2.4
2.5 pass
2.6
2.7 - def remove_counters(self, user, uid, recurrenceid=None):
2.8 + def remove_counters(self, user, uid, recurrenceid=None, attendee=None):
2.9
2.10 """
2.11 For the given 'user', remove all counter-proposals associated with the
2.12 - given 'uid' and 'recurrenceid'.
2.13 + given 'uid' and 'recurrenceid'. If 'attendee' is specified, only objects
2.14 + provided by this attendee will be removed.
2.15 """
2.16
2.17 pass
3.1 --- a/imiptools/stores/database/common.py Fri Oct 13 16:17:20 2017 +0200
3.2 +++ b/imiptools/stores/database/common.py Sat Oct 14 16:44:49 2017 +0200
3.3 @@ -735,11 +735,12 @@
3.4 self.cursor.execute(query, values)
3.5 return True
3.6
3.7 - def remove_counters(self, user, uid, recurrenceid=None):
3.8 + def remove_counters(self, user, uid, recurrenceid=None, attendee=None):
3.9
3.10 """
3.11 For the given 'user', remove all counter-proposals associated with the
3.12 - given 'uid' and 'recurrenceid'.
3.13 + given 'uid' and 'recurrenceid'. If 'attendee' is specified, only objects
3.14 + provided by this attendee will be removed.
3.15 """
3.16
3.17 table = self.get_event_table(recurrenceid, "counters")
3.18 @@ -751,6 +752,10 @@
3.19 columns = ["store_user", "object_uid"]
3.20 values = [user, uid]
3.21
3.22 + if attendee:
3.23 + columns.append("other")
3.24 + values.append(attendee)
3.25 +
3.26 query, values = self.get_query(
3.27 "delete from %(table)s :condition" % {
3.28 "table" : table
4.1 --- a/imiptools/stores/file.py Fri Oct 13 16:17:20 2017 +0200
4.2 +++ b/imiptools/stores/file.py Sat Oct 14 16:44:49 2017 +0200
4.3 @@ -608,11 +608,27 @@
4.4
4.5 return self._set_object(user, filename, node)
4.6
4.7 - def remove_counters(self, user, uid, recurrenceid=None):
4.8 + def remove_counters(self, user, uid, recurrenceid=None, attendee=None):
4.9
4.10 """
4.11 For the given 'user', remove all counter-proposals associated with the
4.12 - given 'uid' and 'recurrenceid'.
4.13 + given 'uid' and 'recurrenceid'. If a parent event is specified, all
4.14 + recurrence counter-proposals will be removed. If 'attendee' is
4.15 + specified, only objects provided by this attendee will be removed.
4.16 + """
4.17 +
4.18 + self._remove_counters(user, uid, recurrenceid, attendee)
4.19 +
4.20 + if not recurrenceid:
4.21 + for recurrenceid in self.get_counter_recurrences(user, uid):
4.22 + self._remove_counters(user, uid, recurrenceid, attendee)
4.23 +
4.24 + def _remove_counters(self, user, uid, recurrenceid=None, attendee=None):
4.25 +
4.26 + """
4.27 + For the given 'user', remove all counter-proposals associated with the
4.28 + given 'uid' and 'recurrenceid'. If 'attendee' is specified, only objects
4.29 + provided by this attendee will be removed.
4.30 """
4.31
4.32 filename = self.get_event_filename(user, uid, recurrenceid, "counters")
4.33 @@ -622,8 +638,12 @@
4.34 removed = False
4.35
4.36 for other in listdir(filename):
4.37 - counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other)
4.38 - removed = removed or self._remove_object(counter_filename)
4.39 + if not attendee or other == attendee:
4.40 + counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other)
4.41 + removed = removed or self._remove_object(counter_filename)
4.42 +
4.43 + if not listdir(filename):
4.44 + self._remove_collection(filename)
4.45
4.46 return removed
4.47