Commit 6b2fe8be authored by Benoit Alessandroni's avatar Benoit Alessandroni

Proper filtering by step on validated resources

parent a577fa53
"""djangoldp project URL Configuration"""
from django.conf.urls import url
from .views import PendingResourcesViewSet
from .views import ValidatedResourcesViewSet
from .views import ValidatedResourcesByStepViewSet
urlpatterns = [
url(r'^resources/validated/', ValidatedResourcesViewSet.urls(model_prefix="resources-validated")),
url(r'^steps/(?P<id>.+)/resources/validated/', ValidatedResourcesByStepViewSet.urls(model_prefix="resources-validated")),
url(r'^resources/pending/', PendingResourcesViewSet.urls(model_prefix="resources-pending")),
]
\ No newline at end of file
from djangoldp.views import LDPViewSet
from .models import Resource
from .models import Resource, Step
class ValidatedResourcesViewSet(LDPViewSet):
class ValidatedResourcesByStepViewSet(LDPViewSet):
model = Resource
def get_queryset(self, *args, **kwargs):
step_id = self.kwargs['id']
return super().get_queryset(*args, **kwargs)\
.filter(review__status='validated')\
.filter(steps__in=step_id, review__status='validated')\
.exclude(submitter__username=self.request.user.username)
class PendingResourcesViewSet(LDPViewSet):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment