def alter_draft_files(draft, file_values): """ file_values list should match this order: ['demographics', 'funding_sources', 'budget1', 'budget2', 'budget3', 'project_budget_file', 'fiscal_letter'] """ files = dict(zip(DraftGrantApplication.file_fields(), file_values)) for key, val in files.iteritems(): setattr(draft, key, val) draft.save()
def alter_draft_files(draft, file_values): """ Helper method to update draft's file fields Args: file_values: list, should match this order: ['demographics', 'funding_sources', 'budget1', 'budget2', 'budget3', 'project_budget_file', 'fiscal_letter'] """ files = dict(zip(DraftGrantApplication.file_fields(), file_values)) for key, val in files.iteritems(): setattr(draft, key, val) draft.save()
def test_start_conflicting_drafts(self): a_pk = 1 b_pk = 2 # a has no apps - rules out conflict over apps self.assert_count(GrantApplication.objects.filter(organization_id=a_pk), 0) # b has draft; create draft for same cycle for a self.assert_count( DraftGrantApplication.objects.filter(organization_id=b_pk, grant_cycle_id=2), 1) draft = DraftGrantApplication(organization_id=a_pk, grant_cycle_id=2) draft.save() post_data = { 'action': 'merge', '_selected_action': [1, 2] } res = self.client.post(self.admin_url, post_data, follow=True) self.assertTemplateUsed(res, 'admin/grants/organization/change_list.html') self.assert_message(res, r'same grant cycle. Cannot be automatically merged.$', regex=True)