implement RoleListCreate
diff --git a/plstackapi/planetstack/views/roles.py b/plstackapi/planetstack/views/roles.py
index d7ab78a..6a08daa 100644
--- a/plstackapi/planetstack/views/roles.py
+++ b/plstackapi/planetstack/views/roles.py
@@ -3,7 +3,8 @@
from rest_framework.response import Response
from rest_framework import status
-from plstackapi.planetstack.models import Role
+from plstackapi.planetstack.api.roles import add_role, delete_role, get_roles
+from plstackapi.planetstack.serializers import RoleSerializer
class RoleListCreate(APIView):
@@ -12,5 +13,20 @@
"""
def post(self, request, format = None):
- print request
+
+ if 'auth' not in request.DATA
+ return Response(status=status.HTTP_400_BAD_REQUEST)
+ else if 'name' in request.DATA:
+ role = add_role(request.DATA['auth'], request.DATA['name'])
+ serializer = RoleSerializer(data=role)
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+ else:
+ roles = get_roles(request.DATA['auth'])
+ serializer = RoleSerializer(roles, many=True)
+ return Response(Serializer.data)
+
+
+
+
+