Skip to content
Snippets Groups Projects
Commit 03bd0a9c authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Make sure that the applicant see the draft details on the homepage

parent 4be7db0e
No related branches found
No related tags found
No related merge requests found
from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory
from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory, ApplicationRevisionFactory
from opentech.apply.users.tests.factories import UserFactory
from opentech.apply.utils.tests import BaseViewTestCase
......@@ -14,6 +14,16 @@ class TestApplicantDashboard(BaseViewTestCase):
self.assertContains(response, application.title)
self.assertNotContains(response, 'Submission history')
def test_can_has_draft_titles_on_dashboard(self):
submission = ApplicationSubmissionFactory(user=self.user)
draft_revision = ApplicationRevisionFactory(submission=submission)
submission.draft_revision = draft_revision
submission.save()
response = self.get_page()
self.assertNotContains(response, submission.title)
self.assertContains(response, submission.from_draft().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()
......
......@@ -20,10 +20,18 @@ class ApplicantDashboardView(SingleTableView):
table_class = SubmissionsTable
def get_queryset(self):
return self.model.objects.filter(user=self.request.user).inactive().current()
return self.model.objects.filter(
user=self.request.user
).inactive().current()
def get_context_data(self, **kwargs):
my_active_submissions = self.model.objects.filter(user=self.request.user).active().current()
my_active_submissions = self.model.objects.filter(
user=self.request.user
).active().current().select_related('draft_revision')
my_active_submissions = [
submission.from_draft() for submission in my_active_submissions
]
return super().get_context_data(
my_active_submissions=my_active_submissions,
......
......@@ -168,9 +168,7 @@ class ApplicantSubmissionDetailView(ActivityContextMixin, DelegateableView):
form_views = [CommentFormView]
def get_object(self):
object = super().get_object()
object = object.from_draft()
return object
return super().get_object().from_draft()
def dispatch(self, request, *args, **kwargs):
if self.get_object().user != request.user:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment