Commit 6b584e81 authored by alexandre's avatar alexandre

Expose flatpages in the API

parent 1dc9140d
......@@ -29,6 +29,7 @@ router = routers.DefaultRouter()
router.register(r'attachments', views.AttachmentViewSet)
router.register(r'scores', views.ScoreViewSet)
router.register(r'users', views.UserViewSet)
router.register(r'pages', views.FlatPageViewSet)
urlpatterns = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + [
......
......@@ -6,9 +6,18 @@ from taggit_serializer.serializers import (TagListSerializerField,
TaggitSerializer)
from guardian.shortcuts import assign_perm, get_users_with_perms, get_user_perms, remove_perm
from django.contrib.auth.models import User
from django.contrib.flatpages.models import FlatPage
class FlatPageSerializer(serializers.HyperlinkedModelSerializer):
# id = serializers.ReadOnlyField()
class Meta:
model = FlatPage
fields = ['url', 'title', 'content']
class UserSerializer(serializers.HyperlinkedModelSerializer):
id = serializers.ReadOnlyField()
......
......@@ -8,7 +8,7 @@ from django_filters import BooleanFilter
from django_filters import rest_framework as filters
from django_filters.rest_framework import DjangoFilterBackend, FilterSet
from .models import Attachment, Score, FeaturedScore
from .serializers import AttachmentSerializer, ScoreSerializer, ScoreLightSerializer, UserSerializer
from .serializers import AttachmentSerializer, ScoreSerializer, ScoreLightSerializer, UserSerializer, FlatPageSerializer
from guardian.shortcuts import get_anonymous_user
from django.contrib.auth.models import User
from guardian.shortcuts import get_objects_for_user
......@@ -17,6 +17,7 @@ from collections import OrderedDict
from django.db import models
from playground.models import Score
from taggit.models import Tag
from django.contrib.flatpages.models import FlatPage
......@@ -166,6 +167,14 @@ class ScoreViewSet(viewsets.ModelViewSet):
return ScoreLightSerializer
else:
return ScoreSerializer
class FlatPageViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = FlatPage.objects.all()
serializer_class = FlatPageSerializer
class ScoreView(TemplateView):
......
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