add filter 'type' to return books of type 'visit' or 'book'
authorrougeronj
Thu, 11 Jun 2015 15:35:00 +0200
changeset 167 389540e1073f
parent 166 eb84ca2b6317
child 168 4b1294eaec0a
add filter 'type' to return books of type 'visit' or 'book' clean unused import
server/ammicosrv/ammico/views.py
server/ammicosrv/authentication/views.py
--- a/server/ammicosrv/ammico/views.py	Thu Jun 11 12:35:10 2015 +0200
+++ b/server/ammicosrv/ammico/views.py	Thu Jun 11 15:35:00 2015 +0200
@@ -5,7 +5,7 @@
 
 from django.conf import settings
 from django.contrib.auth import get_user_model
-from django.core.urlresolvers import reverse, reverse_lazy
+from django.core.urlresolvers import reverse
 from django.http import HttpResponse
 from django.shortcuts import render
 from django.utils.dateparse import parse_datetime
@@ -135,6 +135,9 @@
         books = Book.objects.filter(user = request.user.id)
         if 'idExpo' in request.GET:
             books = books.filter(exposition = request.GET['idExpo'])
+        if 'type' in request.GET:
+            books = books.filter(id_article__isnull = True if (request.GET['type'] == 'book') else False)
+        
         serializer = BookSerializer(books, many=True)
         return Response(serializer.data)
     
--- a/server/ammicosrv/authentication/views.py	Thu Jun 11 12:35:10 2015 +0200
+++ b/server/ammicosrv/authentication/views.py	Thu Jun 11 15:35:00 2015 +0200
@@ -4,14 +4,14 @@
 from django.conf import settings
 from django.contrib.auth import get_user_model
 import requests
-from rest_framework import serializers, status, permissions, parsers, renderers
+from rest_framework import status, permissions, parsers, renderers
 from rest_framework.authtoken.models import Token
 from rest_framework.response import Response
 from rest_framework.views import APIView
 
 from ammicosrv.ammico.views import populateVisit
-from ammicosrv.authentication.serializers import AuthTokenSerializer, \
-    UserSerializer
+from ammicosrv.authentication.serializers import UserSerializer, \
+    AuthTokenSerializer
 
 
 #from ammico.views import populateVisit