Skip to content
Permalink
Browse files

add preliminary permissions.IsAuthenticatedOrReadOnly

to be refined later
  • Loading branch information
bhaugen committed Dec 27, 2015
1 parent 7b6d193 commit f3cbacff2a4afbaa81f73165f78ec5c4ef00f368
Showing with 12 additions and 3 deletions.
  1. +11 −2 valuenetwork/api/views.py
  2. +1 −1 valuenetwork/settings.py
@@ -20,7 +20,7 @@
from django.contrib.sites.models import Site
from django.contrib.auth.models import User, Group

from rest_framework import viewsets
from rest_framework import viewsets, permissions

from valuenetwork.api.serializers import *

@@ -41,6 +41,7 @@ class UserViewSet(viewsets.ModelViewSet):
"""
queryset = User.objects.all()
serializer_class = UserSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)


class PeopleViewSet(viewsets.ModelViewSet):
@@ -49,20 +50,23 @@ class PeopleViewSet(viewsets.ModelViewSet):
"""
queryset = EconomicAgent.objects.individuals()
serializer_class = PeopleSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

class ContextViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows context agents to be viewed or edited.
"""
queryset = EconomicAgent.objects.context_agents()
serializer_class = ContextSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

class AgentViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows all Economic Agents to be viewed or edited.
"""
queryset = EconomicAgent.objects.all()
serializer_class = EconomicAgentSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)


class AgentTypeViewSet(viewsets.ModelViewSet):
@@ -71,6 +75,7 @@ class AgentTypeViewSet(viewsets.ModelViewSet):
"""
queryset = AgentType.objects.all()
serializer_class = AgentTypeSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

class EconomicEventViewSet(viewsets.ModelViewSet):
"""
@@ -82,6 +87,7 @@ class EconomicEventViewSet(viewsets.ModelViewSet):
More query parameters and filters to come, on request.
"""
serializer_class = EconomicEventSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

def get_queryset(self):
"""
@@ -100,28 +106,31 @@ class EventTypeViewSet(viewsets.ModelViewSet):
"""
queryset = EventType.objects.all()
serializer_class = EventTypeSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

class ResourceTypeViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows Agent Types to be viewed or edited.
"""
queryset = EconomicResourceType.objects.all()
serializer_class = ResourceTypeSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

class EconomicResourceViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows Agent Types to be viewed or edited.
"""
queryset = EconomicResource.objects.all()
serializer_class = EconomicResourceSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

class UnitViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows Agent Types to be viewed or edited.
"""
queryset = Unit.objects.all()
serializer_class = UnitSerializer

permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

#the following methods relate to providing linked open data from NRP instances, for the valueflows vocab project.
#they use rdflib, Copyright (c) 2012-2015, RDFLib Team All rights reserved.
@@ -158,7 +158,7 @@
]

REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',),
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticatedOrReadOnly',),
'PAGINATE_BY': 10,
'URL_FIELD_NAME': 'api_url',
}

0 comments on commit f3cbacf

Please sign in to comment.
You can’t perform that action at this time.