Fixing two bugs related to approval
* If roles not present in keystone, we throw and error while trying to handle an error. * when data is empty we fail to return a useful error message. Change-Id: I8572cf7ce35997cd7b5a38658a3e4eb26afe4941
This commit is contained in:
parent
13cb4716cd
commit
7de53ea24a
@ -289,7 +289,7 @@ class UserMixin(ResourceMixin):
|
||||
except Exception as e:
|
||||
self.add_note(
|
||||
"Error: '%s' while %s the roles: %s on user: %s " %
|
||||
(e, action_string, self.roles, user))
|
||||
(e, action_string, roles, user))
|
||||
raise
|
||||
|
||||
def enable_user(self, user=None):
|
||||
|
@ -18,6 +18,7 @@ from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
|
||||
from rest_framework.exceptions import ParseError
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
@ -350,10 +351,15 @@ class TaskDetail(APIViewWithLogger):
|
||||
{'errors': ['No task with this id.']},
|
||||
status=404)
|
||||
|
||||
try:
|
||||
if request.data.get('approved') is not True:
|
||||
return Response(
|
||||
{'approved': ["this is a required boolean field."]},
|
||||
status=400)
|
||||
except ParseError:
|
||||
return Response(
|
||||
{'approved': ["this is a required boolean field."]},
|
||||
status=400)
|
||||
|
||||
if task.completed:
|
||||
return Response(
|
||||
|
Loading…
Reference in New Issue
Block a user