def generate(self): self.document.merge( city=self.school.city, date=DateConverter.to_string(self.contract_date, "%d.%m.%Y"), no=str(self.contract_no), year=str(self.contract_year), semester=self.program.get_current_semester(), name=self.school.name, address=self.school.address, nip=self.school.nip, regon=self.school.regon, representant=self.school.responsible_person if not self.ommit_representat else FILL_BY_SCHOOL, email=self.school.email, program_start_date=DateConverter.to_string(self.program.start_date, "%d.%m.%Y"), program_end_date=DateConverter.to_string(self.program.end_date, "%d.%m.%Y"), nip_additional=self.school.representative_nip if self.school.representative_nip else "-", name_additional=self.school.representative if self.school.representative else "-", regon_additional=self.school.representative_regon if self.school.representative_regon else "-", giving_weeks=ContractCreator._preapre_str_from_weeks( DatabaseManager.get_weeks(self.program.id))) doc_contract_name = "Umowa_{0}_{1}.docx".format( self.contract_no, self.contract_year) created_doc_name = DocumentCreator.generate(self, doc_contract_name) doc_contract_name_copy = path.join( self.main_contract_dir, "{0}_Umowa_{1}_{2}.docx".format(self.school.nick, self.contract_no, self.contract_year)) try: DocumentCreator.copy_to_path(created_doc_name, doc_contract_name_copy) # DocumentCreator.copy_to_path(created_doc_name.replace("docx", "pdf"), doc_contract_name_copy.replace("docx", "pdf")) #TODO problem with generating pdf numbering is wrong except: app.logger.error("Could not copy files [%s]", created_doc_name)
def generate(self): self.document.merge( city=self.school.city, current_date=self.contract_date.strftime("%d.%m.%Y"), contract_no=str(self.contract_no.split("_")[0]), contract_year=str(self.contract_year), semester_no=self.program.get_current_semester(), school_year=self.program.school_year, name=self.school.name, address=self.school.address, nip=self.school.nip, regon=self.school.regon, responsible_person=self.school.responsible_person, fruitveg_products=str(self.fruitVeg_products), dairy_products=str(self.dairy_products), validity_date=self.validity_date.strftime("%d.%m.%Y")) created_annex = DocumentCreator.generate( self, "Aneks_" + self.contract_date.strftime("%d_%m_%Y") + ".docx") new_annex_dst = path.join( config_parser.get('Directories', 'annex_all'), "{0}_Aneks_{1}_{2}.docx".format(self.school.nick, self.contract_no, self.contract_year)) DocumentCreator.copy_to_path(created_annex, new_annex_dst)