def build_scores_sheet_attachment(list_exam_enrollments): name = "%s.pdf" % _('score(s) saved') mimetype = "application/pdf" content = paper_sheet.build_pdf( score_encoding_sheet.scores_sheet_data(list_exam_enrollments, tutor=None)) return (name, content, mimetype)
def print_scores(global_id): json_document = get_score_sheet(global_id) if json_document: document = json.loads(json_document) try: paper_sheet.validate_data_structure(document) return paper_sheet.build_pdf(document) except (KeyError, voluptuous_error.Invalid): trace = traceback.format_exc() logger.error(trace) logger.warning("A document could not be produced from the json document of the global id {0}".format(global_id)) else: logger.warning("A json document for the global id {0} doesn't exist.".format(global_id)) return None
def print_scores(request, global_id): logger.debug("Searching document in couchbase (global id = " + global_id + ")") document = mdl.score_encoding.get_document(global_id) document = document.value if document else None if document: logger.debug("Document found") now = datetime.datetime.now() now_str = '%s/%s/%s' % (now.day, now.month, now.year) if document.get('publication_date', None) != now_str: document = get_score_sheet(global_id) else: logger.debug("No document found in couchbase") document = get_score_sheet(global_id) if document: logger.debug("Calling build_pdf() method to generate the pdf...") return paper_sheet.build_pdf(document) else: return None
def print_scores(request, global_id): document = get_score_sheet(global_id) if document: document = json.loads(document) return paper_sheet.build_pdf(document) return None