def render(self, name, value, attrs=None): if value is None: return super(EMailListWidget,self).render(name,value,attrs) l = value.split() gl = mail.chunks(l,5) lines = [] for g in gl: lines.append(u', '.join(g)) value = u'\n'.join(lines) return super(EMailListWidget,self).render(name,value,attrs)
def show(request, el_id): el = EMailList.get_by_id(int(el_id)) if el is None: raise Http404 gsize = 40 if request.method == 'POST': form = EmailShowForm(request.POST) if form.is_valid(): gsize = form.cleaned_data['gsize'] else: gsize = None else: form = EmailShowForm() if gsize: emails = el.emails emails = sorted(list(set(emails))) ecount = len(emails) if gsize>0: groups = mail.chunks(emails,gsize) else: groups = [emails] else: emails=None groups=None ecount=None return render_to_response('admin/email_show.html', RequestContext(request, { 'form':form, 'el': el, 'list': emails, 'groups': groups, 'count': ecount, }))