[Calypso-commits] [calypso] 01/01: Add is-addressbook and is-calendar settings.

Jelmer Vernooij jelmer at moszumanska.debian.org
Sat Apr 9 22:48:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

jelmer pushed a commit to branch master
in repository calypso.

commit 3c88af670e3cc7119dcbbd2b25e18d2e39ce5a48
Author: Jelmer Vernooij <jelmer at jelmer.uk>
Date:   Sat Apr 9 18:04:12 2016 +0000

    Add is-addressbook and is-calendar settings.
    
    This is necessary acal (for which every collection is either an address
    book or a calendar).
    
    Both settings default to True (current behaviour).
    
    Based on patches by chrysn.
---
 README              | 12 ++++++++++--
 calypso/webdav.py   | 14 ++++++++++++++
 calypso/xmlutils.py | 10 ++++++----
 collection-config   |  7 +++++++
 4 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/README b/README
index f79d693..398e000 100644
--- a/README
+++ b/README
@@ -47,13 +47,21 @@ To add a new database:
 $ mkdir -p ~/.config/calypso/calendars/private/test
 $ cd ~/.config/calypso/calendars/private/test
 $ git init
-$ git commit --allow-empty -m'initialize new calendar'
+$ cat > .calypso-collection << EOF
+[collection]
+is-calendar = 1
+EOF
+$ git add .calypso-collection
+$ git commit -m'initialize new calendar'
 
 The new calendar should now be visible as https://USER:PASSWORD@localhost:5233/private/test.
 
 You can add files to the directory at any time; calypso will check the
 directory mtime at each operation and update its internal state from
-that on disk automatically when the directory changes.  Importing files
+that on disk automatically when the directory changes.
+
+Importing files
+---------------
 
 Given a set of files with VCALENDAR or VCARD entries, you can import them with:
 
diff --git a/calypso/webdav.py b/calypso/webdav.py
index 34aacce..c6f9a0d 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -616,3 +616,17 @@ class Collection(object):
     @property
     def length(self):
         return "%d" % len(self.text)
+
+    @property
+    def is_addressbook(self):
+        try:
+            return self.metadata.getboolean('collection', 'is-addressbook')
+        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
+            return True
+
+    @property
+    def is_calendar(self):
+        try:
+            return self.metadata.getboolean('collection', 'is-calendar')
+        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
+            return True
diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py
index 7f9c674..be8b556 100644
--- a/calypso/xmlutils.py
+++ b/calypso/xmlutils.py
@@ -159,10 +159,12 @@ def propfind(path, xml_request, collection, depth, context):
         for tag in props:
             element = ET.Element(tag)
             if tag == _tag("D", "resourcetype") and is_collection:
-                tag = ET.Element(_tag("C", "calendar"))
-                element.append(tag)
-                tag = ET.Element(_tag("A", "addressbook"))
-                element.append(tag)
+                if collection.is_calendar:
+                    tag = ET.Element(_tag("C", "calendar"))
+                    element.append(tag)
+                if collection.is_addressbook:
+                    tag = ET.Element(_tag("A", "addressbook"))
+                    element.append(tag)
                 tag = ET.Element(_tag("D", "collection"))
                 element.append(tag)
             elif tag == _tag("D", "owner"):
diff --git a/collection-config b/collection-config
index 4ce34a4..c1a2e24 100644
--- a/collection-config
+++ b/collection-config
@@ -11,4 +11,11 @@ displayname = My Calendar
 # WebDAV properties. Defaults to the collection's path.
 description = Collection of all my personal dates.
 
+# Advertise this collection as a calendar. If this setting is absent,
+# it defaults to True.
+is-calendar = 1
+# Advertise this collection as an address book. Behaves in analogy to
+# is-calendar.
+is-addressbook = 0
+
 # vim:ft=cfg

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/calypso/calypso.git



More information about the Calypso-commits mailing list