# HG changeset patch # User Paul Boddie # Date 1442530351 -7200 # Node ID 3b0ac9430955f46ac3e0e56cfcd94bb3dd28819a # Parent e332784ba2bbe5d04881a0e229d6132a956c6552 Added support for configurable default preferences. diff -r e332784ba2bb -r 3b0ac9430955 imiptools/__init__.py --- a/imiptools/__init__.py Thu Sep 17 18:08:40 2015 +0200 +++ b/imiptools/__init__.py Fri Sep 18 00:52:31 2015 +0200 @@ -20,6 +20,7 @@ """ from email import message_from_file +from imiptools import config from imiptools.client import Client from imiptools.content import handle_itip_part from imiptools.data import get_address, get_addresses, get_uri @@ -311,7 +312,7 @@ # Determine whether to wrap, accompany or replace the message. prefs = self.get_preferences() - incoming = prefs.get("incoming") + incoming = prefs.get("incoming", config.INCOMING_DEFAULT) if incoming == "message-only": messages = [msg] diff -r e332784ba2bb -r 3b0ac9430955 imiptools/client.py --- a/imiptools/client.py Thu Sep 17 18:08:40 2015 +0200 +++ b/imiptools/client.py Fri Sep 18 00:52:31 2015 +0200 @@ -20,7 +20,7 @@ """ from datetime import datetime, timedelta -from imiptools.config import MANAGER_INTERFACE +from imiptools import config from imiptools.data import Object, get_address, get_uri, get_window_end, \ is_new_object, make_freebusy, to_part, \ uri_dict, uri_items, uri_values @@ -93,49 +93,49 @@ "Return participation in the calendar system." prefs = self.get_preferences() - return prefs and prefs.get("participating", "participate") != "no" or False + return prefs and prefs.get("participating", config.PARTICIPATING_DEFAULT) != "no" or False def is_sharing(self): "Return whether free/busy information is being generally shared." prefs = self.get_preferences() - return prefs and prefs.get("freebusy_sharing") == "share" or False + return prefs and prefs.get("freebusy_sharing", config.SHARING_DEFAULT) == "share" or False def is_bundling(self): "Return whether free/busy information is being bundled in messages." prefs = self.get_preferences() - return prefs and prefs.get("freebusy_bundling") == "always" or False + return prefs and prefs.get("freebusy_bundling", config.BUNDLING_DEFAULT) == "always" or False def is_notifying(self): "Return whether recipients are notified about free/busy payloads." prefs = self.get_preferences() - return prefs and prefs.get("freebusy_messages") == "notify" or False + return prefs and prefs.get("freebusy_messages", config.NOTIFYING_DEFAULT) == "notify" or False def is_publishing(self): "Return whether free/busy information is being published as Web resources." prefs = self.get_preferences() - return prefs and prefs.get("freebusy_publishing") == "publish" or False + return prefs and prefs.get("freebusy_publishing", config.PUBLISHING_DEFAULT) == "publish" or False def is_refreshing(self): "Return whether a recipient supports requests to refresh event details." prefs = self.get_preferences() - return prefs and prefs.get("event_refreshing") == "always" or False + return prefs and prefs.get("event_refreshing", config.REFRESHING_DEFAULT) == "always" or False def allow_add(self): return self.get_add_method_response() in ("add", "refresh") def get_add_method_response(self): prefs = self.get_preferences() - return prefs and prefs.get("add_method_response", "refresh") or "refresh" + return prefs and prefs.get("add_method_response", config.ADD_RESPONSE_DEFAULT) or "refresh" def get_offer_period(self): @@ -147,7 +147,7 @@ """ prefs = self.get_preferences() - duration = prefs and prefs.get("freebusy_offers") + duration = prefs and prefs.get("freebusy_offers", config.FREEBUSY_OFFER_DEFAULT) if duration: try: if duration.endswith("d"): @@ -164,10 +164,10 @@ def get_organiser_replacement(self): prefs = self.get_preferences() - return prefs and prefs.get("organiser_replacement", "attendee") or "attendee" + return prefs and prefs.get("organiser_replacement", config.ORGANISER_REPLACEMENT_DEFAULT) or "attendee" def have_manager(self): - return MANAGER_INTERFACE + return config.MANAGER_INTERFACE def get_permitted_values(self): diff -r e332784ba2bb -r 3b0ac9430955 imiptools/config.py --- a/imiptools/config.py Thu Sep 17 18:08:40 2015 +0200 +++ b/imiptools/config.py Fri Sep 18 00:52:31 2015 +0200 @@ -32,6 +32,8 @@ DEFAULT_DIR_PERMISSIONS = 02770 + + # The availability of a management interface for calendar information. # True: provide links in notifications to the interface described below. # False: omit links in notifications. @@ -48,4 +50,54 @@ MANAGER_URL = None + + +# Preferences defaults applicable unless overridden by the user. +# Changing these allows organisational policy to be defined while still +# allowing users to choose more appropriate settings themselves. +# See: docs/preferences.txt + +# Do users participate in the calendar system by default? + +PARTICIPATING_DEFAULT = "participate" + +# How should incoming messages be presented to a user by default? + +INCOMING_DEFAULT = "summary-wraps-message" + +# Do users share free/busy information by default? This affects the bundling and +# publishing settings. + +SHARING_DEFAULT = "no" + +# Are free/busy details published on the Web by default? + +PUBLISHING_DEFAULT = "no" + +# Are free/busy details bundled with other objects in messages by default? + +BUNDLING_DEFAULT = "never" + +# What notifications do users get about incoming free/busy messages by default? + +NOTIFYING_DEFAULT = "none" + +# Are REFRESH messages automatically handled by default? + +REFRESHING_DEFAULT = "never" + +# How are ADD messages responded to by default? + +ADD_RESPONSE_DEFAULT = "refresh" + +# Who can replace an organiser in an event by default? + +ORGANISER_REPLACEMENT_DEFAULT = "attendee" + +# How long are free/busy offers valid for by default? +# (None means that no offers are maintained for counter-proposals and thus any +# periods in the counter-proposal are not held in anticipation of a response.) + +FREEBUSY_OFFER_DEFAULT = None + # vim: tabstop=4 expandtab shiftwidth=4