Пример #1
0
def _remove_fundings(before_list, after_list):
    after_id_list = [f["id"] for f in after_list if f.get("id")]
    for f in before_list:
        if f and f["id"] not in after_id_list:
            f["project_id"] = f.pop("project")
            funding = Funding(**f)
            funding.is_active = False
            funding.save()
Пример #2
0
def _save_fundings(funding_formset, project_id):
    saved_fundings = []
    for funding_form in funding_formset:
        if hasattr(funding_form, "cleaned_data"):
            funding_dict = funding_form.cleaned_data.copy()
            funding = Funding(**funding_dict)
            funding.project_id = project_id
            funding.is_active = True
            funding.save()
            saved_fundings.append(funding_dict)
    return saved_fundings
Пример #3
0
 def test_funding_absolute_url(self):
     '''This tests the title_slug field of a :class:`~projects.models.Funding`.'''
     test_funding = Funding(title='Test Funding', active=True)
     test_funding.save()
     self.assertEqual(test_funding.get_absolute_url(),
                      "/funding/test-funding")
Пример #4
0
 def test_funding_title_slug(self):
     '''This tests the title_slug field of a :class:`~projects.models.Funding`.'''
     test_funding = Funding(title='Test Funding.', active=True)
     test_funding.save()
     self.assertEqual(test_funding.title_slug, "test-funding")
Пример #5
0
 def test_create_new_funding_all(self):
     '''This test creates a `:class:~projects.models.Funding` with the required information only.'''
     test_funding = Funding(title='Test Funding',
                            active=True)  #add more fields
     test_funding.save()
Пример #6
0
 def test_create_new_funding_minimum(self):
     '''This test creates a :class:`~projects.models.Funding` with the required information only.'''
     test_funding = Funding(title='Test Funding.', active=True)
     test_funding.save()
     self.assertEqual(test_funding.pk, 2)
Пример #7
0
 def test_funding_absolute_url(self):
     '''This tests the title_slug field of a :class:`~projects.models.Funding`.'''
     test_funding = Funding(title='Test Funding', active=True)
     test_funding.save()
     self.assertEqual(test_funding.get_absolute_url(), "/funding/test-funding") 
Пример #8
0
 def test_funding_title_slug(self):
     '''This tests the title_slug field of a :class:`~projects.models.Funding`.'''
     test_funding = Funding(title='Test Funding.', active=True)
     test_funding.save()
     self.assertEqual(test_funding.title_slug, "test-funding")  
Пример #9
0
 def test_create_new_funding_all(self):
     '''This test creates a `:class:~projects.models.Funding` with the required information only.'''
     test_funding = Funding(title='Test Funding', active=True) #add more fields
     test_funding.save()        
Пример #10
0
 def test_create_new_funding_minimum(self):
     '''This test creates a :class:`~projects.models.Funding` with the required information only.'''
     test_funding = Funding(title='Test Funding.', active=True)
     test_funding.save()
     self.assertEqual(test_funding.pk, 2)