Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_blog.py @ 1663:47224056ce5c
quick_frontend(blog): groups blog sending is handled
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 24 Nov 2015 16:21:18 +0100 |
parents | b08b828a87c9 |
children | dbac3cb19159 |
comparison
equal
deleted
inserted
replaced
1662:9aa2a703e460 | 1663:47224056ce5c |
---|---|
23 | 23 |
24 | 24 |
25 from sat_frontends.quick_frontend.constants import Const as C | 25 from sat_frontends.quick_frontend.constants import Const as C |
26 from sat_frontends.quick_frontend import quick_widgets | 26 from sat_frontends.quick_frontend import quick_widgets |
27 from sat_frontends.tools import jid | 27 from sat_frontends.tools import jid |
28 from sat.tools import common | |
28 | 29 |
29 try: | 30 try: |
30 # FIXME: to be removed when an acceptable solution is here | 31 # FIXME: to be removed when an acceptable solution is here |
31 unicode('') # XXX: unicode doesn't exist in pyjamas | 32 unicode('') # XXX: unicode doesn't exist in pyjamas |
32 except (TypeError, AttributeError): # Error raised is not the same depending on pyjsbuild options | 33 except (TypeError, AttributeError): # Error raised is not the same depending on pyjsbuild options |
260 if value is not None: | 261 if value is not None: |
261 mb_data[name] = value | 262 mb_data[name] = value |
262 | 263 |
263 mb_data.update(tags2mbdata(self.item.tags)) | 264 mb_data.update(tags2mbdata(self.item.tags)) |
264 | 265 |
266 if self.blog.new_message_target not in (C.PUBLIC, C.GROUP): | |
267 raise NotImplementedError | |
268 | |
265 if self.level == 0: | 269 if self.level == 0: |
266 if self.blog.new_message_target == C.PUBLIC: | 270 if self.new: |
267 if self.new: | 271 mb_data["allow_comments"] = C.BOOL_TRUE |
268 mb_data["allow_comments"] = C.BOOL_TRUE | 272 |
269 else: | 273 if self.blog.new_message_target == C.GROUP: |
270 raise NotImplementedError | 274 common.iter2dict('group', self.blog.targets, mb_data) |
271 | 275 |
272 self.blog.host.bridge.mbSend( | 276 self.blog.host.bridge.mbSend( |
273 unicode(self.service or ''), | 277 unicode(self.service or ''), |
274 self.node or '', | 278 self.node or '', |
275 mb_data, | 279 mb_data, |
337 @property | 341 @property |
338 def new_message_target(self): | 342 def new_message_target(self): |
339 if self._targets_type == C.ALL: | 343 if self._targets_type == C.ALL: |
340 return C.PUBLIC | 344 return C.PUBLIC |
341 elif self._targets_type == C.GROUP: | 345 elif self._targets_type == C.GROUP: |
342 return self.targets | 346 return C.GROUP |
343 else: | 347 else: |
344 raise ValueError("Unkown targets type") | 348 raise ValueError("Unkown targets type") |
345 | 349 |
346 def __str__(self): | 350 def __str__(self): |
347 return u"Blog Widget [target: {}, profile: {}]".format(', '.join(self.targets), self.profile) | 351 return u"Blog Widget [target: {}, profile: {}]".format(', '.join(self.targets), self.profile) |