# HG changeset patch # User Paul Boddie # Date 1507992129 -7200 # Node ID b4254eda0708d3a191b57015267d1d0663f70a74 # Parent a2708b0945c855f0fd8695b4e97157b41bcbe0d7 Changed file store code to remove all recurrence counter-proposals when the recurrence identifier is omitted, also introducing the restriction of removed proposals to individual attendees. diff -r a2708b0945c8 -r b4254eda0708 imiptools/stores/common.py --- a/imiptools/stores/common.py Thu Oct 12 23:14:06 2017 +0200 +++ b/imiptools/stores/common.py Sat Oct 14 16:42:09 2017 +0200 @@ -512,11 +512,12 @@ pass - def remove_counters(self, user, uid, recurrenceid=None): + def remove_counters(self, user, uid, recurrenceid=None, attendee=None): """ For the given 'user', remove all counter-proposals associated with the - given 'uid' and 'recurrenceid'. + given 'uid' and 'recurrenceid'. If 'attendee' is specified, only objects + provided by this attendee will be removed. """ pass diff -r a2708b0945c8 -r b4254eda0708 imiptools/stores/database/common.py --- a/imiptools/stores/database/common.py Thu Oct 12 23:14:06 2017 +0200 +++ b/imiptools/stores/database/common.py Sat Oct 14 16:42:09 2017 +0200 @@ -735,11 +735,12 @@ self.cursor.execute(query, values) return True - def remove_counters(self, user, uid, recurrenceid=None): + def remove_counters(self, user, uid, recurrenceid=None, attendee=None): """ For the given 'user', remove all counter-proposals associated with the - given 'uid' and 'recurrenceid'. + given 'uid' and 'recurrenceid'. If 'attendee' is specified, only objects + provided by this attendee will be removed. """ table = self.get_event_table(recurrenceid, "counters") @@ -751,6 +752,10 @@ columns = ["store_user", "object_uid"] values = [user, uid] + if attendee: + columns.append("other") + values.append(attendee) + query, values = self.get_query( "delete from %(table)s :condition" % { "table" : table diff -r a2708b0945c8 -r b4254eda0708 imiptools/stores/file.py --- a/imiptools/stores/file.py Thu Oct 12 23:14:06 2017 +0200 +++ b/imiptools/stores/file.py Sat Oct 14 16:42:09 2017 +0200 @@ -608,11 +608,27 @@ return self._set_object(user, filename, node) - def remove_counters(self, user, uid, recurrenceid=None): + def remove_counters(self, user, uid, recurrenceid=None, attendee=None): """ For the given 'user', remove all counter-proposals associated with the - given 'uid' and 'recurrenceid'. + given 'uid' and 'recurrenceid'. If a parent event is specified, all + recurrence counter-proposals will be removed. If 'attendee' is + specified, only objects provided by this attendee will be removed. + """ + + self._remove_counters(user, uid, recurrenceid, attendee) + + if not recurrenceid: + for recurrenceid in self.get_counter_recurrences(user, uid): + self._remove_counters(user, uid, recurrenceid, attendee) + + def _remove_counters(self, user, uid, recurrenceid=None, attendee=None): + + """ + For the given 'user', remove all counter-proposals associated with the + given 'uid' and 'recurrenceid'. If 'attendee' is specified, only objects + provided by this attendee will be removed. """ filename = self.get_event_filename(user, uid, recurrenceid, "counters") @@ -622,8 +638,12 @@ removed = False for other in listdir(filename): - counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other) - removed = removed or self._remove_object(counter_filename) + if not attendee or other == attendee: + counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other) + removed = removed or self._remove_object(counter_filename) + + if not listdir(filename): + self._remove_collection(filename) return removed