def test_clean_description(self): """Clean description replaces bad bytes and BRs""" text = '!@#$%^&*()_+1234567890-=' self.assertEqual(sync.clean_description(text), '!@#$%^&*()_+1234567890-=') text = "Darwin\u00c2\u00bfs Bulldog" self.assertEqual(sync.clean_description(text), "Darwin's Bulldog") text = "\n\r\nSome<BR><br /></BR>Text" self.assertEqual(sync.clean_description(text), "\n\r\nSome\n\nText")
def clean(apps, schema_editor): """Cleans the description field for imported projects/funds""" for campaign in apps.get_model("peacecorps", "Campaign").objects.all(): campaign.description = clean_description(campaign.description) campaign.description = re.sub(r"(?<!\\)\n", r"\\n", campaign.description) campaign.save() for project in apps.get_model("peacecorps", "Project").objects.all(): project.description = clean_description(project.description) project.description = re.sub(r"(?<!\\)\n", r"\\n", project.description) project.save()