-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/status board #708
base: develop
Are you sure you want to change the base?
Feature/status board #708
Changes from 14 commits
3d213d2
7c3f6bc
1f356d9
346130f
bf05254
6f8a5aa
4edb803
64f959b
1dea184
a2da011
fcdf94e
aabb219
f876dd5
b1200f1
3db1a1c
abb2126
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
from api.serializers import BaseShareSerializer | ||
from api.views.share import ShareObjectViewSet | ||
|
||
|
||
|
||
app_name = 'api' | ||
|
||
router = DefaultRouter() | ||
|
@@ -86,6 +88,8 @@ def register_url(self, subclass, viewset): | |
register_route(r'rawdata', views.RawDatumViewSet) | ||
register_route(r'user', views.ShareUserViewSet) | ||
register_route(r'sources', views.SourceViewSet) | ||
register_route(r'HarvestLog', views.HarvestLogViewSet) | ||
register_route(r'SourceConfig', views.SourceConfigViewSet) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these routes should be snake case and plural ( |
||
|
||
router.register(r'normalizeddata', views.NormalizedDataViewSet, base_name='normalizeddata') | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
from .registration import * # noqa | ||
from .schema import * # noqa | ||
from .banner import * # noqa | ||
from .harvestlogs import * # noqa | ||
from .sourceConfig import * # noqa | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename these files: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from rest_framework import viewsets | ||
from rest_framework import filters | ||
from django_filters.filters import MultipleChoiceFilter | ||
from api.views import ShareObjectViewSet | ||
from share.util import IDObfuscator | ||
|
||
from api.serializers import HarvestLogSerializer | ||
from share.models import HarvestLog | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. import ordering from most broadly available to most specific:
|
||
|
||
class SourceConfigFilterBackend(MultipleChoiceFilter): | ||
def filter_queryset(self, request, queryset, view, conjoined=True): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
if 'source_config_id' in request.GET: | ||
decoded = IDObfuscator.decode_id(request.GET['source_config_id']) | ||
queryset = queryset.filter(source_config_id=decoded) | ||
if 'status' in request.GET: | ||
queryset = queryset.filter(status__in=request.GET.getlist('status')) | ||
return queryset | ||
|
||
class HarvestLogViewSet(ShareObjectViewSet): | ||
serializer_class = HarvestLogSerializer | ||
queryset = HarvestLog.objects.all() | ||
filter_backends = (SourceConfigFilterBackend, ) | ||
filter_fields = ('source_config_id', 'status',) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,13 +28,15 @@ class ShareObjectViewSet(viewsets.ReadOnlyModelViewSet): | |
|
||
# Override get_queryset to handle items marked as deleted. | ||
def get_queryset(self, list=True): | ||
# import ipdb; ipdb.set_trace() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete |
||
queryset = super().get_queryset() | ||
if list and hasattr(queryset.model, 'is_deleted'): | ||
return queryset.exclude(is_deleted=True) | ||
return queryset | ||
|
||
# Override to convert encoded pk to an actual pk | ||
def get_object(self): | ||
import ipdb; ipdb.set_trace() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete delete |
||
queryset = self.filter_queryset(self.get_queryset(False)) | ||
|
||
# Perform the lookup filtering. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from rest_framework import viewsets | ||
from api.views import ShareObjectViewSet | ||
from rest_framework import filters | ||
from api.serializers import SourceConfigSerializer | ||
from share.models import SourceConfig | ||
from api.pagination import FuzzyPageNumberPagination | ||
from django.db.models import Count | ||
from django.db.models import Aggregate | ||
from share.models import HarvestLog | ||
from django.db.models import OuterRef, Subquery | ||
from django.db.models import IntegerField | ||
|
||
class SourceConfigViewSet(ShareObjectViewSet): | ||
serializer_class = SourceConfigSerializer | ||
pagination_class = FuzzyPageNumberPagination | ||
queryset = SourceConfig.objects.all() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ | |
from api.pagination import CursorPagination | ||
from api.authentication import APIV1TokenBackPortAuthentication | ||
from api.permissions import ReadOnlyOrTokenHasScopeOrIsAuthenticated | ||
from api.serializers import FullNormalizedDataSerializer, BasicNormalizedDataSerializer, \ | ||
RawDatumSerializer, ShareUserSerializer, SourceSerializer | ||
from api.serializers import FullNormalizedDataSerializer, BasicNormalizedDataSerializer,RawDatumSerializer, ShareUserSerializer, SourceSerializer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a space! |
||
|
||
from share.models import RawDatum, NormalizedData, Source, SourceConfig, Transformer, ShareUser | ||
from share.tasks import disambiguate | ||
from share.harvest.serialization import DictSerializer | ||
|
@@ -56,6 +56,7 @@ class SourceViewSet(viewsets.ReadOnlyModelViewSet): | |
def get_queryset(self): | ||
return Source.objects.exclude(icon='').exclude(is_deleted=True) | ||
|
||
|
||
def create(self, request, *args, **kwargs): | ||
try: | ||
long_title = request.data['long_title'] | ||
|
@@ -129,6 +130,7 @@ def create(self, request, *args, **kwargs): | |
) | ||
|
||
|
||
|
||
class NormalizedDataViewSet(viewsets.ModelViewSet): | ||
"""View showing all normalized data in the SHARE Dataset. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all the
from share.models
imports, just usefrom share import models
(and update existing things to match)