Ejemplo n.º 1
0
 def submit(self):
     if 'username' in self.cleaned_data:
         ans = User.getByUsername(self.cleaned_data['username'])
         uResponse = UserSerializer([] if not ans else [ans], many=True).data
         response = { 'data' : uResponse }
         return response
     elif 'email' in self.cleaned_data:
         ans = User.getByEmail(self.cleaned_data['email'])
         uResponse = UserSerializer([] if not ans else [ans], many=True).data
         response = { 'data' : uResponse }
         return response
     else:
         ans = User.all(page=self.cleaned_data['page'], limit=self.cleaned_data['limit'])
         uResponse = UserSerializer(ans, many=True).data
         response = { 'data' : uResponse }
         if ans:
             response['next'] = ans[-1].user_id
         return response