Пример #1
0
    def write_pdf(self, response):
        from dashboard.letters import OfficialLetter, MemoContents, LetterContents

        # record the fact that it was generated (for editability checking)
        self.config['pdf_generated'] = True
        self.save()

        doc = OfficialLetter(response, unit=self.unit)
        if self.is_letter:
            l = LetterContents(to_addr_lines=self.to_lines.split("\n"),
                               from_name_lines=self.from_lines.split("\n"),
                               date=self.sent_date,
                               cc_lines=self.cc_lines.split("\n"),
                               )
        else:
            l = MemoContents(to_addr_lines=self.to_lines.split("\n"),
                             from_name_lines=self.from_lines.split("\n"),
                             date=self.sent_date,
                             subject=self.subject.split("\n"),
                             cc_lines=self.cc_lines.split("\n"),
                             )
        content_lines = self.memo_text.split("\n\n")
        l.add_paragraphs(content_lines)
        doc.add_letter(l)
        doc.write()
Пример #2
0
def letter(request, ra_slug):
    appointment = get_object_or_404(RAAppointment, slug=ra_slug, deleted=False)
    response = HttpResponse(content_type="application/pdf")
    response['Content-Disposition'] = 'inline; filename="%s-letter.pdf"' % (
        appointment.slug)
    letter = OfficialLetter(response, unit=appointment.unit)
    contents = LetterContents(
        to_addr_lines=[
            appointment.person.name(), 'c/o ' + appointment.unit.name
        ],
        from_name_lines=[
            appointment.hiring_faculty.first_name + " " +
            appointment.hiring_faculty.last_name, appointment.unit.name
        ],
        closing="Yours Truly",
        signer=appointment.hiring_faculty,
        cosigner_lines=[
            'I agree to the conditions of employment',
            appointment.person.first_name + " " + appointment.person.last_name
        ])
    contents.add_paragraphs([
        "Dear " + appointment.person.get_title() + ' ' +
        appointment.person.last_name
    ])
    contents.add_paragraphs(appointment.letter_paragraphs())
    letter.add_letter(contents)
    letter.write()
    return response
Пример #3
0
    def write_pdf(self, response):
        from dashboard.letters import OfficialLetter, MemoContents, LetterContents

        # record the fact that it was generated (for editability checking)
        self.config['pdf_generated'] = True
        self.save()

        doc = OfficialLetter(response, unit=self.unit)
        if self.is_letter:
            l = LetterContents(to_addr_lines=self.to_lines.split("\n"),
                               from_name_lines=self.from_lines.split("\n"),
                               date=self.sent_date,
                               cc_lines=self.cc_lines.split("\n"),
                               )
        else:
            l = MemoContents(to_addr_lines=self.to_lines.split("\n"),
                             from_name_lines=self.from_lines.split("\n"),
                             date=self.sent_date,
                             subject=self.subject.split("\n"),
                             cc_lines=self.cc_lines.split("\n"),
                             )
        content_lines = self.memo_text.split("\n\n")
        l.add_paragraphs(content_lines)
        doc.add_letter(l)
        doc.write()
Пример #4
0
def sample_letter():
    to_addr_lines = ['Some Person', '123 Fake St', 'Vancouver, BC, Canada']
    from_name_lines = ['Greg Baker', 'Lecturer, School of Computing Science']
    signer = Person.objects.get(userid="ggbaker")
    letter = LetterContents(to_addr_lines=to_addr_lines, from_name_lines=from_name_lines, signer=signer)
    letter.add_paragraphs(paragraphs(random.randint(5,15)))
    return letter
Пример #5
0
def get_letter(request, grad_slug, letter_slug):
    grad, authtype, units = _can_view_student(request, grad_slug)
    if grad is None or authtype == 'student':
        return ForbiddenResponse(request)
    letter = get_object_or_404(Letter,
                               slug=letter_slug,
                               student=grad,
                               student__program__unit__in=units)
    response = HttpResponse(content_type="application/pdf")
    response['Content-Disposition'] = 'inline; filename="%s.pdf"' % (
        letter_slug)

    doc = OfficialLetter(response, unit=letter.student.program.unit)
    l = LetterContents(to_addr_lines=letter.to_lines.split("\n"),
                       from_name_lines=letter.from_lines.split("\n"),
                       date=letter.date,
                       closing=letter.closing,
                       signer=letter.from_person,
                       use_sig=letter.use_sig(),
                       body_font_size=letter.template.body_font_size())
    content_lines = letter.content.split("\n\n")
    l.add_paragraphs(content_lines)
    doc.add_letter(l)
    doc.write()
    return response
Пример #6
0
def letter(request, ra_slug):
    appointment = get_object_or_404(RAAppointment, slug=ra_slug, deleted=False)
    response = HttpResponse(content_type="application/pdf")
    response['Content-Disposition'] = 'inline; filename="%s-letter.pdf"' % (appointment.slug)
    letter = OfficialLetter(response, unit=appointment.unit)
    contents = LetterContents(
        to_addr_lines=[appointment.person.name(), 'c/o '+appointment.unit.name], 
        from_name_lines=[appointment.hiring_faculty.first_name + " " + appointment.hiring_faculty.last_name, appointment.unit.name], 
        closing="Yours Truly", 
        signer=appointment.hiring_faculty,
        cosigner_lines=['I agree to the conditions of employment', appointment.person.first_name + " " + appointment.person.last_name])
    contents.add_paragraphs(["Dear " + appointment.person.get_title() + ' ' + appointment.person.last_name])
    contents.add_paragraphs(appointment.letter_paragraphs())
    letter.add_letter(contents)
    letter.write()
    return response
Пример #7
0
def get_letter(request, grad_slug, letter_slug):
    letter = get_object_or_404(Letter, slug=letter_slug, student__slug=grad_slug, student__program__unit__in=request.units)
    response = HttpResponse(content_type="application/pdf")
    response['Content-Disposition'] = 'inline; filename="%s.pdf"' % (letter_slug)

    doc = OfficialLetter(response, unit=letter.student.program.unit)
    l = LetterContents(to_addr_lines=letter.to_lines.split("\n"), 
                        from_name_lines=letter.from_lines.split("\n"), 
                        date=letter.date, 
                        closing=letter.closing, 
                        signer=letter.from_person,
                        use_sig=letter.use_sig())
    content_lines = letter.content.split("\n\n")
    l.add_paragraphs(content_lines)
    doc.add_letter(l)
    doc.write() 
    return response
Пример #8
0
def letter(request, ra_slug):
    appointment = get_object_or_404(RAAppointment,
                                    slug=ra_slug,
                                    deleted=False,
                                    unit__in=request.units)
    if not appointment.offer_letter_text:
        letter_choices = RAAppointment.letter_choices(request.units)
        if len(letter_choices) == 1:  # why make them select from one?
            appointment.build_letter_text(letter_choices[0][0])
        else:
            return HttpResponseRedirect(
                reverse('ra:select_letter',
                        kwargs=({
                            'ra_slug': ra_slug,
                            'print_only': 'print'
                        })))
    response = HttpResponse(content_type="application/pdf")
    response['Content-Disposition'] = 'inline; filename="%s-letter.pdf"' % (
        appointment.slug)
    letter = OfficialLetter(response, unit=appointment.unit)
    contents = LetterContents(
        to_addr_lines=[
            appointment.person.name(), 'c/o ' + appointment.unit.name
        ],
        from_name_lines=[
            appointment.hiring_faculty.first_name + " " +
            appointment.hiring_faculty.last_name, appointment.unit.name
        ],
        closing="Yours Truly",
        signer=appointment.hiring_faculty,
        cosigner_lines=[
            'I agree to the conditions of employment',
            appointment.person.first_name + " " + appointment.person.last_name
        ])
    contents.add_paragraphs([
        "Dear " + appointment.person.get_title() + ' ' +
        appointment.person.last_name
    ])
    contents.add_paragraphs(appointment.letter_paragraphs())
    letter.add_letter(contents)
    letter.write()
    return response
Пример #9
0
def get_letter(request, grad_slug, letter_slug):
    letter = get_object_or_404(Letter,
                               slug=letter_slug,
                               student__slug=grad_slug,
                               student__program__unit__in=request.units)
    response = HttpResponse(content_type="application/pdf")
    response['Content-Disposition'] = 'inline; filename="%s.pdf"' % (
        letter_slug)

    doc = OfficialLetter(response, unit=letter.student.program.unit)
    l = LetterContents(to_addr_lines=letter.to_lines.split("\n"),
                       from_name_lines=letter.from_lines.split("\n"),
                       date=letter.date,
                       closing=letter.closing,
                       signer=letter.from_person,
                       use_sig=letter.use_sig())
    content_lines = letter.content.split("\n\n")
    l.add_paragraphs(content_lines)
    doc.add_letter(l)
    doc.write()
    return response
Пример #10
0
def get_letter(request, grad_slug, letter_slug):
    grad, authtype, units = _can_view_student(request, grad_slug)
    if grad is None or authtype == 'student':
        return ForbiddenResponse(request)
    letter = get_object_or_404(Letter, slug=letter_slug, student=grad, student__program__unit__in=units)
    response = HttpResponse(content_type="application/pdf")
    response['Content-Disposition'] = 'inline; filename="%s.pdf"' % (letter_slug)

    doc = OfficialLetter(response, unit=letter.student.program.unit)
    l = LetterContents(to_addr_lines=letter.to_lines.split("\n"), 
                       from_name_lines=letter.from_lines.split("\n"),
                       date=letter.date,
                       closing=letter.closing,
                       signer=letter.from_person,
                       use_sig=letter.use_sig(),
                       body_font_size=letter.template.body_font_size())
    content_lines = letter.content.split("\n\n")
    l.add_paragraphs(content_lines)
    doc.add_letter(l)
    doc.write() 
    return response
Пример #11
0
def letter(request, ra_slug):
    appointment = get_object_or_404(RAAppointment, slug=ra_slug, deleted=False, unit__in=request.units)
    if not appointment.offer_letter_text:
        letter_choices = RAAppointment.letter_choices(request.units)
        if len(letter_choices) == 1:  # why make them select from one?
            appointment.build_letter_text(letter_choices[0][0])
        else:
            return HttpResponseRedirect(reverse('ra:select_letter', kwargs=({'ra_slug': ra_slug, 'print_only': 'print'})))
    response = HttpResponse(content_type="application/pdf")
    response['Content-Disposition'] = 'inline; filename="%s-letter.pdf"' % (appointment.slug)
    letter = OfficialLetter(response, unit=appointment.unit)
    contents = LetterContents(
        to_addr_lines=[appointment.person.name(), 'c/o '+appointment.unit.name], 
        from_name_lines=[appointment.hiring_faculty.first_name + " " + appointment.hiring_faculty.last_name, appointment.unit.name], 
        closing="Yours Truly", 
        signer=appointment.hiring_faculty,
        cosigner_lines=['I agree to the conditions of employment', appointment.person.first_name + " " + appointment.person.last_name])
    contents.add_paragraphs(["Dear " + appointment.person.get_title() + ' ' + appointment.person.last_name])
    contents.add_paragraphs(appointment.letter_paragraphs())
    letter.add_letter(contents)
    letter.write()
    return response