Refactor collection view: create a new template for collections with improved layout and staff action visibility
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
{% extends 'atlas/base.html' %}
|
||||||
|
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="d-flex align-items-start justify-content-between mb-3">
|
||||||
|
<h2 class="mb-0">Collections</h2>
|
||||||
|
{% if request.user.is_staff %}
|
||||||
|
<a class="btn btn-sm btn-primary" href="{% url 'atlas:exam_create' %}">Create collection</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="mb-3">Manage and browse case collections. Use filters to narrow results.</p>
|
||||||
|
|
||||||
|
{% render_table table %}
|
||||||
|
|
||||||
|
{% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -7,7 +7,14 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<h2>My Collections</h2>
|
<div class="d-flex align-items-start justify-content-between">
|
||||||
|
<h2 class="mb-0">{{ model_verbose_name_plural|capfirst }}</h2>
|
||||||
|
{% if request.user.is_staff and create_url %}
|
||||||
|
<div>
|
||||||
|
<a class="btn btn-sm btn-primary" href="{{ create_url }}">Add new {{ model_verbose_name }}</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% comment %} <details>
|
{% comment %} <details>
|
||||||
<summary>
|
<summary>
|
||||||
<h4>Filter</h4>
|
<h4>Filter</h4>
|
||||||
@@ -19,7 +26,6 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</details> {% endcomment %}
|
</details> {% endcomment %}
|
||||||
View my <a href='{% url "atlas:case_view" %}?author={{request.user.id}}'>cases</a>.
|
|
||||||
{% render_table table %}
|
{% render_table table %}
|
||||||
{% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}
|
{% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+61
-1
@@ -40,6 +40,7 @@ from .tables import ResourceTable
|
|||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
from django.urls import reverse_lazy, reverse
|
from django.urls import reverse_lazy, reverse
|
||||||
|
from django.urls.exceptions import NoReverseMatch
|
||||||
|
|
||||||
from django.http import Http404, JsonResponse
|
from django.http import Http404, JsonResponse
|
||||||
from django.http import HttpResponseRedirect, HttpResponse
|
from django.http import HttpResponseRedirect, HttpResponse
|
||||||
@@ -2119,6 +2120,17 @@ class ConditionView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleT
|
|||||||
|
|
||||||
filterset_class = ConditionFilter
|
filterset_class = ConditionFilter
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
ctx = super().get_context_data(**kwargs)
|
||||||
|
try:
|
||||||
|
ctx["create_url"] = reverse(f"atlas:{self.model._meta.model_name}_create")
|
||||||
|
except NoReverseMatch:
|
||||||
|
ctx["create_url"] = None
|
||||||
|
# Provide verbose names to templates without accessing _meta in templates
|
||||||
|
ctx["model_verbose_name"] = getattr(self.model._meta, "verbose_name", None)
|
||||||
|
ctx["model_verbose_name_plural"] = getattr(self.model._meta, "verbose_name_plural", None)
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
class QuestionSchemaView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
class QuestionSchemaView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
||||||
model = QuestionSchema
|
model = QuestionSchema
|
||||||
@@ -2135,6 +2147,16 @@ class SubspecialtyView(LoginRequiredMixin, UserConfigurablePaginationMixin, Sing
|
|||||||
|
|
||||||
filterset_class = SubspecialtyFilter
|
filterset_class = SubspecialtyFilter
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
ctx = super().get_context_data(**kwargs)
|
||||||
|
try:
|
||||||
|
ctx["create_url"] = reverse(f"atlas:{self.model._meta.model_name}_create")
|
||||||
|
except NoReverseMatch:
|
||||||
|
ctx["create_url"] = None
|
||||||
|
ctx["model_verbose_name"] = getattr(self.model._meta, "verbose_name", None)
|
||||||
|
ctx["model_verbose_name_plural"] = getattr(self.model._meta, "verbose_name_plural", None)
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
class PresentationView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
class PresentationView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
||||||
model = Presentation
|
model = Presentation
|
||||||
@@ -2143,6 +2165,16 @@ class PresentationView(LoginRequiredMixin, UserConfigurablePaginationMixin, Sing
|
|||||||
|
|
||||||
filterset_class = PresentationFilter
|
filterset_class = PresentationFilter
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
ctx = super().get_context_data(**kwargs)
|
||||||
|
try:
|
||||||
|
ctx["create_url"] = reverse(f"atlas:{self.model._meta.model_name}_create")
|
||||||
|
except NoReverseMatch:
|
||||||
|
ctx["create_url"] = None
|
||||||
|
ctx["model_verbose_name"] = getattr(self.model._meta, "verbose_name", None)
|
||||||
|
ctx["model_verbose_name_plural"] = getattr(self.model._meta, "verbose_name_plural", None)
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
class PathologicalProcessView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
class PathologicalProcessView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
||||||
model = PathologicalProcess
|
model = PathologicalProcess
|
||||||
@@ -2151,6 +2183,16 @@ class PathologicalProcessView(LoginRequiredMixin, UserConfigurablePaginationMixi
|
|||||||
|
|
||||||
filterset_class = PathologicalProcessFilter
|
filterset_class = PathologicalProcessFilter
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
ctx = super().get_context_data(**kwargs)
|
||||||
|
try:
|
||||||
|
ctx["create_url"] = reverse(f"atlas:{self.model._meta.model_name}_create")
|
||||||
|
except NoReverseMatch:
|
||||||
|
ctx["create_url"] = None
|
||||||
|
ctx["model_verbose_name"] = getattr(self.model._meta, "verbose_name", None)
|
||||||
|
ctx["model_verbose_name_plural"] = getattr(self.model._meta, "verbose_name_plural", None)
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
class StructureView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
class StructureView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
||||||
model = Structure
|
model = Structure
|
||||||
@@ -2159,6 +2201,16 @@ class StructureView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleT
|
|||||||
|
|
||||||
filterset_class = StructureFilter
|
filterset_class = StructureFilter
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
ctx = super().get_context_data(**kwargs)
|
||||||
|
try:
|
||||||
|
ctx["create_url"] = reverse(f"atlas:{self.model._meta.model_name}_create")
|
||||||
|
except NoReverseMatch:
|
||||||
|
ctx["create_url"] = None
|
||||||
|
ctx["model_verbose_name"] = getattr(self.model._meta, "verbose_name", None)
|
||||||
|
ctx["model_verbose_name_plural"] = getattr(self.model._meta, "verbose_name_plural", None)
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
class FindingView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
class FindingView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTableMixin, FilterView):
|
||||||
model = Finding
|
model = Finding
|
||||||
@@ -2167,6 +2219,14 @@ class FindingView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTab
|
|||||||
|
|
||||||
filterset_class = FindingFilter
|
filterset_class = FindingFilter
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
ctx = super().get_context_data(**kwargs)
|
||||||
|
try:
|
||||||
|
ctx["create_url"] = reverse(f"atlas:{self.model._meta.model_name}_create")
|
||||||
|
except NoReverseMatch:
|
||||||
|
ctx["create_url"] = None
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def case_order_dicom(request, pk):
|
def case_order_dicom(request, pk):
|
||||||
@@ -2527,7 +2587,7 @@ def categories_search_partial(request):
|
|||||||
class CollectionView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
class CollectionView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
||||||
model = CaseCollection
|
model = CaseCollection
|
||||||
table_class = CaseCollectionTable
|
table_class = CaseCollectionTable
|
||||||
template_name = "atlas/view.html"
|
template_name = "atlas/collection_view.html"
|
||||||
|
|
||||||
filterset_class = CaseCollectionFilter
|
filterset_class = CaseCollectionFilter
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user