def save_model(self, request, newsletter, form, change):
        newsletter.save()
        workgroups = []
        if not newsletter.pk and not request.user.is_superuser \
               and USE_WORKGROUPS:
            workgroups = request_workgroups(request)

#        if newsletter.content.startswith('http://'):
#            if CAN_USE_PREMAILER:
#                try:
#                    premailer = Premailer(newsletter.content.strip())
#                    newsletter.content = premailer.transform()
#                except PremailerError:
#                    self.message_user(request, _('Unable to download HTML, due to errors within.'))
#            else:
#                self.message_user(request, _('Please install lxml for parsing an URL.'))
        clusters = Cluster.objects.filter(publish=True).exclude(id='services')
        quote = Quote.objects.order_by('?')[0]
        smlinks = Socialmedialink.objects.all()
        context = {'newsletter': newsletter,
                    'domain': Site.objects.get_current().domain,
                    'CLUSTERS':clusters,
                    'QUOTE':quote,
                    'SOCIALMEDIALINKS':smlinks,
                    'location':Location.objects.get(town='amsterdam'),
                    'YEAR': datetime.now().year,
                    'MEDIA_URL': settings.MEDIA_URL,}
        newsletter.content = get_content(newsletter, context)
        newsletter.save()

        if not request.user.has_perm('newsletter.can_change_status'):
            newsletter.status = form.initial.get('status', Newsletter.DRAFT)

        for workgroup in workgroups:
            workgroup.newsletters.add(newsletter)
def render_newsletter(request, slug, context):
    """Return a newsletter in HTML format"""
    newsletter = get_object_or_404(Newsletter, slug=slug)
    clusters = Cluster.objects.filter(publish=True).exclude(id='services')
    quote = Quote.objects.order_by('?')[0]
    smlinks = Socialmedialink.objects.all()
    context.update({'newsletter': newsletter,
                    'domain': Site.objects.get_current().domain,
                    'CLUSTERS':clusters,
                    'QUOTE':quote,
                    'SOCIALMEDIALINKS':smlinks,
                    'location':Location.objects.get(town='amsterdam'),
                    'YEAR': datetime.now().year,
                    'MEDIA_URL': settings.MEDIA_URL,})

    content = get_content(newsletter, context)
    #content = render_string(newsletter.content, context)
    title = render_string(newsletter.title, context)
    if TRACKING_LINKS:
        content = track_links(content, context)
    unsubscription = render_file('newsletter/newsletter_link_unsubscribe.html', context)
    content = insert_tag(content, 'span', 'unsubscribe', unsubscription)
    subscription = render_file('newsletter/newsletter_link_subscribe.html', context)
    content = insert_tag(content, 'span', 'subscribe', subscription)

    return render_to_response('includes/newsletter/newsletter_wrapper.html',
                              {'content': content,
                               'title': title,
                               'object': newsletter,
                               'CLUSTERS': clusters,},
                              context_instance=RequestContext(request))