Skip to content

Commit

Permalink
resolved error in 404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
janekg89 committed Mar 15, 2022
1 parent c590bb7 commit ec76cf5
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 19 deletions.
1 change: 1 addition & 0 deletions backend/pkdb_app/data/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class SubSetDocument(Document):
def get_queryset(self):
"""Not mandatory but to improve performance we can select related in one sql request"""
return super(SubSetDocument, self).get_queryset().prefetch_related("data_points__outputs")

class Django:
model = SubSet
# Ignore auto updating of Elasticsearch when a model is saved/deleted
Expand Down
21 changes: 17 additions & 4 deletions backend/pkdb_app/data/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from django.utils.decorators import method_decorator
from django_elasticsearch_dsl_drf.constants import LOOKUP_QUERY_IN, LOOKUP_QUERY_EXCLUDE
from django_elasticsearch_dsl_drf.filter_backends import (
FilteringFilterBackend,
IdsFilterBackend,
MultiMatchSearchFilterBackend
)
from pkdb_app.documents import AccessView
from django_elasticsearch_dsl_drf.viewsets import BaseDocumentViewSet
from drf_yasg.utils import swagger_auto_schema
from rest_framework.views import APIView

from pkdb_app.documents import AccessView, UUID_PARAM
from pkdb_app.data.documents import DataAnalysisDocument, SubSetDocument
from pkdb_app.data.serializers import DataAnalysisSerializer, SubSetElasticSerializer, TimecourseSerializer

Expand All @@ -17,6 +22,7 @@ class DataAnalysisViewSet(AccessView):
serializer_class = DataAnalysisSerializer
pagination_class = CustomPagination
lookup_field = "id"
ignore = [404]
filter_backends = [FilteringFilterBackend, IdsFilterBackend, MultiMatchSearchFilterBackend]
search_fields = (
'study_sid',
Expand Down Expand Up @@ -52,18 +58,20 @@ class DataAnalysisViewSet(AccessView):
},
}


class SubSetViewSet(AccessView):
@method_decorator(name='list', decorator=swagger_auto_schema(manual_parameters=[UUID_PARAM]))
class SubSetViewSet(BaseDocumentViewSet, APIView):
""" Endpoint to query subsets (timecourses and scatters)
The subets endpoint gives access to the subset data. A Subset is a collection of outputs which can be either a
timecourse or scatter. A timecourse subset consists of outputs measured at different time points. A scatter subset
contains correlated data which commonly are displayed as scatter plots.
"""
#document_uid_field = "id"
lookup_field = "id"
ignore = [404]
document = SubSetDocument
serializer_class = SubSetElasticSerializer
pagination_class = CustomPagination
lookup_field = "id"
filter_backends = [FilteringFilterBackend, IdsFilterBackend, MultiMatchSearchFilterBackend]
search_fields = (
"name",
Expand All @@ -84,6 +92,11 @@ class SubSetViewSet(AccessView):
"name": "name.raw",
"data_type": "data_type.raw"
}
@swagger_auto_schema(responses={200: SubSetElasticSerializer(many=False)})
def get_object(self):
""" Test """
return super().get_object()

class TimecourseViewSet(AccessView):
""" Endpoint to query timecourses
Expand Down
1 change: 1 addition & 0 deletions backend/pkdb_app/info_nodes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_serializer(self, *args, **kwargs):
class InfoNodeElasticViewSet(BaseDocumentViewSet):
pagination_class = CustomPagination
document = InfoNodeDocument
ignore = [404]
serializer_class = InfoNodeElasticSerializer
document_uid_field = "sid__raw"
lookup_field = 'sid'
Expand Down
1 change: 1 addition & 0 deletions backend/pkdb_app/interventions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ElasticInterventionViewSet(AccessView):
serializer_class = InterventionElasticSerializer
pagination_class = CustomPagination
lookup_field = "id"
ignore = [404]
filter_backends = [FilteringFilterBackend, IdsFilterBackend, OrderingFilterBackend, MultiMatchSearchFilterBackend]
search_fields = (
'name',
Expand Down
2 changes: 2 additions & 0 deletions backend/pkdb_app/outputs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class OutputInterventionViewSet(AccessView):
serializer_class = OutputInterventionSerializer
pagination_class = CustomPagination
lookup_field = "id"
ignore = [404]
filter_backends = [FilteringFilterBackend, IdsFilterBackend, OrderingFilterBackend, MultiMatchSearchFilterBackend]
search_fields = (
'study',
Expand Down Expand Up @@ -82,6 +83,7 @@ class ElasticOutputViewSet(AccessView):
This includes more complex results which cannot be directly measured but are calculated from the measured data.
In the outputs related subjects and interventions are referenced.
"""
ignore = [404]
document = OutputDocument
serializer_class = OutputElasticSerializer
pagination_class = CustomPagination
Expand Down
2 changes: 2 additions & 0 deletions backend/pkdb_app/subjects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class GroupViewSet(AccessView):
"""
document = GroupDocument
serializer_class = GroupElasticSerializer
ignore = [404]
lookup_field = 'id'
filter_backends = [FilteringFilterBackend, IdsFilterBackend, OrderingFilterBackend, MultiMatchSearchFilterBackend]
pagination_class = CustomPagination
Expand Down Expand Up @@ -89,6 +90,7 @@ class IndividualViewSet(AccessView):
document = IndividualDocument
serializer_class = IndividualElasticSerializer
lookup_field = 'id'
ignore = [404]
filter_backends = [FilteringFilterBackend, IdsFilterBackend, OrderingFilterBackend, MultiMatchSearchFilterBackend]
pagination_class = CustomPagination
search_fields = (
Expand Down
2 changes: 0 additions & 2 deletions backend/pkdb_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
from rest_framework.authentication import TokenAuthentication
from pkdb_app.users.permissions import get_study_file_permission
from .subjects.models import DataFile

from drf_yasg.generators import OpenAPISchemaGenerator


def serve_protected_document(request, file):
try:
user, _ = TokenAuthentication().authenticate(request=request)
Expand Down
29 changes: 16 additions & 13 deletions frontend/src/components/Page404.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<template>
<v-row align="start"
justify="center">
<v-col sm="12" md="10" lg="8">
<v-container v-if="!loading" fluid>
<v-row align="start"
justify="center">
<v-col sm="12" md="10" lg="8">

<h1>404 <code><strong v-if="this.prevRoute">{{ this.prevRoute.path }}</strong></code></h1>
<p>
Page <code><strong v-if="this.prevRoute">{{ this.prevRoute.path }}</strong></code> not found or no access to page as
<code>
<strong v-if="this.$store.state.username">{{ this.$store.state.username }}</strong>
<strong v-else>anonymous</strong>
</code> user.
</p>
</v-col>
</v-row>
<h1>404 <code><strong v-if="this.prevRoute">{{ this.prevRoute.path }}</strong></code></h1>
<p>
Page <code><strong v-if="this.prevRoute">{{ this.prevRoute.path }}</strong></code> not found or no access to page as
<code>
<strong v-if="this.$store.state.username">{{ this.$store.state.username }}</strong>
<strong v-else>anonymous</strong>
</code> user.
</p>
</v-col>

</v-row>
</v-container>
</template>

<script>
Expand Down

0 comments on commit ec76cf5

Please sign in to comment.