views.py 731 Bytes
Newer Older
Benoit Alessandroni's avatar
Benoit Alessandroni committed
1 2 3
from djangoldp.views import LDPViewSet
from .models import Resource

4 5 6 7 8 9 10 11 12

class ValidatedResourcesViewSet(LDPViewSet):
  model = Resource

  def get_queryset(self, *args, **kwargs):
    return super().get_queryset(*args, **kwargs)\
          .filter(review__status='validated')\
          .exclude(submitter__username=self.request.user.username)

Benoit Alessandroni's avatar
Benoit Alessandroni committed
13 14 15 16 17
class PendingResourcesViewSet(LDPViewSet):
  model = Resource

  def get_queryset(self, *args, **kwargs):
    return super().get_queryset(*args, **kwargs)\
18
          .filter(review__status='pending', language__in=self.request.user.mentor_profile.languages.all(), fields__in=self.request.user.mentor_profile.fields.all())\
19
          .exclude(submitter__username=self.request.user.username)