diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2018-02-19 20:58:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-02-19 20:58:15 +0000 |
commit | 3b22628fe24ca3b9b9659462af6abaf8fd6601f8 (patch) | |
tree | 71af40f5ea05ac22f992ceacc848afbedd2c3390 | |
parent | b9ac97df7bedf857a38dd696b05ec618b217d4ff (diff) | |
parent | 3979c0cc8fc863b1661353e96e17ffa166abfa96 (diff) |
Merge "Expose Limited User Info Through API"
-rw-r--r-- | dashboard/src/api/serializers.py | 7 | ||||
-rw-r--r-- | dashboard/src/api/urls.py | 1 | ||||
-rw-r--r-- | dashboard/src/api/views.py | 5 |
3 files changed, 13 insertions, 0 deletions
diff --git a/dashboard/src/api/serializers.py b/dashboard/src/api/serializers.py index 1cc621a..10e1975 100644 --- a/dashboard/src/api/serializers.py +++ b/dashboard/src/api/serializers.py @@ -10,6 +10,7 @@ from rest_framework import serializers +from account.models import UserProfile from notifier.models import Notifier from booking.models import Booking from dashboard.models import Server, Resource, ResourceStatus @@ -44,3 +45,9 @@ class NotifierSerializer(serializers.ModelSerializer): class Meta: model = Notifier fields = ('id', 'title', 'content', 'user', 'sender', 'message_type', 'msg_sent') + +class UserSerializer(serializers.ModelSerializer): + username = serializers.CharField(source='user.username') + class Meta: + model = UserProfile + fields = ('user', 'username', 'ssh_public_key', 'pgp_public_key', 'email_addr') diff --git a/dashboard/src/api/urls.py b/dashboard/src/api/urls.py index 71cd3ef..c2cd510 100644 --- a/dashboard/src/api/urls.py +++ b/dashboard/src/api/urls.py @@ -34,6 +34,7 @@ router.register(r'servers', ServerViewSet) router.register(r'bookings', BookingViewSet) router.register(r'resource_status', ResourceStatusViewSet) router.register(r'notifier', NotifierViewSet) +router.register(r'user', UserViewSet) urlpatterns = [ url(r'^', include(router.urls)), diff --git a/dashboard/src/api/views.py b/dashboard/src/api/views.py index c16d57d..b873ef1 100644 --- a/dashboard/src/api/views.py +++ b/dashboard/src/api/views.py @@ -16,6 +16,7 @@ from rest_framework import viewsets from rest_framework.authtoken.models import Token from api.serializers import * +from account.models import UserProfile from booking.models import Booking from dashboard.models import Resource, Server, ResourceStatus @@ -45,6 +46,10 @@ class NotifierViewSet(viewsets.ModelViewSet): queryset = Notifier.objects.none() serializer_class = NotifierSerializer +class UserViewSet(viewsets.ModelViewSet): + queryset = UserProfile.objects.all() + serializer_class = UserSerializer + @method_decorator(login_required, name='dispatch') class GenerateTokenView(View): def get(self, request, *args, **kwargs): |