# HG changeset patch # User Paul Boddie # Date 1507842846 -7200 # Node ID a2708b0945c855f0fd8695b4e97157b41bcbe0d7 # Parent b139a6f7662b95a7388a7df5d07d53cf8085c961 Added methods to obtain recurrence counter-proposal identifiers. diff -r b139a6f7662b -r a2708b0945c8 imiptools/stores/common.py --- a/imiptools/stores/common.py Sat Oct 07 22:08:13 2017 +0200 +++ b/imiptools/stores/common.py Thu Oct 12 23:14:06 2017 +0200 @@ -3,7 +3,7 @@ """ General support for calendar data storage. -Copyright (C) 2014, 2015, 2016 Paul Boddie +Copyright (C) 2014, 2015, 2016, 2017 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -484,6 +484,15 @@ pass + def get_counter_recurrences(self, user, uid): + + """ + For the given 'user', return a list of recurrence identifiers describing + counter-proposals for the parent event with the given 'uid'. + """ + + pass + def get_counter(self, user, other, uid, recurrenceid=None): """ diff -r b139a6f7662b -r a2708b0945c8 imiptools/stores/database/common.py --- a/imiptools/stores/database/common.py Sat Oct 07 22:08:13 2017 +0200 +++ b/imiptools/stores/database/common.py Thu Oct 12 23:14:06 2017 +0200 @@ -662,6 +662,27 @@ self.cursor.execute(query, values) return self.get_single_values() + def get_counter_recurrences(self, user, uid): + + """ + For the given 'user', return a list of recurrence identifiers describing + counter-proposals for the parent event with the given 'uid'. + """ + + table = self.get_recurrence_table("counters") + + columns = ["store_user", "object_uid"] + values = [user, uid] + + query, values = self.get_query( + "select object_recurrenceid from %(table)s :condition" % { + "table" : table + }, + columns, values) + + self.cursor.execute(query, values) + return self.get_single_values() + def get_counter(self, user, other, uid, recurrenceid=None): """ diff -r b139a6f7662b -r a2708b0945c8 imiptools/stores/file.py --- a/imiptools/stores/file.py Sat Oct 07 22:08:13 2017 +0200 +++ b/imiptools/stores/file.py Thu Oct 12 23:14:06 2017 +0200 @@ -568,6 +568,19 @@ return [name for name in listdir(filename) if isfile(join(filename, name))] + def get_counter_recurrences(self, user, uid): + + """ + For the given 'user', return a list of recurrence identifiers describing + counter-proposals for the parent event with the given 'uid'. + """ + + filename = self.get_object_in_store(user, "counters", "recurrences", uid) + if not filename or not isdir(filename): + return [] + + return listdir(filename) + def get_counter(self, user, other, uid, recurrenceid=None): """