diff --git a/opentech/apply/dashboard/templates/dashboard/applicant_dashboard.html b/opentech/apply/dashboard/templates/dashboard/applicant_dashboard.html index a9795e015ec078ce3a1b8cc46b3e16db33b58d95..ee3d6ebc834e6e107415446b6b2f7c77666d867c 100644 --- a/opentech/apply/dashboard/templates/dashboard/applicant_dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/applicant_dashboard.html @@ -28,7 +28,13 @@ </div> {% include "funds/includes/status_bar.html" with phases=submission.workflow current_phase=submission.phase class="status-bar--small" %} {% if request.user|has_edit_perm:submission %} - <a class="button button--primary" href="{% url 'funds:submissions:edit' submission.id %}">Start your {{ submission.stage }} application</a> + <a class="button button--primary" href="{% url 'funds:submissions:edit' submission.id %}"> + {% if submission.status == 'draft_proposal' %} + Start your {{ submission.stage }} application + {% else %} + Edit + {% endif %} + </a> {% endif %} </div> {% empty %} diff --git a/opentech/apply/dashboard/tests/test_views.py b/opentech/apply/dashboard/tests/test_views.py new file mode 100644 index 0000000000000000000000000000000000000000..a6d3514a248b1606089ebcd54e560e65db70fb31 --- /dev/null +++ b/opentech/apply/dashboard/tests/test_views.py @@ -0,0 +1,38 @@ +from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory +from opentech.apply.users.tests.factories import UserFactory +from opentech.apply.utils.tests import BaseViewTestCase + + +class TestApplicantDashboard(BaseViewTestCase): + user_factory = UserFactory + url_name = 'dashboard:{}' + base_view_name = 'dashboard' + + def test_can_access_dashboard_with_active(self): + application = ApplicationSubmissionFactory(user=self.user, form_data__title='Improve the internet') + response = self.get_page() + self.assertContains(response, application.title) + self.assertNotContains(response, 'Submission history') + + def test_can_not_access_other_users_active(self): + application = ApplicationSubmissionFactory(form_data__title='Ruin the internet') + response = self.get_page() + self.assertNotContains(response, application.title) + self.assertNotContains(response, 'Submission history') + + def test_gets_invite_if_invited_to_proposal(self): + ApplicationSubmissionFactory(user=self.user, draft_proposal=True) + response = self.get_page() + self.assertContains(response, 'Start your ') + + def test_no_invite_if_can_edit(self): + ApplicationSubmissionFactory(user=self.user, status='concept_more_info', workflow_stages=2) + response = self.get_page() + self.assertNotContains(response, 'Start your ') + self.assertContains(response, 'Edit', 1) + + def test_no_edit_if_in_review(self): + ApplicationSubmissionFactory(user=self.user, status='internal_review') + response = self.get_page() + self.assertNotContains(response, 'Edit') + self.assertNotContains(response, 'Submission history') diff --git a/opentech/apply/funds/tests/factories/models.py b/opentech/apply/funds/tests/factories/models.py index abef318fc8457979e8e80c6ad01910dc4df83571..dd93ca97e2ead1457a95613634d6600fc28cdffc 100644 --- a/opentech/apply/funds/tests/factories/models.py +++ b/opentech/apply/funds/tests/factories/models.py @@ -186,6 +186,10 @@ class ApplicationSubmissionFactory(factory.DjangoModelFactory): class Params: workflow_stages = 1 + draft_proposal = factory.Trait( + status='draft_proposal', + workflow_name='double', + ) form_fields = blocks.CustomFormFieldsFactory form_data = factory.SubFactory(FormDataFactory, form_fields=factory.SelfAttribute('..form_fields'))