paul@1039 | 1 | #!/usr/bin/env python |
paul@1039 | 2 | |
paul@1039 | 3 | """ |
paul@1039 | 4 | Quota-related scheduling functionality. |
paul@1039 | 5 | |
paul@1039 | 6 | Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk> |
paul@1039 | 7 | |
paul@1039 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@1039 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@1039 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@1039 | 11 | version. |
paul@1039 | 12 | |
paul@1039 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@1039 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@1039 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@1039 | 16 | details. |
paul@1039 | 17 | |
paul@1039 | 18 | You should have received a copy of the GNU General Public License along with |
paul@1039 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@1039 | 20 | """ |
paul@1039 | 21 | |
paul@1059 | 22 | from imiptools.dates import get_duration, to_utc_datetime |
paul@1196 | 23 | from imiptools.data import get_uri, uri_dict, Object |
paul@1185 | 24 | from imiptools.handlers.scheduling.common import get_scheduling_conflicts, \ |
paul@1185 | 25 | standard_responses |
paul@1039 | 26 | from imiptools.period import Endless |
paul@1039 | 27 | from datetime import timedelta |
paul@1039 | 28 | |
paul@1039 | 29 | # Quota maintenance. |
paul@1039 | 30 | |
paul@1039 | 31 | def check_quota(handler, args): |
paul@1039 | 32 | |
paul@1039 | 33 | """ |
paul@1039 | 34 | Check the current object of the given 'handler' against the applicable |
paul@1039 | 35 | quota. |
paul@1039 | 36 | """ |
paul@1039 | 37 | |
paul@1153 | 38 | _ = handler.get_translator() |
paul@1153 | 39 | |
paul@1039 | 40 | quota, group = _get_quota_and_group(handler, args) |
paul@1039 | 41 | |
paul@1039 | 42 | # Obtain the journal entries and check the balance. |
paul@1039 | 43 | |
paul@1039 | 44 | journal = handler.get_journal() |
paul@1039 | 45 | entries = journal.get_entries(quota, group) |
paul@1039 | 46 | limits = journal.get_limits(quota) |
paul@1039 | 47 | |
paul@1039 | 48 | # Obtain a limit for the group or any general limit. |
paul@1039 | 49 | # Decline invitations if no limit has been set. |
paul@1039 | 50 | |
paul@1039 | 51 | limit = limits.get(group) or limits.get("*") |
paul@1039 | 52 | if not limit: |
paul@1153 | 53 | return "DECLINED", _("You have no quota allocation for the recipient.") |
paul@1039 | 54 | |
paul@1196 | 55 | # Where the quota is unlimited, accept the invitation. |
paul@1196 | 56 | |
paul@1196 | 57 | if limit == "*": |
paul@1196 | 58 | return "ACCEPTED", _("The recipient has scheduled the requested period.") |
paul@1196 | 59 | |
paul@1196 | 60 | # Decline endless events for limited quotas. |
paul@1185 | 61 | |
paul@1185 | 62 | total = _get_duration(handler) |
paul@1185 | 63 | |
paul@1185 | 64 | if total == Endless(): |
paul@1185 | 65 | return "DECLINED", _("The event period exceeds your quota allocation for the recipient.") |
paul@1185 | 66 | |
paul@1039 | 67 | # Decline events whose durations exceed the balance. |
paul@1039 | 68 | |
paul@1039 | 69 | balance = get_duration(limit) - _get_usage(entries) |
paul@1039 | 70 | |
paul@1039 | 71 | if total > balance: |
paul@1153 | 72 | return "DECLINED", _("The event period exceeds your quota allocation for the recipient.") |
paul@1039 | 73 | else: |
paul@1153 | 74 | return "ACCEPTED", _("The recipient has scheduled the requested period.") |
paul@1039 | 75 | |
paul@1039 | 76 | def add_to_quota(handler, args): |
paul@1039 | 77 | |
paul@1039 | 78 | """ |
paul@1039 | 79 | Record details of the current object of the given 'handler' in the |
paul@1039 | 80 | applicable quota. |
paul@1039 | 81 | """ |
paul@1039 | 82 | |
paul@1039 | 83 | quota, group = _get_quota_and_group(handler, args) |
paul@1199 | 84 | _add_to_quota(handler, quota, group, handler.user, False) |
paul@1196 | 85 | |
paul@1039 | 86 | def remove_from_quota(handler, args): |
paul@1039 | 87 | |
paul@1039 | 88 | """ |
paul@1039 | 89 | Remove details of the current object of the given 'handler' from the |
paul@1039 | 90 | applicable quota. |
paul@1039 | 91 | """ |
paul@1039 | 92 | |
paul@1039 | 93 | quota, group = _get_quota_and_group(handler, args) |
paul@1199 | 94 | _remove_from_quota(handler, quota, group, handler.user) |
paul@1196 | 95 | |
paul@1199 | 96 | def update_event(handler, args): |
paul@1196 | 97 | |
paul@1196 | 98 | "Update a stored version of the current object of the given 'handler'." |
paul@1196 | 99 | |
paul@1196 | 100 | quota, group = _get_quota_and_group(handler, args) |
paul@1196 | 101 | journal = handler.get_journal() |
paul@1196 | 102 | |
paul@1196 | 103 | # Where an existing version of the object exists, merge the recipient's |
paul@1196 | 104 | # attendance information. |
paul@1196 | 105 | |
paul@1196 | 106 | fragment = journal.get_event(quota, handler.uid, handler.recurrenceid) |
paul@1196 | 107 | obj = fragment and Object(fragment) |
paul@1196 | 108 | if not obj: |
paul@1196 | 109 | obj = handler.obj |
paul@1196 | 110 | |
paul@1196 | 111 | # Set attendance. |
paul@1196 | 112 | |
paul@1196 | 113 | attendee_map = uri_dict(obj.get_value_map("ATTENDEE")) |
paul@1196 | 114 | attendee_map[handler.user]["PARTSTAT"] = "ACCEPTED" |
paul@1196 | 115 | obj["ATTENDEE"] = attendee_map.items() |
paul@1196 | 116 | |
paul@1196 | 117 | # Record the object so that recurrences can be generated. |
paul@1196 | 118 | |
paul@1196 | 119 | journal.set_event(quota, handler.uid, handler.recurrenceid, obj.to_node()) |
paul@1196 | 120 | |
paul@1199 | 121 | def remove_event(handler, args): |
paul@1196 | 122 | |
paul@1196 | 123 | "Remove a stored version of the current object of the given 'handler'." |
paul@1196 | 124 | |
paul@1196 | 125 | quota, group = _get_quota_and_group(handler, args) |
paul@1196 | 126 | journal = handler.get_journal() |
paul@1196 | 127 | |
paul@1196 | 128 | # Where an existing version of the object exists, remove the recipient's |
paul@1196 | 129 | # attendance information. |
paul@1196 | 130 | |
paul@1196 | 131 | fragment = journal.get_event(quota, handler.uid, handler.recurrenceid) |
paul@1196 | 132 | obj = fragment and Object(fragment) |
paul@1196 | 133 | if not obj: |
paul@1196 | 134 | return |
paul@1196 | 135 | |
paul@1196 | 136 | attendee_map = uri_dict(obj.get_value_map("ATTENDEE")) |
paul@1196 | 137 | delegates = journal.get_delegates(quota) |
paul@1196 | 138 | |
paul@1196 | 139 | # Determine whether any of the delegates are still involved. |
paul@1196 | 140 | |
paul@1196 | 141 | attendees = set(delegates).intersection(attendee_map.keys()) |
paul@1196 | 142 | if handler.user in attendees: |
paul@1196 | 143 | attendees.remove(handler.user) |
paul@1196 | 144 | |
paul@1196 | 145 | # Remove event details where no delegates will be involved. |
paul@1196 | 146 | |
paul@1196 | 147 | if not attendees: |
paul@1196 | 148 | journal.remove_event(quota, handler.uid, handler.recurrenceid) |
paul@1196 | 149 | return |
paul@1196 | 150 | |
paul@1196 | 151 | del attendee_map[handler.user] |
paul@1196 | 152 | obj["ATTENDEE"] = attendee_map.items() |
paul@1196 | 153 | |
paul@1196 | 154 | # Record the object so that recurrences can be generated. |
paul@1196 | 155 | |
paul@1196 | 156 | journal.set_event(quota, handler.uid, handler.recurrenceid, obj.to_node()) |
paul@1196 | 157 | |
paul@1039 | 158 | def _get_quota_and_group(handler, args): |
paul@1039 | 159 | |
paul@1039 | 160 | """ |
paul@1039 | 161 | Combine information about the current object from the 'handler' with the |
paul@1039 | 162 | given 'args' to return a tuple containing the quota group and the user |
paul@1039 | 163 | identity or group involved. |
paul@1039 | 164 | """ |
paul@1039 | 165 | |
paul@1039 | 166 | quota = args and args[0] or handler.user |
paul@1039 | 167 | |
paul@1039 | 168 | # Obtain the identity to whom the quota will apply. |
paul@1039 | 169 | |
paul@1039 | 170 | organiser = get_uri(handler.obj.get_value("ORGANIZER")) |
paul@1039 | 171 | |
paul@1039 | 172 | # Obtain any user group to which the quota will apply instead. |
paul@1039 | 173 | |
paul@1039 | 174 | journal = handler.get_journal() |
paul@1039 | 175 | groups = journal.get_groups(quota) |
paul@1039 | 176 | |
paul@1179 | 177 | return quota, groups.get(organiser) or groups.get("*") or organiser |
paul@1039 | 178 | |
paul@1039 | 179 | def _get_duration(handler): |
paul@1039 | 180 | |
paul@1039 | 181 | "Return the duration of the current object provided by the 'handler'." |
paul@1039 | 182 | |
paul@1050 | 183 | # Reject indefinitely recurring events. |
paul@1050 | 184 | |
paul@1050 | 185 | if handler.obj.possibly_recurring_indefinitely(): |
paul@1050 | 186 | return Endless() |
paul@1050 | 187 | |
paul@1050 | 188 | # Otherwise, return a sum of the period durations. |
paul@1039 | 189 | |
paul@1039 | 190 | total = timedelta(0) |
paul@1039 | 191 | |
paul@1050 | 192 | for period in handler.get_periods(handler.obj): |
paul@1039 | 193 | duration = period.get_duration() |
paul@1039 | 194 | |
paul@1039 | 195 | # Decline events whose period durations are endless. |
paul@1039 | 196 | |
paul@1039 | 197 | if duration == Endless(): |
paul@1039 | 198 | return duration |
paul@1039 | 199 | else: |
paul@1039 | 200 | total += duration |
paul@1039 | 201 | |
paul@1039 | 202 | return total |
paul@1039 | 203 | |
paul@1048 | 204 | def _get_expiry_time(handler): |
paul@1048 | 205 | |
paul@1048 | 206 | """ |
paul@1048 | 207 | Return the expiry time for quota purposes of the current object provided by |
paul@1048 | 208 | the 'handler'. |
paul@1048 | 209 | """ |
paul@1048 | 210 | |
paul@1050 | 211 | # Reject indefinitely recurring events. |
paul@1048 | 212 | |
paul@1050 | 213 | if handler.obj.possibly_recurring_indefinitely(): |
paul@1050 | 214 | return None |
paul@1050 | 215 | |
paul@1050 | 216 | periods = handler.get_periods(handler.obj) |
paul@1048 | 217 | return periods and to_utc_datetime(periods[-1].get_end_point()) or None |
paul@1048 | 218 | |
paul@1039 | 219 | def _get_usage(entries): |
paul@1039 | 220 | |
paul@1039 | 221 | "Return the usage total according to the given 'entries'." |
paul@1039 | 222 | |
paul@1039 | 223 | total = timedelta(0) |
paul@1059 | 224 | for period in entries: |
paul@1059 | 225 | total += period.get_duration() |
paul@1039 | 226 | return total |
paul@1039 | 227 | |
paul@1199 | 228 | def _add_to_quota(handler, quota, user, participant, is_organiser): |
paul@1199 | 229 | |
paul@1199 | 230 | """ |
paul@1199 | 231 | Record details of the current object of the 'handler' in the applicable |
paul@1199 | 232 | free/busy resource. |
paul@1199 | 233 | """ |
paul@1199 | 234 | |
paul@1199 | 235 | journal = handler.get_journal() |
paul@1199 | 236 | freebusy = journal.get_entries_for_update(quota, user) |
paul@1199 | 237 | handler.update_freebusy(freebusy, participant, is_organiser) |
paul@1199 | 238 | |
paul@1199 | 239 | # Remove original recurrence details replaced by additional |
paul@1199 | 240 | # recurrences, as well as obsolete additional recurrences. |
paul@1199 | 241 | |
paul@1199 | 242 | handler.remove_freebusy_for_recurrences(freebusy, journal.get_recurrences(quota, handler.uid)) |
paul@1199 | 243 | |
paul@1199 | 244 | # Update free/busy provider information if the event may recur indefinitely. |
paul@1199 | 245 | |
paul@1199 | 246 | if handler.possibly_recurring_indefinitely(): |
paul@1199 | 247 | journal.append_freebusy_provider(quota, handler.obj) |
paul@1199 | 248 | |
paul@1199 | 249 | journal.set_entries(quota, user, freebusy) |
paul@1199 | 250 | |
paul@1199 | 251 | def _remove_from_quota(handler, quota, user, participant): |
paul@1199 | 252 | |
paul@1199 | 253 | """ |
paul@1199 | 254 | Remove details of the current object of the 'handler' from the applicable |
paul@1199 | 255 | free/busy resource. |
paul@1199 | 256 | """ |
paul@1199 | 257 | |
paul@1199 | 258 | journal = handler.get_journal() |
paul@1199 | 259 | freebusy = journal.get_entries_for_update(quota, user) |
paul@1199 | 260 | |
paul@1199 | 261 | # Remove only the entries associated with this recipient. |
paul@1199 | 262 | |
paul@1199 | 263 | removed = handler.remove_from_freebusy(freebusy) |
paul@1199 | 264 | for p in removed: |
paul@1199 | 265 | if p.attendee != participant: |
paul@1199 | 266 | freebusy.insert_period(p) |
paul@1199 | 267 | |
paul@1199 | 268 | # Update free/busy provider information if the event may recur indefinitely. |
paul@1199 | 269 | |
paul@1199 | 270 | if handler.possibly_recurring_indefinitely(): |
paul@1199 | 271 | journal.remove_freebusy_provider(quota, handler.obj) |
paul@1199 | 272 | |
paul@1199 | 273 | journal.set_entries(quota, user, freebusy) |
paul@1199 | 274 | |
paul@1039 | 275 | # Collective free/busy maintenance. |
paul@1039 | 276 | |
paul@1039 | 277 | def schedule_across_quota(handler, args): |
paul@1039 | 278 | |
paul@1039 | 279 | """ |
paul@1181 | 280 | Check the current object of the given 'handler' against the individual |
paul@1181 | 281 | schedules managed by the quota. The consolidated schedules are not tested, |
paul@1181 | 282 | nor are the quotas themselves. |
paul@1039 | 283 | """ |
paul@1039 | 284 | |
paul@1039 | 285 | quota, organiser = _get_quota_and_identity(handler, args) |
paul@1039 | 286 | |
paul@1166 | 287 | # Check the event periods against the quota's consolidated record of the |
paul@1166 | 288 | # organiser's reservations. |
paul@1039 | 289 | |
paul@1039 | 290 | periods = handler.get_periods(handler.obj) |
paul@1192 | 291 | freebusy = handler.get_journal().get_entries(quota, organiser) |
paul@1039 | 292 | scheduled = handler.can_schedule(freebusy, periods) |
paul@1039 | 293 | |
paul@1185 | 294 | return standard_responses(handler, scheduled and "ACCEPTED" or "DECLINED") |
paul@1039 | 295 | |
paul@1039 | 296 | def add_to_quota_freebusy(handler, args): |
paul@1039 | 297 | |
paul@1039 | 298 | """ |
paul@1039 | 299 | Record details of the current object of the 'handler' in the applicable |
paul@1039 | 300 | free/busy resource. |
paul@1039 | 301 | """ |
paul@1039 | 302 | |
paul@1039 | 303 | quota, organiser = _get_quota_and_identity(handler, args) |
paul@1199 | 304 | _add_to_quota(handler, quota, organiser, organiser, True) |
paul@1039 | 305 | |
paul@1039 | 306 | def remove_from_quota_freebusy(handler, args): |
paul@1039 | 307 | |
paul@1039 | 308 | """ |
paul@1039 | 309 | Remove details of the current object of the 'handler' from the applicable |
paul@1039 | 310 | free/busy resource. |
paul@1039 | 311 | """ |
paul@1039 | 312 | |
paul@1039 | 313 | quota, organiser = _get_quota_and_identity(handler, args) |
paul@1199 | 314 | _remove_from_quota(handler, quota, organiser, organiser) |
paul@1039 | 315 | |
paul@1039 | 316 | def _get_quota_and_identity(handler, args): |
paul@1039 | 317 | |
paul@1039 | 318 | """ |
paul@1039 | 319 | Combine information about the current object from the 'handler' with the |
paul@1039 | 320 | given 'args' to return a tuple containing the quota group and the user |
paul@1039 | 321 | identity involved. |
paul@1039 | 322 | """ |
paul@1039 | 323 | |
paul@1039 | 324 | quota = args and args[0] or handler.user |
paul@1039 | 325 | |
paul@1039 | 326 | # Obtain the identity for whom the scheduling will apply. |
paul@1039 | 327 | |
paul@1039 | 328 | organiser = get_uri(handler.obj.get_value("ORGANIZER")) |
paul@1039 | 329 | |
paul@1039 | 330 | return quota, organiser |
paul@1039 | 331 | |
paul@1176 | 332 | # Delegation of reservations. |
paul@1176 | 333 | |
paul@1176 | 334 | def schedule_for_delegate(handler, args): |
paul@1176 | 335 | |
paul@1176 | 336 | """ |
paul@1176 | 337 | Check the current object of the given 'handler' against the schedules |
paul@1176 | 338 | managed by the quota, delegating to a specific recipient according to the |
paul@1185 | 339 | given policies. |
paul@1176 | 340 | """ |
paul@1176 | 341 | |
paul@1181 | 342 | # First check the quota and decline any request that would exceed the quota. |
paul@1181 | 343 | |
paul@1181 | 344 | scheduled = check_quota(handler, args) |
paul@1181 | 345 | response, description = scheduled or ("DECLINED", None) |
paul@1181 | 346 | |
paul@1181 | 347 | if response == "DECLINED": |
paul@1181 | 348 | return response, description |
paul@1181 | 349 | |
paul@1181 | 350 | # Obtain the quota and organiser group details to evaluate delegation. |
paul@1181 | 351 | |
paul@1176 | 352 | quota, group = _get_quota_and_group(handler, args) |
paul@1185 | 353 | policies = args and args[1:] or ["available"] |
paul@1176 | 354 | |
paul@1176 | 355 | # Determine the status of the recipient. |
paul@1176 | 356 | |
paul@1176 | 357 | attendee_map = uri_dict(handler.obj.get_value_map("ATTENDEE")) |
paul@1176 | 358 | attendee_attr = attendee_map[handler.user] |
paul@1176 | 359 | |
paul@1176 | 360 | # Prevent delegation by a delegate. |
paul@1176 | 361 | |
paul@1176 | 362 | if attendee_attr.get("DELEGATED-FROM"): |
paul@1176 | 363 | delegates = set([handler.user]) |
paul@1176 | 364 | |
paul@1176 | 365 | # Obtain the delegate pool for the quota. |
paul@1176 | 366 | |
paul@1176 | 367 | else: |
paul@1176 | 368 | delegates = handler.get_journal().get_delegates(quota) |
paul@1176 | 369 | |
paul@1176 | 370 | # Obtain the remaining delegates not already involved in the event. |
paul@1176 | 371 | |
paul@1176 | 372 | delegates = set(delegates).difference(attendee_map) |
paul@1176 | 373 | delegates.add(handler.user) |
paul@1176 | 374 | |
paul@1176 | 375 | # Get the quota's schedule for the requested periods and identify |
paul@1176 | 376 | # unavailable delegates. |
paul@1176 | 377 | |
paul@1176 | 378 | entries = handler.get_journal().get_entries(quota, group) |
paul@1185 | 379 | conflicts = get_scheduling_conflicts(handler, entries, delegates, attendee=True) |
paul@1176 | 380 | |
paul@1185 | 381 | # Get the delegates in order of increasing unavailability (or decreasing |
paul@1185 | 382 | # availability). |
paul@1176 | 383 | |
paul@1185 | 384 | unavailability = conflicts.items() |
paul@1185 | 385 | |
paul@1185 | 386 | # Apply the policies to choose a suitable delegate. |
paul@1176 | 387 | |
paul@1185 | 388 | if "most-available" in policies: |
paul@1185 | 389 | unavailability.sort(key=lambda t: t[1]) |
paul@1185 | 390 | available = [delegate for (delegate, commitments) in unavailability] |
paul@1185 | 391 | delegate = available and available[0] |
paul@1176 | 392 | |
paul@1185 | 393 | # The default is to select completely available delegates. |
paul@1176 | 394 | |
paul@1185 | 395 | else: |
paul@1185 | 396 | available = [delegate for (delegate, commitments) in unavailability if not commitments] |
paul@1185 | 397 | delegate = available and (handler.user in available and handler.user or available[0]) |
paul@1176 | 398 | |
paul@1185 | 399 | # Only accept or delegate if a suitably available delegate is found. |
paul@1176 | 400 | |
paul@1185 | 401 | if delegate: |
paul@1176 | 402 | |
paul@1176 | 403 | # Add attendee for delegate, obtaining the original attendee dictionary. |
paul@1176 | 404 | # Modify this user's status to refer to the delegate. |
paul@1176 | 405 | |
paul@1176 | 406 | if delegate != handler.user: |
paul@1176 | 407 | attendee_map = handler.obj.get_value_map("ATTENDEE") |
paul@1176 | 408 | attendee_map[delegate] = {"DELEGATED-FROM" : [handler.user]} |
paul@1176 | 409 | attendee_attr["DELEGATED-TO"] = [delegate] |
paul@1176 | 410 | handler.obj["ATTENDEE"] = attendee_map.items() |
paul@1176 | 411 | |
paul@1185 | 412 | response = "DELEGATED" |
paul@1176 | 413 | else: |
paul@1185 | 414 | response = "ACCEPTED" |
paul@1176 | 415 | else: |
paul@1185 | 416 | response = "DECLINED" |
paul@1185 | 417 | |
paul@1185 | 418 | return standard_responses(handler, response) |
paul@1176 | 419 | |
paul@1040 | 420 | # Locking and unlocking. |
paul@1040 | 421 | |
paul@1040 | 422 | def lock_journal(handler, args): |
paul@1040 | 423 | |
paul@1040 | 424 | "Using the 'handler' and 'args', lock the journal for the quota." |
paul@1040 | 425 | |
paul@1040 | 426 | handler.get_journal().acquire_lock(_get_quota(handler, args)) |
paul@1040 | 427 | |
paul@1040 | 428 | def unlock_journal(handler, args): |
paul@1040 | 429 | |
paul@1040 | 430 | "Using the 'handler' and 'args', unlock the journal for the quota." |
paul@1040 | 431 | |
paul@1040 | 432 | handler.get_journal().release_lock(_get_quota(handler, args)) |
paul@1040 | 433 | |
paul@1040 | 434 | def _get_quota(handler, args): |
paul@1040 | 435 | |
paul@1040 | 436 | "Return the quota using the 'handler' and 'args'." |
paul@1040 | 437 | |
paul@1040 | 438 | return args and args[0] or handler.user |
paul@1040 | 439 | |
paul@1039 | 440 | # Registry of scheduling functions. |
paul@1039 | 441 | |
paul@1039 | 442 | scheduling_functions = { |
paul@1199 | 443 | "check_quota" : [check_quota], |
paul@1199 | 444 | "schedule_across_quota" : [schedule_across_quota], |
paul@1199 | 445 | "schedule_for_delegate" : [schedule_for_delegate], |
paul@1039 | 446 | } |
paul@1039 | 447 | |
paul@1040 | 448 | # Registries of locking and unlocking functions. |
paul@1040 | 449 | |
paul@1040 | 450 | locking_functions = { |
paul@1199 | 451 | "check_quota" : [lock_journal], |
paul@1199 | 452 | "schedule_across_quota" : [lock_journal], |
paul@1199 | 453 | "schedule_for_delegate" : [lock_journal], |
paul@1040 | 454 | } |
paul@1040 | 455 | |
paul@1040 | 456 | unlocking_functions = { |
paul@1199 | 457 | "check_quota" : [unlock_journal], |
paul@1199 | 458 | "schedule_across_quota" : [unlock_journal], |
paul@1199 | 459 | "schedule_for_delegate" : [unlock_journal], |
paul@1040 | 460 | } |
paul@1040 | 461 | |
paul@1039 | 462 | # Registries of listener functions. |
paul@1039 | 463 | |
paul@1039 | 464 | confirmation_functions = { |
paul@1199 | 465 | "check_quota" : [add_to_quota, update_event], |
paul@1199 | 466 | "schedule_across_quota" : [add_to_quota_freebusy, update_event], |
paul@1199 | 467 | "schedule_for_delegate" : [add_to_quota, update_event], |
paul@1039 | 468 | } |
paul@1039 | 469 | |
paul@1039 | 470 | retraction_functions = { |
paul@1199 | 471 | "check_quota" : [remove_from_quota, remove_event], |
paul@1199 | 472 | "schedule_across_quota" : [remove_from_quota_freebusy, remove_event], |
paul@1199 | 473 | "schedule_for_delegate" : [remove_from_quota, remove_event], |
paul@1039 | 474 | } |
paul@1039 | 475 | |
paul@1039 | 476 | # vim: tabstop=4 expandtab shiftwidth=4 |