def create_pcpp(account, row, issue_map): """Create and save a project (and account). This is a bit more complex for projects, which have goal amounts, etc.""" country_name = row['LOCATION'] country = Country.objects.filter(name__iexact=country_name).first() if not country: logging.getLogger('peacecorps.sync_accounting').warning( "%s: Country does not exist: %s", row['PROJ_NO'], row['LOCATION']) issue = issue_map.find(row['SECTOR']) if not issue and row['SECTOR'] != 'None': logging.getLogger('peacecorps.sync_accounting').warning( "%s: Sector does not exist: %s", row['PROJ_NO'], row['SECTOR']) if country and (issue or row['SECTOR'] == 'None'): set_balances(row, account) account.save() volunteername = row['PCV_NAME'] if volunteername.startswith(row['STATE']): volunteername = volunteername[len(row['STATE']):].strip() summary = clean_description(row['SUMMARY']) sirtrevorobj = {"data": [{"type": "text", "data": {"text": summary}}]} description = json.dumps(sirtrevorobj) project = Project(title=row['PROJ_NAME1'], country=country, account=account, volunteername=volunteername, volunteerhomestate=row['STATE'], description=description) if issue: project.overflow = issue.account project.save() project.campaigns.add(issue) else: project.save()