Merge branch 'release_3.3.0' into filterama

This commit is contained in:
Alan Rominger 2018-07-03 15:42:37 -04:00 committed by GitHub
commit 360ad7ad61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 6 deletions

View File

@ -23,7 +23,7 @@ from django.utils.translation import ugettext_lazy as _
from django.contrib.auth import views as auth_views
# Django REST Framework
from rest_framework.exceptions import PermissionDenied, AuthenticationFailed, ParseError, NotAcceptable
from rest_framework.exceptions import PermissionDenied, AuthenticationFailed, ParseError, NotAcceptable, UnsupportedMediaType
from rest_framework import generics
from rest_framework.response import Response
from rest_framework import status
@ -197,6 +197,10 @@ class APIView(views.APIView):
except (PermissionDenied, ParseError) as exc:
request.drf_request_user = None
self.__init_request_error__ = exc
except UnsupportedMediaType as exc:
exc.detail = _('You did not use correct content_type in your HTTP request. \
If you are using our REST API, the content_type must be application/json')
self.__init_request_error__ = exc
return drf_request
def finalize_response(self, request, response, *args, **kwargs):

View File

@ -1193,10 +1193,13 @@ class OAuth2ApplicationSerializer(BaseSerializer):
def get_related(self, obj):
res = super(OAuth2ApplicationSerializer, self).get_related(obj)
res.update(dict(
tokens = self.reverse('api:o_auth2_application_token_list', kwargs={'pk': obj.pk}),
tokens = self.reverse('api:o_auth2_application_token_list', kwargs={'pk': obj.pk}),
activity_stream = self.reverse(
'api:o_auth2_application_activity_stream_list', kwargs={'pk': obj.pk}
)
))
return res
def get_modified(self, obj):
if obj is None:
return None

View File

@ -3720,7 +3720,11 @@ class WorkflowJobTemplateCopy(WorkflowsEnforcementMixin, CopyAPIView):
copy_return_serializer_class = WorkflowJobTemplateSerializer
def get(self, request, *args, **kwargs):
if get_request_version(request) < 2:
return self.v1_not_allowed()
obj = self.get_object()
if not request.user.can_access(obj.__class__, 'read', obj):
raise PermissionDenied()
can_copy, messages = request.user.can_access_with_errors(self.model, 'copy', obj)
data = OrderedDict([
('can_copy', can_copy), ('can_copy_without_user_input', can_copy),

View File

@ -107,3 +107,13 @@ def test_filterable_fields(options, instance, admin_user):
assert filterable_info['filterable'] is True
assert not non_filterable_info['filterable']
@pytest.mark.django_db
def test_handle_content_type(post, admin):
''' Tower should return 415 when wrong content type is in HTTP requests '''
post(reverse('api:project_list'),
{'name': 't', 'organization': None},
admin,
content_type='text/html',
expect=415)

View File

@ -1085,7 +1085,6 @@ var NetworkUIController = function($scope,
$scope.topology_id = data.topology_id;
$scope.panX = data.panX;
$scope.panY = data.panX;
$scope.current_scale = data.scale;
$scope.$emit('awxNet-UpdateZoomWidget', $scope.current_scale, true);
$scope.link_id_seq = util.natural_numbers(data.link_id_seq);
$scope.device_id_seq = util.natural_numbers(data.device_id_seq);
@ -1215,7 +1214,6 @@ var NetworkUIController = function($scope,
$scope.current_scale = Math.min(2, Math.max(0.10, Math.min((window.innerWidth-200)/diff_x, (window.innerHeight-300)/diff_y)));
$scope.$emit('awxNet-UpdateZoomWidget', $scope.current_scale, true);
$scope.updateScaledXY();
$scope.updatePanAndScale();
}
// Calculate the new panX and panY to show the entire diagram
if (min_x !== null && min_y !== null) {
@ -1224,7 +1222,6 @@ var NetworkUIController = function($scope,
$scope.panX = $scope.current_scale * (-min_x - diff_x/2) + window.innerWidth/2;
$scope.panY = $scope.current_scale * (-min_y - diff_y/2) + window.innerHeight/2;
$scope.updateScaledXY();
$scope.updatePanAndScale();
}
//Update the device_id_seq to be greater than all device ids to prevent duplicate ids.
@ -1261,6 +1258,7 @@ var NetworkUIController = function($scope,
}
$scope.updateInterfaceDots();
$scope.updatePanAndScale(); // Update the canvas element scale to the correct initial scale
$scope.$emit('awxNet-instatiateSelect', $scope.devices);
};