paul@1069 | 1 | #!/usr/bin/env python |
paul@1069 | 2 | |
paul@1069 | 3 | """ |
paul@1069 | 4 | General support for calendar data storage. |
paul@1069 | 5 | |
paul@1069 | 6 | Copyright (C) 2014, 2015, 2016 Paul Boddie <paul@boddie.org.uk> |
paul@1069 | 7 | |
paul@1069 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@1069 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@1069 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@1069 | 11 | version. |
paul@1069 | 12 | |
paul@1069 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@1069 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@1069 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@1069 | 16 | details. |
paul@1069 | 17 | |
paul@1069 | 18 | You should have received a copy of the GNU General Public License along with |
paul@1069 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@1069 | 20 | """ |
paul@1069 | 21 | |
paul@1075 | 22 | from imiptools.dates import format_datetime |
paul@1075 | 23 | |
paul@1069 | 24 | class StoreBase: |
paul@1069 | 25 | |
paul@1069 | 26 | "The core operations of a data store." |
paul@1069 | 27 | |
paul@1069 | 28 | def acquire_lock(self, user, timeout=None): |
paul@1069 | 29 | pass |
paul@1069 | 30 | |
paul@1069 | 31 | def release_lock(self, user): |
paul@1069 | 32 | pass |
paul@1069 | 33 | |
paul@1069 | 34 | # User discovery. |
paul@1069 | 35 | |
paul@1069 | 36 | def get_users(self): |
paul@1069 | 37 | |
paul@1069 | 38 | "Return a list of users." |
paul@1069 | 39 | |
paul@1069 | 40 | pass |
paul@1069 | 41 | |
paul@1069 | 42 | # Event and event metadata access. |
paul@1069 | 43 | |
paul@1069 | 44 | def get_events(self, user): |
paul@1069 | 45 | |
paul@1069 | 46 | "Return a list of event identifiers." |
paul@1069 | 47 | |
paul@1069 | 48 | pass |
paul@1069 | 49 | |
paul@1069 | 50 | def get_all_events(self, user): |
paul@1069 | 51 | |
paul@1069 | 52 | "Return a set of (uid, recurrenceid) tuples for all events." |
paul@1069 | 53 | |
paul@1069 | 54 | uids = self.get_events(user) |
paul@1069 | 55 | if not uids: |
paul@1069 | 56 | return set() |
paul@1069 | 57 | |
paul@1069 | 58 | all_events = set() |
paul@1069 | 59 | for uid in uids: |
paul@1069 | 60 | all_events.add((uid, None)) |
paul@1069 | 61 | all_events.update([(uid, recurrenceid) for recurrenceid in self.get_recurrences(user, uid)]) |
paul@1069 | 62 | |
paul@1069 | 63 | return all_events |
paul@1069 | 64 | |
paul@1069 | 65 | def get_event(self, user, uid, recurrenceid=None, dirname=None): |
paul@1069 | 66 | |
paul@1069 | 67 | """ |
paul@1069 | 68 | Get the event for the given 'user' with the given 'uid'. If |
paul@1069 | 69 | the optional 'recurrenceid' is specified, a specific instance or |
paul@1069 | 70 | occurrence of an event is returned. |
paul@1069 | 71 | """ |
paul@1069 | 72 | |
paul@1069 | 73 | pass |
paul@1069 | 74 | |
paul@1069 | 75 | def get_complete_event(self, user, uid): |
paul@1069 | 76 | |
paul@1069 | 77 | "Get the event for the given 'user' with the given 'uid'." |
paul@1069 | 78 | |
paul@1069 | 79 | pass |
paul@1069 | 80 | |
paul@1069 | 81 | def set_event(self, user, uid, recurrenceid, node): |
paul@1069 | 82 | |
paul@1069 | 83 | """ |
paul@1069 | 84 | Set an event for 'user' having the given 'uid' and 'recurrenceid' (which |
paul@1069 | 85 | if the latter is specified, a specific instance or occurrence of an |
paul@1069 | 86 | event is referenced), using the given 'node' description. |
paul@1069 | 87 | """ |
paul@1069 | 88 | |
paul@1069 | 89 | if recurrenceid: |
paul@1069 | 90 | return self.set_recurrence(user, uid, recurrenceid, node) |
paul@1069 | 91 | else: |
paul@1069 | 92 | return self.set_complete_event(user, uid, node) |
paul@1069 | 93 | |
paul@1069 | 94 | def set_complete_event(self, user, uid, node): |
paul@1069 | 95 | |
paul@1069 | 96 | "Set an event for 'user' having the given 'uid' and 'node'." |
paul@1069 | 97 | |
paul@1069 | 98 | pass |
paul@1069 | 99 | |
paul@1069 | 100 | def remove_event(self, user, uid, recurrenceid=None): |
paul@1069 | 101 | |
paul@1069 | 102 | """ |
paul@1069 | 103 | Remove an event for 'user' having the given 'uid'. If the optional |
paul@1069 | 104 | 'recurrenceid' is specified, a specific instance or occurrence of an |
paul@1069 | 105 | event is removed. |
paul@1069 | 106 | """ |
paul@1069 | 107 | |
paul@1069 | 108 | if recurrenceid: |
paul@1069 | 109 | return self.remove_recurrence(user, uid, recurrenceid) |
paul@1069 | 110 | else: |
paul@1069 | 111 | for recurrenceid in self.get_recurrences(user, uid) or []: |
paul@1069 | 112 | self.remove_recurrence(user, uid, recurrenceid) |
paul@1069 | 113 | return self.remove_complete_event(user, uid) |
paul@1069 | 114 | |
paul@1069 | 115 | def remove_complete_event(self, user, uid): |
paul@1069 | 116 | |
paul@1069 | 117 | "Remove an event for 'user' having the given 'uid'." |
paul@1069 | 118 | |
paul@1069 | 119 | self.remove_recurrences(user, uid) |
paul@1069 | 120 | return self.remove_parent_event(user, uid) |
paul@1069 | 121 | |
paul@1069 | 122 | def remove_parent_event(self, user, uid): |
paul@1069 | 123 | |
paul@1069 | 124 | "Remove the parent event for 'user' having the given 'uid'." |
paul@1069 | 125 | |
paul@1069 | 126 | pass |
paul@1069 | 127 | |
paul@1069 | 128 | def get_recurrences(self, user, uid): |
paul@1069 | 129 | |
paul@1069 | 130 | """ |
paul@1069 | 131 | Get additional event instances for an event of the given 'user' with the |
paul@1069 | 132 | indicated 'uid'. Both active and cancelled recurrences are returned. |
paul@1069 | 133 | """ |
paul@1069 | 134 | |
paul@1069 | 135 | return self.get_active_recurrences(user, uid) + self.get_cancelled_recurrences(user, uid) |
paul@1069 | 136 | |
paul@1069 | 137 | def get_active_recurrences(self, user, uid): |
paul@1069 | 138 | |
paul@1069 | 139 | """ |
paul@1069 | 140 | Get additional event instances for an event of the given 'user' with the |
paul@1069 | 141 | indicated 'uid'. Cancelled recurrences are not returned. |
paul@1069 | 142 | """ |
paul@1069 | 143 | |
paul@1069 | 144 | pass |
paul@1069 | 145 | |
paul@1069 | 146 | def get_cancelled_recurrences(self, user, uid): |
paul@1069 | 147 | |
paul@1069 | 148 | """ |
paul@1069 | 149 | Get additional event instances for an event of the given 'user' with the |
paul@1069 | 150 | indicated 'uid'. Only cancelled recurrences are returned. |
paul@1069 | 151 | """ |
paul@1069 | 152 | |
paul@1069 | 153 | pass |
paul@1069 | 154 | |
paul@1069 | 155 | def get_recurrence(self, user, uid, recurrenceid): |
paul@1069 | 156 | |
paul@1069 | 157 | """ |
paul@1069 | 158 | For the event of the given 'user' with the given 'uid', return the |
paul@1069 | 159 | specific recurrence indicated by the 'recurrenceid'. |
paul@1069 | 160 | """ |
paul@1069 | 161 | |
paul@1069 | 162 | pass |
paul@1069 | 163 | |
paul@1069 | 164 | def set_recurrence(self, user, uid, recurrenceid, node): |
paul@1069 | 165 | |
paul@1069 | 166 | "Set an event for 'user' having the given 'uid' and 'node'." |
paul@1069 | 167 | |
paul@1069 | 168 | pass |
paul@1069 | 169 | |
paul@1069 | 170 | def remove_recurrence(self, user, uid, recurrenceid): |
paul@1069 | 171 | |
paul@1069 | 172 | """ |
paul@1069 | 173 | Remove a special recurrence from an event stored by 'user' having the |
paul@1069 | 174 | given 'uid' and 'recurrenceid'. |
paul@1069 | 175 | """ |
paul@1069 | 176 | |
paul@1069 | 177 | pass |
paul@1069 | 178 | |
paul@1069 | 179 | def remove_recurrences(self, user, uid): |
paul@1069 | 180 | |
paul@1069 | 181 | """ |
paul@1069 | 182 | Remove all recurrences for an event stored by 'user' having the given |
paul@1069 | 183 | 'uid'. |
paul@1069 | 184 | """ |
paul@1069 | 185 | |
paul@1069 | 186 | for recurrenceid in self.get_recurrences(user, uid): |
paul@1069 | 187 | self.remove_recurrence(user, uid, recurrenceid) |
paul@1069 | 188 | |
paul@1069 | 189 | return self.remove_recurrence_collection(user, uid) |
paul@1069 | 190 | |
paul@1069 | 191 | def remove_recurrence_collection(self, user, uid): |
paul@1069 | 192 | |
paul@1069 | 193 | """ |
paul@1069 | 194 | Remove the collection of recurrences stored by 'user' having the given |
paul@1069 | 195 | 'uid'. |
paul@1069 | 196 | """ |
paul@1069 | 197 | |
paul@1069 | 198 | pass |
paul@1069 | 199 | |
paul@1069 | 200 | # Free/busy period providers, upon extension of the free/busy records. |
paul@1069 | 201 | |
paul@1075 | 202 | def _get_freebusy_providers(self, user): |
paul@1075 | 203 | |
paul@1075 | 204 | """ |
paul@1075 | 205 | Return the free/busy providers for the given 'user'. |
paul@1075 | 206 | |
paul@1075 | 207 | This function returns any stored datetime and a list of providers as a |
paul@1075 | 208 | 2-tuple. Each provider is itself a (uid, recurrenceid) tuple. |
paul@1075 | 209 | """ |
paul@1075 | 210 | |
paul@1075 | 211 | pass |
paul@1075 | 212 | |
paul@1069 | 213 | def get_freebusy_providers(self, user, dt=None): |
paul@1069 | 214 | |
paul@1069 | 215 | """ |
paul@1069 | 216 | Return a set of uncancelled events of the form (uid, recurrenceid) |
paul@1069 | 217 | providing free/busy details beyond the given datetime 'dt'. |
paul@1069 | 218 | |
paul@1069 | 219 | If 'dt' is not specified, all events previously found to provide |
paul@1069 | 220 | details will be returned. Otherwise, if 'dt' is earlier than the |
paul@1069 | 221 | datetime recorded for the known providers, None is returned, indicating |
paul@1069 | 222 | that the list of providers must be recomputed. |
paul@1069 | 223 | |
paul@1069 | 224 | This function returns a list of (uid, recurrenceid) tuples upon success. |
paul@1069 | 225 | """ |
paul@1069 | 226 | |
paul@1075 | 227 | t = self._get_freebusy_providers(user) |
paul@1075 | 228 | if not t: |
paul@1075 | 229 | return None |
paul@1075 | 230 | |
paul@1075 | 231 | dt_string, t = t |
paul@1075 | 232 | |
paul@1075 | 233 | # If the requested datetime is earlier than the stated datetime, the |
paul@1075 | 234 | # providers will need to be recomputed. |
paul@1075 | 235 | |
paul@1075 | 236 | if dt: |
paul@1075 | 237 | providers_dt = get_datetime(dt_string) |
paul@1075 | 238 | if not providers_dt or providers_dt > dt: |
paul@1075 | 239 | return None |
paul@1075 | 240 | |
paul@1075 | 241 | # Otherwise, return the providers. |
paul@1075 | 242 | |
paul@1075 | 243 | return t[1:] |
paul@1075 | 244 | |
paul@1075 | 245 | def _set_freebusy_providers(self, user, dt_string, t): |
paul@1075 | 246 | |
paul@1075 | 247 | "Set the given provider timestamp 'dt_string' and table 't'." |
paul@1075 | 248 | |
paul@1069 | 249 | pass |
paul@1069 | 250 | |
paul@1069 | 251 | def set_freebusy_providers(self, user, dt, providers): |
paul@1069 | 252 | |
paul@1069 | 253 | """ |
paul@1069 | 254 | Define the uncancelled events providing free/busy details beyond the |
paul@1069 | 255 | given datetime 'dt'. |
paul@1069 | 256 | """ |
paul@1069 | 257 | |
paul@1075 | 258 | t = [] |
paul@1075 | 259 | |
paul@1075 | 260 | for obj in providers: |
paul@1075 | 261 | t.append((obj.get_uid(), obj.get_recurrenceid())) |
paul@1075 | 262 | |
paul@1075 | 263 | return self._set_freebusy_providers(user, format_datetime(dt), t) |
paul@1069 | 264 | |
paul@1069 | 265 | def append_freebusy_provider(self, user, provider): |
paul@1069 | 266 | |
paul@1069 | 267 | "For the given 'user', append the free/busy 'provider'." |
paul@1069 | 268 | |
paul@1075 | 269 | t = self._get_freebusy_providers(user) |
paul@1075 | 270 | if not t: |
paul@1075 | 271 | return False |
paul@1075 | 272 | |
paul@1075 | 273 | dt_string, t = t |
paul@1075 | 274 | t.append((provider.get_uid(), provider.get_recurrenceid())) |
paul@1075 | 275 | |
paul@1075 | 276 | return self._set_freebusy_providers(user, dt_string, t) |
paul@1069 | 277 | |
paul@1069 | 278 | def remove_freebusy_provider(self, user, provider): |
paul@1069 | 279 | |
paul@1069 | 280 | "For the given 'user', remove the free/busy 'provider'." |
paul@1069 | 281 | |
paul@1075 | 282 | t = self._get_freebusy_providers(user) |
paul@1075 | 283 | if not t: |
paul@1075 | 284 | return False |
paul@1075 | 285 | |
paul@1075 | 286 | dt_string, t = t |
paul@1075 | 287 | try: |
paul@1075 | 288 | t.remove((provider.get_uid(), provider.get_recurrenceid())) |
paul@1075 | 289 | except ValueError: |
paul@1075 | 290 | return False |
paul@1075 | 291 | |
paul@1075 | 292 | return self._set_freebusy_providers(user, dt_string, t) |
paul@1069 | 293 | |
paul@1069 | 294 | # Free/busy period access. |
paul@1069 | 295 | |
paul@1069 | 296 | def get_freebusy(self, user, name=None): |
paul@1069 | 297 | |
paul@1069 | 298 | "Get free/busy details for the given 'user'." |
paul@1069 | 299 | |
paul@1069 | 300 | pass |
paul@1069 | 301 | |
paul@1069 | 302 | def get_freebusy_for_other(self, user, other): |
paul@1069 | 303 | |
paul@1069 | 304 | "For the given 'user', get free/busy details for the 'other' user." |
paul@1069 | 305 | |
paul@1069 | 306 | pass |
paul@1069 | 307 | |
paul@1069 | 308 | def set_freebusy(self, user, freebusy, name=None): |
paul@1069 | 309 | |
paul@1069 | 310 | "For the given 'user', set 'freebusy' details." |
paul@1069 | 311 | |
paul@1069 | 312 | pass |
paul@1069 | 313 | |
paul@1069 | 314 | def set_freebusy_for_other(self, user, freebusy, other): |
paul@1069 | 315 | |
paul@1069 | 316 | "For the given 'user', set 'freebusy' details for the 'other' user." |
paul@1069 | 317 | |
paul@1069 | 318 | pass |
paul@1069 | 319 | |
paul@1069 | 320 | # Tentative free/busy periods related to countering. |
paul@1069 | 321 | |
paul@1069 | 322 | def get_freebusy_offers(self, user): |
paul@1069 | 323 | |
paul@1069 | 324 | "Get free/busy offers for the given 'user'." |
paul@1069 | 325 | |
paul@1069 | 326 | pass |
paul@1069 | 327 | |
paul@1069 | 328 | def set_freebusy_offers(self, user, freebusy): |
paul@1069 | 329 | |
paul@1069 | 330 | "For the given 'user', set 'freebusy' offers." |
paul@1069 | 331 | |
paul@1069 | 332 | return self.set_freebusy(user, freebusy, "freebusy-offers") |
paul@1069 | 333 | |
paul@1069 | 334 | # Requests and counter-proposals. |
paul@1069 | 335 | |
paul@1069 | 336 | def get_requests(self, user): |
paul@1069 | 337 | |
paul@1069 | 338 | "Get requests for the given 'user'." |
paul@1069 | 339 | |
paul@1069 | 340 | pass |
paul@1069 | 341 | |
paul@1069 | 342 | def set_requests(self, user, requests): |
paul@1069 | 343 | |
paul@1069 | 344 | "For the given 'user', set the list of queued 'requests'." |
paul@1069 | 345 | |
paul@1069 | 346 | pass |
paul@1069 | 347 | |
paul@1069 | 348 | def set_request(self, user, uid, recurrenceid=None, type=None): |
paul@1069 | 349 | |
paul@1069 | 350 | """ |
paul@1069 | 351 | For the given 'user', set the queued 'uid' and 'recurrenceid', |
paul@1069 | 352 | indicating a request, along with any given 'type'. |
paul@1069 | 353 | """ |
paul@1069 | 354 | |
paul@1069 | 355 | pass |
paul@1069 | 356 | |
paul@1069 | 357 | def queue_request(self, user, uid, recurrenceid=None, type=None): |
paul@1069 | 358 | |
paul@1069 | 359 | """ |
paul@1069 | 360 | Queue a request for 'user' having the given 'uid'. If the optional |
paul@1069 | 361 | 'recurrenceid' is specified, the entry refers to a specific instance |
paul@1069 | 362 | or occurrence of an event. The 'type' parameter can be used to indicate |
paul@1069 | 363 | a specific type of request. |
paul@1069 | 364 | """ |
paul@1069 | 365 | |
paul@1069 | 366 | requests = self.get_requests(user) or [] |
paul@1069 | 367 | |
paul@1069 | 368 | if not self.have_request(requests, uid, recurrenceid): |
paul@1069 | 369 | return self.set_request(user, uid, recurrenceid, type) |
paul@1069 | 370 | |
paul@1069 | 371 | return False |
paul@1069 | 372 | |
paul@1069 | 373 | def dequeue_request(self, user, uid, recurrenceid=None): |
paul@1069 | 374 | |
paul@1069 | 375 | """ |
paul@1069 | 376 | Dequeue all requests for 'user' having the given 'uid'. If the optional |
paul@1069 | 377 | 'recurrenceid' is specified, all requests for that specific instance or |
paul@1069 | 378 | occurrence of an event are dequeued. |
paul@1069 | 379 | """ |
paul@1069 | 380 | |
paul@1069 | 381 | requests = self.get_requests(user) or [] |
paul@1069 | 382 | result = [] |
paul@1069 | 383 | |
paul@1069 | 384 | for request in requests: |
paul@1069 | 385 | if request[:2] != (uid, recurrenceid): |
paul@1069 | 386 | result.append(request) |
paul@1069 | 387 | |
paul@1069 | 388 | self.set_requests(user, result) |
paul@1069 | 389 | return True |
paul@1069 | 390 | |
paul@1069 | 391 | def has_request(self, user, uid, recurrenceid=None, type=None, strict=False): |
paul@1069 | 392 | return self.have_request(self.get_requests(user) or [], uid, recurrenceid, type, strict) |
paul@1069 | 393 | |
paul@1069 | 394 | def have_request(self, requests, uid, recurrenceid=None, type=None, strict=False): |
paul@1069 | 395 | |
paul@1069 | 396 | """ |
paul@1069 | 397 | Return whether 'requests' contains a request with the given 'uid' and |
paul@1069 | 398 | any specified 'recurrenceid' and 'type'. If 'strict' is set to a true |
paul@1069 | 399 | value, the precise type of the request must match; otherwise, any type |
paul@1069 | 400 | of request for the identified object may be matched. |
paul@1069 | 401 | """ |
paul@1069 | 402 | |
paul@1069 | 403 | for request in requests: |
paul@1069 | 404 | if request[:2] == (uid, recurrenceid) and ( |
paul@1069 | 405 | not strict or |
paul@1069 | 406 | not request[2:] and not type or |
paul@1069 | 407 | request[2:] and request[2] == type): |
paul@1069 | 408 | |
paul@1069 | 409 | return True |
paul@1069 | 410 | |
paul@1069 | 411 | return False |
paul@1069 | 412 | |
paul@1069 | 413 | def get_counters(self, user, uid, recurrenceid=None): |
paul@1069 | 414 | |
paul@1069 | 415 | """ |
paul@1069 | 416 | For the given 'user', return a list of users from whom counter-proposals |
paul@1069 | 417 | have been received for the given 'uid' and optional 'recurrenceid'. |
paul@1069 | 418 | """ |
paul@1069 | 419 | |
paul@1069 | 420 | pass |
paul@1069 | 421 | |
paul@1069 | 422 | def get_counter(self, user, other, uid, recurrenceid=None): |
paul@1069 | 423 | |
paul@1069 | 424 | """ |
paul@1069 | 425 | For the given 'user', return the counter-proposal from 'other' for the |
paul@1069 | 426 | given 'uid' and optional 'recurrenceid'. |
paul@1069 | 427 | """ |
paul@1069 | 428 | |
paul@1069 | 429 | pass |
paul@1069 | 430 | |
paul@1069 | 431 | def set_counter(self, user, other, node, uid, recurrenceid=None): |
paul@1069 | 432 | |
paul@1069 | 433 | """ |
paul@1069 | 434 | For the given 'user', store a counter-proposal received from 'other' the |
paul@1069 | 435 | given 'node' representing that proposal for the given 'uid' and |
paul@1069 | 436 | 'recurrenceid'. |
paul@1069 | 437 | """ |
paul@1069 | 438 | |
paul@1069 | 439 | pass |
paul@1069 | 440 | |
paul@1069 | 441 | def remove_counters(self, user, uid, recurrenceid=None): |
paul@1069 | 442 | |
paul@1069 | 443 | """ |
paul@1069 | 444 | For the given 'user', remove all counter-proposals associated with the |
paul@1069 | 445 | given 'uid' and 'recurrenceid'. |
paul@1069 | 446 | """ |
paul@1069 | 447 | |
paul@1069 | 448 | pass |
paul@1069 | 449 | |
paul@1069 | 450 | def remove_counter(self, user, other, uid, recurrenceid=None): |
paul@1069 | 451 | |
paul@1069 | 452 | """ |
paul@1069 | 453 | For the given 'user', remove any counter-proposal from 'other' |
paul@1069 | 454 | associated with the given 'uid' and 'recurrenceid'. |
paul@1069 | 455 | """ |
paul@1069 | 456 | |
paul@1069 | 457 | pass |
paul@1069 | 458 | |
paul@1069 | 459 | # Event cancellation. |
paul@1069 | 460 | |
paul@1069 | 461 | def cancel_event(self, user, uid, recurrenceid=None): |
paul@1069 | 462 | |
paul@1069 | 463 | """ |
paul@1069 | 464 | Cancel an event for 'user' having the given 'uid'. If the optional |
paul@1069 | 465 | 'recurrenceid' is specified, a specific instance or occurrence of an |
paul@1069 | 466 | event is cancelled. |
paul@1069 | 467 | """ |
paul@1069 | 468 | |
paul@1069 | 469 | pass |
paul@1069 | 470 | |
paul@1069 | 471 | def uncancel_event(self, user, uid, recurrenceid=None): |
paul@1069 | 472 | |
paul@1069 | 473 | """ |
paul@1069 | 474 | Uncancel an event for 'user' having the given 'uid'. If the optional |
paul@1069 | 475 | 'recurrenceid' is specified, a specific instance or occurrence of an |
paul@1069 | 476 | event is uncancelled. |
paul@1069 | 477 | """ |
paul@1069 | 478 | |
paul@1069 | 479 | pass |
paul@1069 | 480 | |
paul@1069 | 481 | def remove_cancellations(self, user, uid, recurrenceid=None): |
paul@1069 | 482 | |
paul@1069 | 483 | """ |
paul@1069 | 484 | Remove cancellations for 'user' for any event having the given 'uid'. If |
paul@1069 | 485 | the optional 'recurrenceid' is specified, a specific instance or |
paul@1069 | 486 | occurrence of an event is affected. |
paul@1069 | 487 | """ |
paul@1069 | 488 | |
paul@1069 | 489 | # Remove all recurrence cancellations if a general event is indicated. |
paul@1069 | 490 | |
paul@1069 | 491 | if not recurrenceid: |
paul@1069 | 492 | for _recurrenceid in self.get_cancelled_recurrences(user, uid): |
paul@1069 | 493 | self.remove_cancellation(user, uid, _recurrenceid) |
paul@1069 | 494 | |
paul@1069 | 495 | return self.remove_cancellation(user, uid, recurrenceid) |
paul@1069 | 496 | |
paul@1069 | 497 | def remove_cancellation(self, user, uid, recurrenceid=None): |
paul@1069 | 498 | |
paul@1069 | 499 | """ |
paul@1069 | 500 | Remove a cancellation for 'user' for the event having the given 'uid'. |
paul@1069 | 501 | If the optional 'recurrenceid' is specified, a specific instance or |
paul@1069 | 502 | occurrence of an event is affected. |
paul@1069 | 503 | """ |
paul@1069 | 504 | |
paul@1069 | 505 | pass |
paul@1069 | 506 | |
paul@1069 | 507 | class PublisherBase: |
paul@1069 | 508 | |
paul@1069 | 509 | "The core operations of a data publisher." |
paul@1069 | 510 | |
paul@1069 | 511 | def set_freebusy(self, user, freebusy): |
paul@1069 | 512 | |
paul@1069 | 513 | "For the given 'user', set 'freebusy' details." |
paul@1069 | 514 | |
paul@1069 | 515 | pass |
paul@1069 | 516 | |
paul@1069 | 517 | class JournalBase: |
paul@1069 | 518 | |
paul@1069 | 519 | "The core operations of a journal system supporting quotas." |
paul@1069 | 520 | |
paul@1069 | 521 | # Quota and user identity/group discovery. |
paul@1069 | 522 | |
paul@1069 | 523 | def get_quotas(self): |
paul@1069 | 524 | |
paul@1069 | 525 | "Return a list of quotas." |
paul@1069 | 526 | |
paul@1069 | 527 | pass |
paul@1069 | 528 | |
paul@1069 | 529 | def get_quota_users(self, quota): |
paul@1069 | 530 | |
paul@1069 | 531 | "Return a list of quota users." |
paul@1069 | 532 | |
paul@1069 | 533 | pass |
paul@1069 | 534 | |
paul@1069 | 535 | # Groups of users sharing quotas. |
paul@1069 | 536 | |
paul@1069 | 537 | def get_groups(self, quota): |
paul@1069 | 538 | |
paul@1069 | 539 | "Return the identity mappings for the given 'quota' as a dictionary." |
paul@1069 | 540 | |
paul@1069 | 541 | pass |
paul@1069 | 542 | |
paul@1069 | 543 | def get_limits(self, quota): |
paul@1069 | 544 | |
paul@1069 | 545 | """ |
paul@1069 | 546 | Return the limits for the 'quota' as a dictionary mapping identities or |
paul@1069 | 547 | groups to durations. |
paul@1069 | 548 | """ |
paul@1069 | 549 | |
paul@1069 | 550 | pass |
paul@1069 | 551 | |
paul@1069 | 552 | # Free/busy period access for users within quota groups. |
paul@1069 | 553 | |
paul@1069 | 554 | def get_freebusy(self, quota, user): |
paul@1069 | 555 | |
paul@1069 | 556 | "Get free/busy details for the given 'quota' and 'user'." |
paul@1069 | 557 | |
paul@1069 | 558 | pass |
paul@1069 | 559 | |
paul@1069 | 560 | def set_freebusy(self, quota, user, freebusy): |
paul@1069 | 561 | |
paul@1069 | 562 | "For the given 'quota' and 'user', set 'freebusy' details." |
paul@1069 | 563 | |
paul@1069 | 564 | pass |
paul@1069 | 565 | |
paul@1069 | 566 | # Journal entry methods. |
paul@1069 | 567 | |
paul@1069 | 568 | def get_entries(self, quota, group): |
paul@1069 | 569 | |
paul@1069 | 570 | """ |
paul@1069 | 571 | Return a list of journal entries for the given 'quota' for the indicated |
paul@1069 | 572 | 'group'. |
paul@1069 | 573 | """ |
paul@1069 | 574 | |
paul@1069 | 575 | pass |
paul@1069 | 576 | |
paul@1069 | 577 | def set_entries(self, quota, group, entries): |
paul@1069 | 578 | |
paul@1069 | 579 | """ |
paul@1069 | 580 | For the given 'quota' and indicated 'group', set the list of journal |
paul@1069 | 581 | 'entries'. |
paul@1069 | 582 | """ |
paul@1069 | 583 | |
paul@1069 | 584 | pass |
paul@1069 | 585 | |
paul@1069 | 586 | # vim: tabstop=4 expandtab shiftwidth=4 |