.
This commit is contained in:
@@ -46,6 +46,37 @@ def get_series(request):
|
|||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
class CaseCollectionFilter(django_filters.FilterSet):
|
||||||
|
author = django_filters.ModelMultipleChoiceFilter(
|
||||||
|
queryset=get_authors, null_label="No author"
|
||||||
|
)
|
||||||
|
cases = django_filters.ModelMultipleChoiceFilter(
|
||||||
|
queryset=get_cases, null_label="No cases"
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Case
|
||||||
|
fields = (
|
||||||
|
"archive",
|
||||||
|
"author",
|
||||||
|
) # "site",
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
data=None,
|
||||||
|
queryset=None,
|
||||||
|
prefix=None,
|
||||||
|
strict=None,
|
||||||
|
user=None,
|
||||||
|
request=None,
|
||||||
|
):
|
||||||
|
if not request.user.groups.filter(name="atlas_editor").exists():
|
||||||
|
queryset = queryset.prefetch_related("author").filter(author__id=request.user.id)
|
||||||
|
super(CaseCollectionFilter, self).__init__(
|
||||||
|
data=data, queryset=queryset, prefix=prefix, request=request
|
||||||
|
)
|
||||||
|
pass
|
||||||
|
|
||||||
class CaseFilter(django_filters.FilterSet):
|
class CaseFilter(django_filters.FilterSet):
|
||||||
author = django_filters.ModelMultipleChoiceFilter(
|
author = django_filters.ModelMultipleChoiceFilter(
|
||||||
queryset=get_authors, null_label="No author"
|
queryset=get_authors, null_label="No author"
|
||||||
|
|||||||
@@ -313,3 +313,43 @@ class SubspecialtyTable(tables.Table):
|
|||||||
def render_synonym(self, value, record):
|
def render_synonym(self, value, record):
|
||||||
return format_html(record.get_synonym_link())
|
return format_html(record.get_synonym_link())
|
||||||
return f"{record.get_synonym_link()}"
|
return f"{record.get_synonym_link()}"
|
||||||
|
|
||||||
|
class CaseCollectionTable(tables.Table):
|
||||||
|
edit = tables.LinkColumn(
|
||||||
|
"atlas:collection_update", text="Edit", args=[A("pk")], orderable=False
|
||||||
|
)
|
||||||
|
view = tables.LinkColumn(
|
||||||
|
"atlas:collection_view", text="View", args=[A("pk")], orderable=False
|
||||||
|
)
|
||||||
|
#clone = tables.LinkColumn(
|
||||||
|
# "atlas:case_clone", text="Clone", args=[A("pk")], orderable=False
|
||||||
|
#)
|
||||||
|
delete = tables.LinkColumn(
|
||||||
|
"atlas:collection_delete", text="Delete", args=[A("pk")], orderable=False
|
||||||
|
)
|
||||||
|
#series = AtlasImageColumn("Images", orderable=False)
|
||||||
|
|
||||||
|
#differential = tables.ManyToManyColumn(verbose_name="Differential")
|
||||||
|
|
||||||
|
selection = tables.CheckBoxColumn(accessor="pk", orderable=False)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Case
|
||||||
|
template_name = "django_tables2/bootstrap4.html"
|
||||||
|
fields = (
|
||||||
|
"name",
|
||||||
|
"collection_type",
|
||||||
|
"publish_results",
|
||||||
|
"active",
|
||||||
|
"author",
|
||||||
|
)
|
||||||
|
sequence = ("view", )#, "series")
|
||||||
|
|
||||||
|
def __init__(self, data=None, *args, **kwargs):
|
||||||
|
super().__init__(
|
||||||
|
data.prefetch_related(
|
||||||
|
#"condition", "condition__synonym"
|
||||||
|
),
|
||||||
|
*args,
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
@@ -19,7 +19,7 @@ Atlas:
|
|||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
<a href="{% url 'atlas:case_view' %}">Cases</a> /
|
<a href="{% url 'atlas:case_view' %}">Cases</a> /
|
||||||
<a href="{% url 'atlas:series_view' %}">Series</a> /
|
<a href="{% url 'atlas:series_view' %}">Series</a> /
|
||||||
<a href="{% url 'atlas:collection_index_view' %}">Collections</a> /
|
<a href="{% url 'atlas:collection_view' %}">Collections</a> /
|
||||||
<a href="{% url 'atlas:categories_list' %}">Categories</a> /
|
<a href="{% url 'atlas:categories_list' %}">Categories</a> /
|
||||||
<a href="{% url 'atlas:case_create' %}" title="Create a new atlas case">Create Case</a> /
|
<a href="{% url 'atlas:case_create' %}" title="Create a new atlas case">Create Case</a> /
|
||||||
<a href="{% url 'atlas:series_create' %}" title="Create a new image series">Create Series</a>
|
<a href="{% url 'atlas:series_create' %}" title="Create a new image series">Create Series</a>
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ urlpatterns = [
|
|||||||
path("author/<int:pk>/", views.author_detail, name="author_detail"),
|
path("author/<int:pk>/", views.author_detail, name="author_detail"),
|
||||||
path("author/", views.author_list, name="author_list"),
|
path("author/", views.author_list, name="author_list"),
|
||||||
path("case/", views.CaseView.as_view(), name="case_view"),
|
path("case/", views.CaseView.as_view(), name="case_view"),
|
||||||
path("collection/", views.collection_index_view, name="collection_index_view"),
|
path("collection/", views.CollectionView.as_view(), name="collection_view"),
|
||||||
path("collection/create", views.CaseCollectionCreate.as_view(), name="collection_create"),
|
path("collection/create", views.CaseCollectionCreate.as_view(), name="collection_create"),
|
||||||
path("collection/<int:pk>/delete", views.CaseCollectionDelete.as_view(), name="collection_delete"),
|
path("collection/<int:pk>/delete", views.CaseCollectionDelete.as_view(), name="collection_delete"),
|
||||||
path("collection/<int:pk>/update", views.CaseCollectionUpdate.as_view(), name="collection_update"),
|
path("collection/<int:pk>/update", views.CaseCollectionUpdate.as_view(), name="collection_update"),
|
||||||
|
|||||||
+14
-6
@@ -60,7 +60,9 @@ from .models import (
|
|||||||
SeriesImage,
|
SeriesImage,
|
||||||
)
|
)
|
||||||
from .tables import (
|
from .tables import (
|
||||||
|
CaseCollectionTable,
|
||||||
CaseTable,
|
CaseTable,
|
||||||
|
CollectionTable,
|
||||||
ConditionTable,
|
ConditionTable,
|
||||||
FindingTable,
|
FindingTable,
|
||||||
PathologicalProcessTable,
|
PathologicalProcessTable,
|
||||||
@@ -308,7 +310,7 @@ class SeriesDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
|
|||||||
class CaseCollectionDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
|
class CaseCollectionDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
|
||||||
model = CaseCollection
|
model = CaseCollection
|
||||||
template_name = "confirm_delete.html"
|
template_name = "confirm_delete.html"
|
||||||
success_url = reverse_lazy("atlas:collection_index_view")
|
success_url = reverse_lazy("atlas:collection_view")
|
||||||
|
|
||||||
class ConditionDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
|
class ConditionDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
|
||||||
model = Condition
|
model = Condition
|
||||||
@@ -1041,12 +1043,18 @@ def categories_list(request):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def collection_index_view(request):
|
#def collection_view(request):
|
||||||
collections = CaseCollection.objects.all()
|
# collections = CaseCollection.objects.all()
|
||||||
|
#
|
||||||
|
# return render(
|
||||||
|
# request, "atlas/collection_view.html", {"collections": collections}
|
||||||
|
# )
|
||||||
|
class CollectionView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
||||||
|
model = CaseCollection
|
||||||
|
table_class = CaseCollectionTable
|
||||||
|
template_name = "atlas/view.html"
|
||||||
|
|
||||||
return render(
|
filterset_class = CollectionFilter
|
||||||
request, "atlas/collection_index_view.html", {"collections": collections}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def collection_detail_view(request, pk):
|
def collection_detail_view(request, pk):
|
||||||
|
|||||||
Reference in New Issue
Block a user