Mercurial > libervia-web
diff browser_side/panels.py @ 119:a8d11fdea090
microblog avatar update
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 06 Jul 2011 03:03:07 +0200 |
parents | c64b00f31461 |
children | 054b7b3424a3 |
line wrap: on
line diff
--- a/browser_side/panels.py Wed Jul 06 03:01:55 2011 +0200 +++ b/browser_side/panels.py Wed Jul 06 03:03:07 2011 +0200 @@ -474,24 +474,32 @@ class MicroblogEntry(SimplePanel): - def __init__(self, mblog_entry): + def __init__(self, host, mblog_entry): SimplePanel.__init__(self) + self.author = mblog_entry.author _datetime = datetime.fromtimestamp(mblog_entry.timestamp) - panel = HTMLPanel(""" - <div class="mb_entry_avatar"><img src="%(avatar)s" alt="%(author)s" /></div> + self.panel = HTMLPanel(""" + <div class="mb_entry_avatar" id='id_avatar'></div> <div class="mb_entry_dialog"> <p class="bubble">%(body)s</p> </div> <div class='mb_entry_timestamp'>%(timestamp)s</div> - """ % {"avatar": "/media/misc/empty_avatar", - "author": html_sanitize(mblog_entry.author), + """ % {"author": html_sanitize(self.author), "timestamp": _datetime, "body": html_sanitize(mblog_entry.content) }) - panel.setStyleName('mb_entry') - self.add(panel) + self.avatar = Image(host.getAvatar(self.author)) + self.panel.add(self.avatar, "id_avatar") + self.panel.setStyleName('mb_entry') + self.add(self.panel) + + def updateAvatar(self, new_avatar): + """Change the avatar of the entry + @param new_avatar: path to the new image""" + self.avatar.setUrl(new_avatar) + class MicroblogPanel(LiberviaWidget): @@ -517,10 +525,20 @@ @param date: when the entry was written""" if mblog_entry.id in self.entries: return - _entry = MicroblogEntry(mblog_entry) + _entry = MicroblogEntry(self.host, mblog_entry) self.entries[mblog_entry.id] = _entry self.vpanel.insert(_entry,0) + def updateValue(self, type, jid, value): + """Update a jid value in entries + @param type: one of 'avatar', 'nick' + @param jid: jid concerned + @param value: new value""" + if type=='avatar': + for entry in self.entries.values(): + if entry.author == jid: + entry.updateAvatar(value) + def setAcceptedGroup(self, group): """Set the group which can be displayed in this panel @param group: string of the group, or list of string