From d1a17710313a3a26424bd536508816d64a96d97f Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Sat, 7 Jan 2017 10:08:14 -0600 Subject: [PATCH] Add members endpoint. --- bikeshop_project/bikeshop/urls.py | 2 ++ bikeshop_project/registration/serializers.py | 9 ++++----- bikeshop_project/registration/views.py | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bikeshop_project/bikeshop/urls.py b/bikeshop_project/bikeshop/urls.py index 3605ad1..5782436 100644 --- a/bikeshop_project/bikeshop/urls.py +++ b/bikeshop_project/bikeshop/urls.py @@ -23,12 +23,14 @@ from rest_framework_jwt.views import obtain_jwt_token import registration import bike +import registration from bike import urls as bike_urls from core import urls as core_urls from registration import urls as member_urls routeLists = [ bike.urls.apiRoutes, + registration.urls.apiRoutes, ] router = routers.DefaultRouter() diff --git a/bikeshop_project/registration/serializers.py b/bikeshop_project/registration/serializers.py index 471cd5e..8633795 100644 --- a/bikeshop_project/registration/serializers.py +++ b/bikeshop_project/registration/serializers.py @@ -4,10 +4,9 @@ from rest_framework.serializers import ModelSerializer from .models import Member -class MemberSerializer(ModelSerializer): - first_name = serializers.CharField(allow_blank=True, required=False) - last_name = serializers.CharField(allow_blank=True, required=False) - +class MemberSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Member - fields = ('first_name', 'last_name', 'email', 'id', 'banned', 'suspended') \ No newline at end of file + fields = ('email', 'email_consent', 'email_consent', 'first_name', 'last_name', 'preferred_name', + 'date_of_birth', 'guardian_name', 'phone', 'street', 'city', 'province', 'country', 'post_code', + 'waiver', 'is_active', 'banned', 'suspended') \ No newline at end of file diff --git a/bikeshop_project/registration/views.py b/bikeshop_project/registration/views.py index 0ea34a3..daa33ec 100644 --- a/bikeshop_project/registration/views.py +++ b/bikeshop_project/registration/views.py @@ -9,6 +9,7 @@ from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt from django.views.generic import TemplateView, View from haystack.query import SearchQuerySet +from rest_framework import serializers from rest_framework import viewsets from rest_framework.renderers import JSONRenderer from rest_framework.serializers import ModelSerializer @@ -67,7 +68,7 @@ class MemberSearchView(View): class VisitSerializer(ModelSerializer): - member = MemberSerializer() + member = MemberSignInSerializer() class Meta: model = Visit