1.1 --- a/imiptools/stores/common.py Thu Oct 12 23:14:06 2017 +0200
1.2 +++ b/imiptools/stores/common.py Sat Oct 14 16:42:09 2017 +0200
1.3 @@ -512,11 +512,12 @@
1.4
1.5 pass
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 'attendee' is specified, only objects
1.14 + provided by this attendee will be removed.
1.15 """
1.16
1.17 pass
2.1 --- a/imiptools/stores/database/common.py Thu Oct 12 23:14:06 2017 +0200
2.2 +++ b/imiptools/stores/database/common.py Sat Oct 14 16:42:09 2017 +0200
2.3 @@ -735,11 +735,12 @@
2.4 self.cursor.execute(query, values)
2.5 return True
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 table = self.get_event_table(recurrenceid, "counters")
2.18 @@ -751,6 +752,10 @@
2.19 columns = ["store_user", "object_uid"]
2.20 values = [user, uid]
2.21
2.22 + if attendee:
2.23 + columns.append("other")
2.24 + values.append(attendee)
2.25 +
2.26 query, values = self.get_query(
2.27 "delete from %(table)s :condition" % {
2.28 "table" : table
3.1 --- a/imiptools/stores/file.py Thu Oct 12 23:14:06 2017 +0200
3.2 +++ b/imiptools/stores/file.py Sat Oct 14 16:42:09 2017 +0200
3.3 @@ -608,11 +608,27 @@
3.4
3.5 return self._set_object(user, filename, node)
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 a parent event is specified, all
3.14 + recurrence counter-proposals will be removed. If 'attendee' is
3.15 + specified, only objects provided by this attendee will be removed.
3.16 + """
3.17 +
3.18 + self._remove_counters(user, uid, recurrenceid, attendee)
3.19 +
3.20 + if not recurrenceid:
3.21 + for recurrenceid in self.get_counter_recurrences(user, uid):
3.22 + self._remove_counters(user, uid, recurrenceid, attendee)
3.23 +
3.24 + def _remove_counters(self, user, uid, recurrenceid=None, attendee=None):
3.25 +
3.26 + """
3.27 + For the given 'user', remove all counter-proposals associated with the
3.28 + given 'uid' and 'recurrenceid'. If 'attendee' is specified, only objects
3.29 + provided by this attendee will be removed.
3.30 """
3.31
3.32 filename = self.get_event_filename(user, uid, recurrenceid, "counters")
3.33 @@ -622,8 +638,12 @@
3.34 removed = False
3.35
3.36 for other in listdir(filename):
3.37 - counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other)
3.38 - removed = removed or self._remove_object(counter_filename)
3.39 + if not attendee or other == attendee:
3.40 + counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other)
3.41 + removed = removed or self._remove_object(counter_filename)
3.42 +
3.43 + if not listdir(filename):
3.44 + self._remove_collection(filename)
3.45
3.46 return removed
3.47