1.1 --- a/imiptools/stores/file.py Thu Oct 12 23:14:06 2017 +0200
1.2 +++ b/imiptools/stores/file.py Sat Oct 14 16:42:09 2017 +0200
1.3 @@ -608,11 +608,27 @@
1.4
1.5 return self._set_object(user, filename, node)
1.6
1.7 - def remove_counters(self, user, uid, recurrenceid=None):
1.8 + def remove_counters(self, user, uid, recurrenceid=None, attendee=None):
1.9
1.10 """
1.11 For the given 'user', remove all counter-proposals associated with the
1.12 - given 'uid' and 'recurrenceid'.
1.13 + given 'uid' and 'recurrenceid'. If a parent event is specified, all
1.14 + recurrence counter-proposals will be removed. If 'attendee' is
1.15 + specified, only objects provided by this attendee will be removed.
1.16 + """
1.17 +
1.18 + self._remove_counters(user, uid, recurrenceid, attendee)
1.19 +
1.20 + if not recurrenceid:
1.21 + for recurrenceid in self.get_counter_recurrences(user, uid):
1.22 + self._remove_counters(user, uid, recurrenceid, attendee)
1.23 +
1.24 + def _remove_counters(self, user, uid, recurrenceid=None, attendee=None):
1.25 +
1.26 + """
1.27 + For the given 'user', remove all counter-proposals associated with the
1.28 + given 'uid' and 'recurrenceid'. If 'attendee' is specified, only objects
1.29 + provided by this attendee will be removed.
1.30 """
1.31
1.32 filename = self.get_event_filename(user, uid, recurrenceid, "counters")
1.33 @@ -622,8 +638,12 @@
1.34 removed = False
1.35
1.36 for other in listdir(filename):
1.37 - counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other)
1.38 - removed = removed or self._remove_object(counter_filename)
1.39 + if not attendee or other == attendee:
1.40 + counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other)
1.41 + removed = removed or self._remove_object(counter_filename)
1.42 +
1.43 + if not listdir(filename):
1.44 + self._remove_collection(filename)
1.45
1.46 return removed
1.47