diff --git a/opentech/apply/determinations/tests/test_views.py b/opentech/apply/determinations/tests/test_views.py index 7535f13e1a53a45eff997e0daa9f693e45cfa673..7840bb015b53e2298ae0cd700d4f0f16de3b90e1 100644 --- a/opentech/apply/determinations/tests/test_views.py +++ b/opentech/apply/determinations/tests/test_views.py @@ -36,7 +36,7 @@ class StaffDeterminationsTestCase(BaseTestCase): url_name = 'funds:submissions:determinations:{}' def get_kwargs(self, instance): - return {'pk': instance.id, 'submission_pk': instance.submission.id} + return {'submission_pk': instance.submission.id} def test_can_access_determination(self): submission = ApplicationSubmissionFactory(status='in_discussion') diff --git a/opentech/apply/determinations/urls.py b/opentech/apply/determinations/urls.py index c2729057f2f4d7237de745716c995acd36beb7c8..532222e6788cbc227ebd545f13715dd1387e672e 100644 --- a/opentech/apply/determinations/urls.py +++ b/opentech/apply/determinations/urls.py @@ -5,6 +5,6 @@ from .views import DeterminationCreateOrUpdateView, DeterminationDetailView app_name = 'determinations' urlpatterns = [ - path('determination/', DeterminationCreateOrUpdateView.as_view(), name="form"), - path('determination/<int:pk>', DeterminationDetailView.as_view(), name="detail"), + path('determination/', DeterminationDetailView.as_view(), name="detail"), + path('determination/create', DeterminationCreateOrUpdateView.as_view(), name="form"), ] diff --git a/opentech/apply/determinations/views.py b/opentech/apply/determinations/views.py index b108b39fb3d3773502a54233e764083f3b170d85..350ea62a5cbc4fa781536b94ed70e18166dc0c57 100644 --- a/opentech/apply/determinations/views.py +++ b/opentech/apply/determinations/views.py @@ -45,7 +45,7 @@ class DeterminationCreateOrUpdateView(CreateOrUpdateView): template_name = 'determinations/determination_form.html' def get_object(self, queryset=None): - return self.model.objects.get(submission=self.submission, author=self.request.user) + return self.model.objects.get(submission=self.submission) def dispatch(self, request, *args, **kwargs): self.submission = get_object_or_404(ApplicationSubmission, id=self.kwargs['submission_pk']) @@ -101,16 +101,19 @@ class DeterminationCreateOrUpdateView(CreateOrUpdateView): class DeterminationDetailView(DetailView): model = Determination + def get_object(self, queryset=None): + return self.model.objects.get(submission=self.submission) + def dispatch(self, request, *args, **kwargs): + self.submission = get_object_or_404(ApplicationSubmission, id=self.kwargs['submission_pk']) determination = self.get_object() - submission = determination.submission if request.user != submission.user and request.user != submission.lead \ and not request.user.is_apply_staff and not request.user.is_superuser: raise PermissionDenied if determination.is_draft: - return HttpResponseRedirect(reverse_lazy('apply:submissions:determinations:form', args=(submission.id,))) + return HttpResponseRedirect(reverse_lazy('apply:submissions:determinations:form', args=(self.submission.id,))) return super().dispatch(request, *args, **kwargs) diff --git a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html index c41ca5a8df9b570298be0630e8e7a9b00471976c..9c9041fa56a843ebbc5e5ba0775fa88036483576 100644 --- a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html +++ b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html @@ -95,7 +95,7 @@ {% if object|pending_determination:request.user %} <p>Pending</p> {% else %} - <a href="{% url 'apply:submissions:determinations:detail' pk=object.determination.id submission_pk=object.id %}">{{ object.determination.get_outcome_display }}</a> + <a href="{% url 'apply:submissions:determinations:detail' submission_pk=object.id %}">{{ object.determination.get_outcome_display }}</a> {{ object.determination.updated_at|date:"Y-m-d" }} by {{ object.determination.author }} {% endif %} {% endif %}