Skip to content
Snippets Groups Projects
Commit 16ea8e61 authored by Dan Braghis's avatar Dan Braghis
Browse files

Simplify URLs

parent fbb9610a
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......
......@@ -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"),
]
......@@ -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)
......
......@@ -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 %}
......
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