Mercurial > libervia-backend
comparison src/plugins/plugin_misc_groupblog.py @ 1919:d3354c80bd1f
core (tools): moved common to a separate package, and put data method in a data_format module
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 22 Mar 2016 22:46:04 +0100 |
parents | d17772b0fe22 |
children | 2daf7b4c6756 |
comparison
equal
deleted
inserted
replaced
1918:01d56efd488b | 1919:d3354c80bd1f |
---|---|
23 log = getLogger(__name__) | 23 log = getLogger(__name__) |
24 from twisted.internet import defer | 24 from twisted.internet import defer |
25 from sat.core import exceptions | 25 from sat.core import exceptions |
26 from wokkel import disco, data_form, iwokkel | 26 from wokkel import disco, data_form, iwokkel |
27 from zope.interface import implements | 27 from zope.interface import implements |
28 from sat.tools import common | 28 from sat.tools.common import data_format |
29 | 29 |
30 try: | 30 try: |
31 from twisted.words.protocols.xmlstream import XMPPHandler | 31 from twisted.words.protocols.xmlstream import XMPPHandler |
32 except ImportError: | 32 except ImportError: |
33 from wokkel.subprotocols import XMPPHandler | 33 from wokkel.subprotocols import XMPPHandler |
100 if config_form is None: | 100 if config_form is None: |
101 return | 101 return |
102 access_model = config_form.get(self._p.OPT_ACCESS_MODEL, self._p.ACCESS_OPEN) | 102 access_model = config_form.get(self._p.OPT_ACCESS_MODEL, self._p.ACCESS_OPEN) |
103 # FIXME: ACCESS_ROSTER need to be changed to a new ACCESS_PUBLISHER_ROSTER when available | 103 # FIXME: ACCESS_ROSTER need to be changed to a new ACCESS_PUBLISHER_ROSTER when available |
104 if access_model == self._p.ACCESS_ROSTER: | 104 if access_model == self._p.ACCESS_ROSTER: |
105 common.iter2dict('group', config_form.fields[self._p.OPT_ROSTER_GROUPS_ALLOWED].values, microblog_data) | 105 data_format.iter2dict('group', config_form.fields[self._p.OPT_ROSTER_GROUPS_ALLOWED].values, microblog_data) |
106 | 106 |
107 def _data2entryTrigger(self, client, mb_data, entry_elt, item_elt): | 107 def _data2entryTrigger(self, client, mb_data, entry_elt, item_elt): |
108 """Build fine access permission if needed | 108 """Build fine access permission if needed |
109 | 109 |
110 This trigger check if "group*" key are present, | 110 This trigger check if "group*" key are present, |
111 and create a fine item config to restrict view to these groups | 111 and create a fine item config to restrict view to these groups |
112 """ | 112 """ |
113 groups = list(common.dict2iter('group', mb_data)) | 113 groups = list(data_format.dict2iter('group', mb_data)) |
114 if not groups: | 114 if not groups: |
115 return | 115 return |
116 if not client.server_groupblog_available: | 116 if not client.server_groupblog_available: |
117 raise exceptions.CancelError(u"GroupBlog is not available") | 117 raise exceptions.CancelError(u"GroupBlog is not available") |
118 log.debug(u"This entry use group blog") | 118 log.debug(u"This entry use group blog") |
130 It changes the access mode to roster if needed, and give the authorized groups | 130 It changes the access mode to roster if needed, and give the authorized groups |
131 """ | 131 """ |
132 if "group" in mb_data: | 132 if "group" in mb_data: |
133 # FIXME: ACCESS_ROSTER need to be changed to a new ACCESS_PUBLISHER_ROSTER when available | 133 # FIXME: ACCESS_ROSTER need to be changed to a new ACCESS_PUBLISHER_ROSTER when available |
134 options[self._p.OPT_ACCESS_MODEL] = self._p.ACCESS_ROSTER | 134 options[self._p.OPT_ACCESS_MODEL] = self._p.ACCESS_ROSTER |
135 options[self._p.OPT_ROSTER_GROUPS_ALLOWED] = list(common.dict2iter('group', mb_data)) | 135 options[self._p.OPT_ROSTER_GROUPS_ALLOWED] = list(data_format.dict2iter('group', mb_data)) |
136 | 136 |
137 | 137 |
138 class GroupBlog_handler(XMPPHandler): | 138 class GroupBlog_handler(XMPPHandler): |
139 implements(iwokkel.IDisco) | 139 implements(iwokkel.IDisco) |
140 | 140 |