Refactor collection view: create a new template for collections with improved layout and staff action visibility
This commit is contained in:
+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