def genComments(self, proposal): # Need to fetch some comments from the PST DB pst = PstInterface() reviews = pst.getProposalTechnicalReviews(proposal.pcode) ps = ParagraphStyle(name = 'Heading1', fontSize = 10, leading = 16) sciComment = proposal.comments.srp_to_pi if proposal.comments is not None else '' sciComment = sciComment.replace('\n\n', '<br/><br/>') if sciComment is not None else '' contents = [Paragraph('<b>Scientific Ratings</b>', ps) , self.pg(sciComment) , Paragraph('<b>Technical Ratings</b>', ps) ] reviewStyle = ParagraphStyle(name = 'Review', fontSize = 8, leftIndent = 20) reviewStyle2 = ParagraphStyle(name = 'Review', fontSize = 8, leftIndent = 40) for tech4Auth, tech4Tac, refF, refL in reviews: rf, rl = '', '' if refF is not None and refL is not None: rf, rl = refF[0], refL[0] contents.extend( [Paragraph('<b>Ref</b> %s%s' % (rf, rl), reviewStyle) , Paragraph(tech4Auth.replace('\n', '<br/>'), reviewStyle2) , Paragraph('<b>To Selection Committee</b>', reviewStyle) , Paragraph(tech4Tac.replace('\n', '<br/>'), reviewStyle2) ]) nraoComment = (proposal.comments.nrao_comment if proposal.comments is not None else '') or '' contents.extend([Paragraph('<b>NRAO Comments</b>', ps) , Paragraph(nraoComment, reviewStyle) ]) return contents
class ProposalWorksheet(Report): def __init__(self, filename): self.filename = filename self.pstInterface = PstInterface() super(ProposalWorksheet, self).__init__(filename, orientation = 'portrait') def genHeader(self, proposal): pi_name = proposal.pi.getLastFirstName() if proposal.pi is not None else '' joint = 'J' if proposal.joint_proposal else '' students = len(proposal.author_set.filter(thesis_observing = True)) related = self.pstInterface.getRelatedProposals(proposal) or '' related = self.truncateStr(related, 70) content = [[self.pg('<b>%s</b>' % proposal.pcode) , self.pg(pi_name) , self.pg('%s - %s' % (proposal.requestedTime(), proposal.bands())) , self.pg(proposal.title) ], [self.pg('') , self.pg('') , self.pg('S: %i %s' % (students, joint)) , self.pg(related) , self.pg(''.join([o.code for o in proposal.observing_types.all()])) ]] proposalHeader = Table(content, colWidths = [50, 75, 50, 300, 50]) proposalHeader.setStyle(self.tableStyle) data = [proposalHeader] data.extend([self.getBreak()] * 10) return data def reports(self, semester, filter = None): filter = filter or defaultFilter proposals = [p for p in Proposal.objects.filter(semester__semester = semester).order_by('pcode') if filter(p)] contents = [] for header in map(self.genHeader, proposals): contents.extend(header) self.doc.build(contents , onFirstPage = self.makeFooter , onLaterPages = self.makeFooter) def report(self, proposal): contents = self.genHeader(proposal) self.doc.build(contents , onFirstPage = self.makeFooter , onLaterPages = self.makeFooter) def makeFooter(self, canvas, doc): pass
def __init__(self, filename): self.filename = filename self.pstInterface = PstInterface() super(ProposalWorksheet, self).__init__(filename, orientation = 'portrait')