quick frontend (blog): replaced mbdata2tags and tags2mbdata by sat.tools.common.dict2iter and iter2dict

This commit is contained in:
Goffi 2015-11-24 23:28:11 +01:00
commit 44ad744c63

View file

@ -49,7 +49,7 @@ class Item(object):
self.title = data.get('title')
self.title_rich = None
self.title_xhtml = data.get('title_xhtml')
self.tags = mbdata2tags(data)
self.tags = list(common.dict2iter('tag', data))
self.content = data.get('content')
self.content_rich = None
self.content_xhtml = data.get('content_xhtml')
@ -261,7 +261,7 @@ class Entry(EntriesManager):
if value is not None:
mb_data[name] = value
mb_data.update(tags2mbdata(self.item.tags))
common.iter2dict('tag', self.item.tags, mb_data)
if self.blog.new_message_target not in (C.PUBLIC, C.GROUP):
raise NotImplementedError
@ -462,15 +462,6 @@ def registerClass(type_, cls):
if COMMENTS_CLS is None:
COMMENTS_CLS = ENTRY_CLS
def mbdata2tags(mb_data):
"""Parse the tags in microblog data.
@param mb_data (dict): microblog data as return by bridge methods
@return list[unicode]
"""
return [tag for key, tag in mb_data.iteritems() if (key == "tag" or key.startswith("tag#")) and tag]
def tags2mbdata(tags):
"""Build from the tags a dict using the microblog data format.