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 %}
|
||||
|
||||
<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>
|
||||
<summary>
|
||||
<h4>Filter</h4>
|
||||
@@ -19,7 +26,6 @@
|
||||
</form>
|
||||
</div>
|
||||
</details> {% endcomment %}
|
||||
View my <a href='{% url "atlas:case_view" %}?author={{request.user.id}}'>cases</a>.
|
||||
{% render_table table %}
|
||||
{% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}
|
||||
</div>
|
||||
|
||||
+61
-1
@@ -40,6 +40,7 @@ from .tables import ResourceTable
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.urls.exceptions import NoReverseMatch
|
||||
|
||||
from django.http import Http404, JsonResponse
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
@@ -2119,6 +2120,17 @@ class ConditionView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleT
|
||||
|
||||
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):
|
||||
model = QuestionSchema
|
||||
@@ -2135,6 +2147,16 @@ class SubspecialtyView(LoginRequiredMixin, UserConfigurablePaginationMixin, Sing
|
||||
|
||||
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):
|
||||
model = Presentation
|
||||
@@ -2143,6 +2165,16 @@ class PresentationView(LoginRequiredMixin, UserConfigurablePaginationMixin, Sing
|
||||
|
||||
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):
|
||||
model = PathologicalProcess
|
||||
@@ -2151,6 +2183,16 @@ class PathologicalProcessView(LoginRequiredMixin, UserConfigurablePaginationMixi
|
||||
|
||||
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):
|
||||
model = Structure
|
||||
@@ -2159,6 +2201,16 @@ class StructureView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleT
|
||||
|
||||
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):
|
||||
model = Finding
|
||||
@@ -2167,6 +2219,14 @@ class FindingView(LoginRequiredMixin, UserConfigurablePaginationMixin, SingleTab
|
||||
|
||||
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
|
||||
def case_order_dicom(request, pk):
|
||||
@@ -2527,7 +2587,7 @@ def categories_search_partial(request):
|
||||
class CollectionView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
||||
model = CaseCollection
|
||||
table_class = CaseCollectionTable
|
||||
template_name = "atlas/view.html"
|
||||
template_name = "atlas/collection_view.html"
|
||||
|
||||
filterset_class = CaseCollectionFilter
|
||||
|
||||
|
||||
Reference in New Issue
Block a user