diff --git a/app/model/__init__.py b/app/model/__init__.py index 6f87dd6..df456b0 100644 --- a/app/model/__init__.py +++ b/app/model/__init__.py @@ -1,51 +1,54 @@ # -*- coding: utf-8 -*- # -# Copyright 2014 Kolab Systems AG (http://www.kolabsys.com) +# Copyright 2014-2015 Kolab Systems AG (http://www.kolabsys.com) # # Thomas Bruederli # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # from event import Event from task import Task from note import Note +from contact import Contact from system import System from user import User, Permission, AnonymousUser __all__ = [ 'System', 'Event', 'Task', 'Note', + 'Contact', 'User', 'Permission', 'AnonymousUser', ] __class_map__ = { 'event': Event, 'task': Task, 'note': Note, + 'contact': Contact, 'system': System, } def get_instance(classname, **kw): """ Returns an instance of the given model class """ if __class_map__.has_key(classname): return __class_map__[classname](**kw) return None \ No newline at end of file diff --git a/app/model/__init__.py b/app/model/contact.py similarity index 55% copy from app/model/__init__.py copy to app/model/contact.py index 6f87dd6..7c7cb7e 100644 --- a/app/model/__init__.py +++ b/app/model/contact.py @@ -1,51 +1,35 @@ # -*- coding: utf-8 -*- # -# Copyright 2014 Kolab Systems AG (http://www.kolabsys.com) +# Copyright 2015 Kolab Systems AG (http://www.kolabsys.com) # # Thomas Bruederli # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -from event import Event -from task import Task -from note import Note -from system import System -from user import User, Permission, AnonymousUser +from kolabobject import KolabObject +from pykolab.xml import contact_from_message -__all__ = [ - 'System', - 'Event', - 'Task', - 'Note', - 'User', - 'Permission', - 'AnonymousUser', -] - -__class_map__ = { - 'event': Event, - 'task': Task, - 'note': Note, - 'system': System, -} - -def get_instance(classname, **kw): +class Contact(KolabObject): """ - Returns an instance of the given model class + Model class for accessing Kolab Groupware Contact objects """ - if __class_map__.has_key(classname): - return __class_map__[classname](**kw) - return None \ No newline at end of file + def __init__(self, *args, **kw): + KolabObject.__init__(self, *args, **kw) + self.folder_type = 'contact' + self.x_kolab_type = 'application/x-vnd.kolab.contact' + + def _object_from_message(self, message): + return contact_from_message(message)