Skip to content

Commit

Permalink
Simplify urls of accessing tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
medihack committed Dec 13, 2023
1 parent 480d8f2 commit 74f3dfc
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 27 deletions.
2 changes: 1 addition & 1 deletion adit/batch_query/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def clean(self) -> None:
return super().clean()

def get_absolute_url(self):
return reverse("batch_query_task_detail", args=[self.job.id, self.id])
return reverse("batch_query_task_detail", args=[self.id])


class BatchQueryResult(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion adit/batch_query/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
name="batch_query_result_download",
),
path(
"jobs/<int:job_id>/tasks/<int:task_id>/",
"tasks/<int:pk>/",
BatchQueryTaskDetailView.as_view(),
name="batch_query_task_detail",
),
Expand Down
2 changes: 1 addition & 1 deletion adit/batch_transfer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ class BatchTransferTask(TransferTask):
lines = ArrayField(models.PositiveSmallIntegerField())

def get_absolute_url(self):
return reverse("batch_transfer_task_detail", args=[self.job.id, self.id])
return reverse("batch_transfer_task_detail", args=[self.id])
2 changes: 1 addition & 1 deletion adit/batch_transfer/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
name="batch_transfer_job_verify",
),
path(
"jobs/<int:job_id>/tasks/<int:task_id>/",
"tasks/<int:pk>/",
BatchTransferTaskDetailView.as_view(),
name="batch_transfer_task_detail",
),
Expand Down
2 changes: 1 addition & 1 deletion adit/core/templates/core/admin_section.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h5>Job Overview</h5>
<h5>Admin Tools</h5>
<ul class="list-group">
<li class="list-group-item">
<a href="{% url "broadcast" %}">Send Email to all users</a>
<a href="{% url 'broadcast' %}">Send Email to all users</a>
</li>
<!-- djlint:off D018 -->
<li class="list-group-item">
Expand Down
19 changes: 1 addition & 18 deletions adit/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
)
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import SuspiciousOperation
from django.db.models import Model
from django.db.models.query import QuerySet
from django.forms import Form, ModelForm
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect, render
from django.shortcuts import redirect, render
from django.urls import re_path, reverse_lazy
from django.views.generic import View
from django.views.generic.base import TemplateView
Expand Down Expand Up @@ -410,22 +409,6 @@ def get_queryset(self):
return self.model.objects.all()
return self.model.objects.filter(job__owner=self.request.user)

def get_object(self, queryset: QuerySet | None = None) -> Model:
if queryset is None:
queryset = self.get_queryset()

job_id = self.kwargs.get("job_id")
task_id = self.kwargs.get("task_id")

if job_id is None or task_id is None:
raise AttributeError(
f"Dicom task detail view {self.__class__.__name__} must "
"be called with a job_id and a task_id in the URLconf."
)

queryset = queryset.filter(job_id=job_id, id=task_id)
return get_object_or_404(queryset)

def get_context_data(self, **kwargs) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
context["job_url_name"] = self.job_url_name
Expand Down
2 changes: 1 addition & 1 deletion adit/selective_transfer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ class SelectiveTransferTask(TransferTask):
)

def get_absolute_url(self):
return reverse("selective_transfer_task_detail", args=[self.job.id, self.id])
return reverse("selective_transfer_task_detail", args=[self.id])
2 changes: 1 addition & 1 deletion adit/selective_transfer/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
name="selective_transfer_job_restart",
),
path(
"jobs/<int:job_id>/tasks/<int:task_id>/",
"tasks/<int:pk>/",
SelectiveTransferTaskDetailView.as_view(),
name="selective_transfer_task_detail",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h5>Existing tokens</h5>
<td>{{ token.expires|default_if_none:"Never" }}</td>
<td>{{ token.last_used|default_if_none:"Never" }}</td>
<td>
<form action="{% url "delete_token" token.pk %}" method="post">
<form action="{% url 'delete_token' token.pk %}" method="post">
{% csrf_token %}
<button type="submit" class="btn btn-danger btn-sm" aria-label="Delete token">{% bootstrap_icon "trash" %}</button>
</form>
Expand All @@ -77,7 +77,7 @@ <h5>No generated tokens</h5>
<!-- Form to generate new tokens -->
<div style="margin-top: 40px;">
<h5>Generate a new token</h5>
<form action={% url "token_dashboard" %} method="post">
<form action="{% url 'token_dashboard' %}" method="post">
{% csrf_token %}
{% crispy form %}
</form>
Expand Down

0 comments on commit 74f3dfc

Please sign in to comment.