Exemplo n.º 1
0
def first_post_letter(letter):
    pdfs = []
    pdfs.append(
        utils.render_tex_to_pdf("correspondence/first-post-template.tex",
                                {'letter': letter}))
    # First post, if any.  First post uses a dynamic document rather than the
    # letter.document field, so that if a document is ever removed/unpublished,
    # we get the updated "first post" on printout.
    try:
        document = Document.objects.filter(
            status="published", type="post",
            author__pk=letter.recipient.pk).order_by('date_written')[0]
        pdfs.append(utils.url_to_pdf(document.get_absolute_url()))
    except IndexError:
        pass
    # Profile, if any
    if Document.objects.filter(
            status="published", type="profile",
            author__pk=letter.recipient.pk).order_by('-date_written').exists():
        pdfs.append(
            utils.url_to_pdf(letter.recipient.profile.get_absolute_url()))
    if not pdfs:
        return None

    combined_pdf = utils.combine_pdfs(*pdfs)
    for pdf in pdfs:
        os.remove(pdf)
    return combined_pdf
Exemplo n.º 2
0
def first_post_letter(letter):
    pdfs = []
    pdfs.append(
        utils.render_tex_to_pdf("correspondence/first-post-template.tex", {
            'letter': letter
        })
    )
    # First post, if any.  First post uses a dynamic document rather than the
    # letter.document field, so that if a document is ever removed/unpublished,
    # we get the updated "first post" on printout.
    try:
        document = Document.objects.filter(status="published", type="post",
                author__pk=letter.recipient.pk).order_by('date_written')[0]
        pdfs.append(utils.url_to_pdf(document.get_absolute_url()))
    except IndexError:
        pass
    # Profile, if any
    if Document.objects.filter(status="published", type="profile",
            author__pk=letter.recipient.pk).order_by('-date_written').exists():
        pdfs.append(utils.url_to_pdf(letter.recipient.profile.get_absolute_url()))
    if not pdfs:
        return None

    combined_pdf = utils.combine_pdfs(*pdfs)
    for pdf in pdfs:
        os.remove(pdf)
    return combined_pdf
Exemplo n.º 3
0
def comments_letter(letter):
    pdfs = [
        # cover letter
        utils.render_tex_to_pdf("correspondence/comment-mailing.tex", {"letter": letter}),
        utils.url_to_pdf(reverse("correspondence.recent_comments_letter", args=[letter.pk])),
    ]
    combined_pdf = utils.combine_pdfs(*pdfs)
    for pdf in pdfs:
        os.remove(pdf)
    return combined_pdf
Exemplo n.º 4
0
def comments_letter(letter):
    pdfs = [
        # cover letter
        utils.render_tex_to_pdf("correspondence/comment-mailing.tex",
                                {'letter': letter}),
        utils.url_to_pdf(
            reverse("correspondence.recent_comments_letter", args=[letter.pk]))
    ]
    combined_pdf = utils.combine_pdfs(*pdfs)
    for pdf in pdfs:
        os.remove(pdf)
    return combined_pdf
Exemplo n.º 5
0
def printout(letter):
    return utils.url_to_pdf(letter.document.get_absolute_url())
Exemplo n.º 6
0
def printout(letter):
    return utils.url_to_pdf(letter.document.get_absolute_url())