akvo.rest.viewsets module
- class akvo.rest.viewsets.BaseRSRViewSet(**kwargs)[source]
Bases:
ModelViewSet
Base class used for the view sets for RSR models. Provides unified auth and perms settings.
- authentication_classes = (<class 'rest_framework.authentication.SessionAuthentication'>, <class 'akvo.rest.authentication.TastyTokenAuthentication'>, <class 'akvo.rest.authentication.JWTAuthentication'>)
- filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'akvo.rest.filters.RSRGenericFilterBackend'>)
- filter_queryset(queryset)[source]
Given a queryset, filter it with whichever filter backend is in use.
You are unlikely to want to override this method, although you may need to call it either from a list view, or from a custom get_object method if you want to apply the configured filtering backend to the default queryset.
- ordering_fields = '__all__'
- permission_classes = (<class 'akvo.rest.viewsets.SafeMethodsPermissions'>,)
- class akvo.rest.viewsets.PublicProjectViewSet(**kwargs)[source]
Bases:
BaseRSRViewSet
Only public projects or objects related to public projects will be shown.
- filter_queryset(queryset)[source]
Given a queryset, filter it with whichever filter backend is in use.
You are unlikely to want to override this method, although you may need to call it either from a list view, or from a custom get_object method if you want to apply the configured filtering backend to the default queryset.
- project_relation = 'project__'
- class akvo.rest.viewsets.ReadOnlyPublicProjectViewSet(**kwargs)[source]
Bases:
ReadOnlyModelViewSet
Read only viewset for public projects or objects related to public projects will be shown.
- authentication_classes = (<class 'rest_framework.authentication.SessionAuthentication'>, <class 'akvo.rest.authentication.TastyTokenAuthentication'>)
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- ordering_fields = '__all__'
- permission_classes = (<class 'akvo.rest.viewsets.SafeMethodsPermissions'>,)
- project_relation = 'project__'
- class akvo.rest.viewsets.SafeMethodsPermissions[source]
Bases:
DjangoObjectPermissions
Base class to allow any safe methods (‘GET’, ‘OPTIONS’ and ‘HEAD’) without needing to authenticate.