def renderEvent(event,prev=None): out = StringIO() print >>out, '<div class="event %s" id="event-%d">' % ( event.inbound and 'inbound' or 'outbound', event.id) if event.status: print >>out, '<div class="status stat-%s">%s</div>' % ( event.status, event.status ) dateFormat='<div class="date">%x</div><div class="time">%H:%M</div>' thisTime=timeutil.convert(event.time,tz) if prev: prevTime=timeutil.convert(prev.time,tz) if prevTime.date() == thisTime.date(): dateFormat='<div class="time">%H:%M</div>' print >>out, '<div class="when">%s</div>' % timeutil.convert(event.time,tz).strftime(dateFormat) if event.type == 'voice': if event.call_duration: print >>out, '<div class="call">Call, %d seconds</div>' % event.call_duration else: print >>out, '<div class="call">Call, unknown duration</div>' if event.message_body: text=autolink(sanitize(event.message_body)) print >>out, '<div class="text">%s</div>' % text for attach in event.media: print >>out, '<div class="media">' attachBody = None mimeclass = attach.mime_type.split('/')[0] if mimeclass == 'audio': attachBody = '<audio controls="controls" preload="none"><source src="%s" type="%s"></audio>' % ( attach.url, attach.mime_type) elif mimeclass == 'image': attachBody = '<img src="%s">' % attach.url elif mimeclass == 'video': attachBody = '<video controls="controls"><source src="%s" type="%s"></video>' % ( attach.url, attach.mime_type) if attachBody: print >>out, '<div class="attachbody">%s</div>' % attachBody print >>out, '<div class="desc">' print >>out, '<a class="link" href="%s">original %s</a>' % (attach.url, mimeclass) if attach.duration: print >>out, '<span class="duration">(%d:%02d)</span>' % (int(attach.duration)/60, attach.duration%60) print >>out, '</div>' if attach.transcription: print >>out, '<div class="transcript">%s</div>' % attach.transcription print >>out, '</div>' print >>out, '</div>' return out.getvalue()
def renderEvent(event, prev=None): out = StringIO() print >> out, '<div class="event %s" id="event-%d">' % ( event.inbound and 'inbound' or 'outbound', event.id) if event.status: print >> out, '<div class="status stat-%s">%s</div>' % (event.status, event.status) dateFormat = '<div class="date">%x</div><div class="time">%H:%M</div>' thisTime = timeutil.convert(event.time, tz) if prev: prevTime = timeutil.convert(prev.time, tz) if prevTime.date() == thisTime.date(): dateFormat = '<div class="time">%H:%M</div>' print >> out, '<div class="when">%s</div>' % timeutil.convert( event.time, tz).strftime(dateFormat) if event.type == 'voice': if event.call_duration: print >> out, '<div class="call">Call, %d seconds</div>' % event.call_duration else: print >> out, '<div class="call">Call, unknown duration</div>' if event.message_body: text = autolink(sanitize(event.message_body)) print >> out, '<div class="text">%s</div>' % text for attach in event.media: print >> out, '<div class="media">' attachBody = None mimeclass = attach.mime_type.split('/')[0] if mimeclass == 'audio': attachBody = '<audio controls="controls" preload="none"><source src="%s" type="%s"></audio>' % ( attach.url, attach.mime_type) elif mimeclass == 'image': attachBody = '<img src="%s">' % attach.url elif mimeclass == 'video': attachBody = '<video controls="controls"><source src="%s" type="%s"></video>' % ( attach.url, attach.mime_type) if attachBody: print >> out, '<div class="attachbody">%s</div>' % attachBody print >> out, '<div class="desc">' print >> out, '<a class="link" href="%s">original %s</a>' % ( attach.url, mimeclass) if attach.duration: print >> out, '<span class="duration">(%d:%02d)</span>' % ( int(attach.duration) / 60, attach.duration % 60) print >> out, '</div>' if attach.transcription: print >> out, '<div class="transcript">%s</div>' % attach.transcription print >> out, '</div>' print >> out, '</div>' return out.getvalue()
def renderEvent(event): out = StringIO() print >>out, '<div class="event %s" id="event-%d">' % ( event.inbound and 'inbound' or 'outbound', event.id) if event.status: print >>out, '<div class="status stat-%s">%s</div>' % ( event.status, event.status ) print >>out, '<div class="when">%s</div>' % timeutil.convert(event.time,tz).strftime('%x %H:%M') if event.call_duration: print >>out, '<div class="call">Call, %d seconds</div>' % event.call_duration if event.message_body: print >>out, '<div class="text">%s</div>' % event.message_body for attach in event.media: print >>out, '<div class="media">' attachBody = None mimeclass = attach.mime_type.split('/')[0] if mimeclass == 'audio': attachBody = '<audio controls="controls" preload="none"><source src="%s" type="%s"></audio>' % ( attach.url, attach.mime_type) elif mimeclass == 'image': attachBody = '<img src="%s">' % attach.url elif mimeclass == 'video': attachBody = '<video controls="controls"><source src="%s" type="%s"></video>' % ( attach.url, attach.mime_type) if attachBody: print >>out, '<div class="attachbody">%s</div>' % attachBody print >>out, '<div class="desc">' print >>out, '<a class="link" href="%s">original %s</a>' % (attach.url, mimeclass) if attach.duration: print >>out, '<span class="duration">(%d:%02d)</span>' % (int(attach.duration)/60, attach.duration%60) print >>out, '</div>' if attach.transcription: print >>out, '<div class="transcript">%s</div>' % attach.transcription print >>out, '</div>' print >>out, '</div>' return out.getvalue()
print '<p class="back"><a href=".">Back to inbox</a></p>' print '''<table id="addressbook"> <tr><th colspan="2">Number</th><th>Display Name</th><th colspan="2">Disposition</th><th>Last Event</th></tr> ''' for p in user.peers.order_by(Peer.last_event.desc()): print ''' <tr class="peer" id="peer-{pid}"> <td class="num"><a href=".?p={pid}">{num}</a></td> <td class="loc">{loc}</td> <td class="name"><input type="text" name="name" value="{displayName}" placeholder="Unnamed"></td> <td class="block"><label for="block-{pid}">Block</label> <input type="checkbox" name="blocked" {blockChk} id="block-{pid}"></td> <td class="vm"><label for="vm-{pid}">VM</label> <input type="checkbox" name="vm" {vmChk} id="vm-{pid}"></td> <td class="last">{lastEvent}</td> </tr> '''.format(pid=p.id, num=p.phone_number, loc=render.getPeerLocation(p), displayName=p.display_name or '', blockChk=p.blocked and 'checked="1"' or '', vmChk=p.send_to_voicemail and 'checked="1"' or '', lastEvent=p.last_event and timeutil.convert(p.last_event,tz).strftime('%x %H:%M') ) print ''' </table> </body> </html> '''
print '<p class="back"><a href=".">Back to inbox</a></p>' print '''<table id="addressbook"> <tr><th colspan="2">Number</th><th>Display Name</th><th colspan="2">Disposition</th><th>Last Event</th></tr> ''' for p in user.peers.order_by(Peer.last_event.desc()): print ''' <tr class="peer" id="peer-{pid}"> <td class="num"><a href=".?p={pid}">{num}</a></td> <td class="loc">{loc}</td> <td class="name"><input type="text" name="name" value="{displayName}" placeholder="Unnamed"></td> <td class="block"><label for="block-{pid}">Block</label> <input type="checkbox" name="blocked" {blockChk} id="block-{pid}"></td> <td class="vm"><label for="vm-{pid}">VM</label> <input type="checkbox" name="vm" {vmChk} id="vm-{pid}"></td> <td class="last">{lastEvent}</td> </tr> '''.format(pid=p.id, num=p.phone_number, loc=render.getPeerLocation(p), displayName=p.display_name or '', blockChk=p.blocked and 'checked="1"' or '', vmChk=p.send_to_voicemail and 'checked="1"' or '', lastEvent=p.last_event and timeutil.convert(p.last_event, tz).strftime('%x %H:%M')) print ''' </table> </body> </html> '''