зеркало из https://github.com/mozilla/mentoring.git
add a REST API for participants
This commit is contained in:
Родитель
e053250a5f
Коммит
2b53843c91
1
TODO.txt
1
TODO.txt
|
@ -9,6 +9,7 @@ Stuff to do!
|
|||
* pairing
|
||||
* show existing pairings
|
||||
* "unpair" button
|
||||
* check in model that pair.mentor.role == MENTOR etc.
|
||||
* provide data to a react app, allow filtering, etc.
|
||||
|
||||
* hardening
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
from rest_framework import serializers, viewsets, permissions
|
||||
|
||||
from .models import Participant
|
||||
|
||||
class ParticipantSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Participant
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
# ViewSets define the view behavior.
|
||||
class ParticipantViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
queryset = Participant.objects.all()
|
||||
serializer_class = ParticipantSerializer
|
|
@ -0,0 +1,6 @@
|
|||
from rest_framework import serializers, viewsets, routers
|
||||
|
||||
from .participants.rest import ParticipantViewSet
|
||||
|
||||
router = routers.DefaultRouter(trailing_slash=False)
|
||||
router.register(r'participants', ParticipantViewSet)
|
|
@ -25,7 +25,9 @@ SECRET_KEY = '54ld$bgd#&@os*u2^t)06b)8@-#m&2zhe_4k+*xs_k6f*n*o_a'
|
|||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
ALLOWED_HOSTS = [
|
||||
'mentoring.ngrok.io',
|
||||
]
|
||||
|
||||
# Project-specific confit
|
||||
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
|
||||
from . import rest
|
||||
|
||||
urlpatterns = [
|
||||
# the POST destination for enrollment via SurveyGizmo
|
||||
path('enrollment/', include('mentoring.enrollment.urls')),
|
||||
# TODO
|
||||
path('pairing/', include('mentoring.pairing.urls')),
|
||||
# the Django admin
|
||||
path('admin/', admin.site.urls),
|
||||
# the API
|
||||
path('api/', include(rest.router.urls)),
|
||||
# ..and anything else renders the frontend
|
||||
path('', include('mentoring.frontend.urls')),
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче