diff --git a/.circleci/config.yml b/.circleci/config.yml index c7e509566aa9c0e0e10654b6b9c6ff7a49a98a18..5d1ba29917f4ab96e42e18e0a1bb8b3e8bcf83cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,7 +13,6 @@ jobs: PGUSER: root DJANGO_SETTINGS_MODULE: opentech.settings.test SEND_MESSAGES: false - PROJECTS_ENABLED: true - image: circleci/postgres:10.5 environment: diff --git a/.travis.yml b/.travis.yml index d2e18cf9fb607c1b6fb6e0318197728cc780363d..3a9983e245c3b1b21cb284eeedf40771ddd90916 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,6 @@ env: global: - DJANGO_SETTINGS_MODULE=opentech.settings.test - DATABASE_URL=postgres://postgres@localhost/test_db - - PROJECTS_ENABLED=true before_script: # Create a database diff --git a/opentech/apply/determinations/tests/test_views.py b/opentech/apply/determinations/tests/test_views.py index 9adff7a7f4139ab3f621dcd4a80078f5df312036..070836f7630d109033cdfcf6ba6d648924acbf07 100644 --- a/opentech/apply/determinations/tests/test_views.py +++ b/opentech/apply/determinations/tests/test_views.py @@ -2,7 +2,7 @@ import urllib from django.contrib.messages.storage.fallback import FallbackStorage from django.contrib.sessions.middleware import SessionMiddleware -from django.test import RequestFactory +from django.test import override_settings, RequestFactory from django.urls import reverse_lazy from opentech.apply.activity.models import Activity @@ -88,6 +88,7 @@ class DeterminationFormTestCase(BaseViewTestCase): response = self.get_page(submission, 'form') self.assertNotContains(response, 'Update ') + @override_settings(PROJECTS_ENABLED=False) def test_can_edit_draft_determination_if_not_lead(self): submission = ApplicationSubmissionFactory(status='in_discussion') determination = DeterminationFactory(submission=submission, author=self.user, accepted=True) @@ -95,6 +96,13 @@ class DeterminationFormTestCase(BaseViewTestCase): self.assertContains(response, 'Approved') self.assertRedirects(response, self.absolute_url(submission.get_absolute_url())) + def test_can_edit_draft_determination_if_not_lead_with_projects(self): + submission = ApplicationSubmissionFactory(status='in_discussion') + determination = DeterminationFactory(submission=submission, author=self.user, accepted=True) + response = self.post_page(submission, {'data': 'value', 'outcome': determination.outcome}, 'form') + self.assertContains(response, 'Approved') + self.assertRedirects(response, self.absolute_url(submission.get_absolute_url())) + def test_sends_message_if_requires_more_info(self): submission = ApplicationSubmissionFactory(status='in_discussion', lead=self.user) determination = DeterminationFactory(submission=submission, author=self.user) diff --git a/opentech/apply/determinations/views.py b/opentech/apply/determinations/views.py index bee9a188bf0199a9e07d018d525b00d01385a9f9..5cb56920c88ccff6cad55bbf5f5c8916cd84c654 100644 --- a/opentech/apply/determinations/views.py +++ b/opentech/apply/determinations/views.py @@ -267,13 +267,14 @@ class DeterminationCreateOrUpdateView(CreateOrUpdateView): if self.submission.accepted_for_funding: project = Project.create_from_submission(self.submission) - messenger( - MESSAGES.CREATED_PROJECT, - request=self.request, - user=self.request.user, - source=project, - related=project.submission, - ) + if project: + messenger( + MESSAGES.CREATED_PROJECT, + request=self.request, + user=self.request.user, + source=project, + related=project.submission, + ) messenger( MESSAGES.DETERMINATION_OUTCOME, diff --git a/opentech/settings/test.py b/opentech/settings/test.py index 11a71f78e5248d8568b15eaf0f8d0ca00ff70acd..3d6102ba8bff38edc37cef28a368432054de92c1 100644 --- a/opentech/settings/test.py +++ b/opentech/settings/test.py @@ -8,6 +8,8 @@ from .base import * # noqa SECRET_KEY = 'NOT A SECRET' +PROJECTS_ENABLED = True + # Need this to ensure white noise doesn't kill the speed of testing # http://whitenoise.evans.io/en/latest/django.html#whitenoise-makes-my-tests-run-slow WHITENOISE_AUTOREFRESH = True