Merge branch 'master' into issue4989

This commit is contained in:
Vimarsh Chaturvedi 2017-05-13 19:10:47 +05:30 committed by GitHub
commit 7b4afdc737
6 changed files with 98 additions and 15 deletions

View File

@ -40,6 +40,33 @@ You can determine your currently installed version using `pip freeze`:
## 3.6.x series
### 3.6.3
**Date**: [12th May 2017][3.6.3-milestone]
* Raise 404 if a URL lookup results in ValidationError. ([#5126][gh5126])
* Honor http_method_names on class based view, when generating API schemas. ([#5085][gh5085])
* Allow overridden `get_limit` in LimitOffsetPagination to return all records. ([#4437][gh4437])
* Fix partial update for the ListSerializer. ([#4222][gh4222])
* Render JSONField control correctly in browsable API. ([#4999][gh4999], [#5042][gh5042])
* Raise validation errors for invalid datetime in given timezone. ([#4987][gh4987])
* Support restricting doc & schema shortcuts to a subset of urls. ([#4979][gh4979])
* Resolve SchemaGenerator error with paginators that have no `page_size` attribute. ([#5086][gh5086], [#3692][gh3692])
* Resolve HyperlinkedRelatedField exception on string with %20 instead of space. ([#4748][gh4748], [#5078][gh5078])
* Customizable schema generator classes. ([#5082][gh5082])
* Update existing vary headers in response instead of overwriting them. ([#5047][gh5047])
* Support passing `.as_view()` to view instance. ([#5053][gh5053])
* Use correct exception handler when settings overridden on a view. ([#5055][gh5055], [#5054][gh5054])
* Update Boolean field to support 'yes' and 'no' values. ([#5038][gh5038])
* Fix unique validator for ChoiceField. ([#5004][gh5004], [#5026][gh5026], [#5028][gh5028])
* JavaScript cleanups in API Docs. ([#5001][gh5001])
* Include URL path regexs in API schemas where valid. ([#5014][gh5014])
* Correctly set scheme in coreapi TokenAuthentication. ([#5000][gh5000], [#4994][gh4994])
* HEAD requests on ViewSets should not return 405. ([#4705][gh4705], [#4973][gh4973], [#4864][gh4864])
* Support usage of 'source' in `extra_kwargs`. ([#4688][gh4688])
* Fix invalid content type for schema.js ([#4968][gh4968])
* Fix DjangoFilterBackend inheritance issues. ([#5089][gh5089], [#5117][gh5117])
### 3.6.2
**Date**: [10th March 2017][3.6.2-milestone]
@ -688,6 +715,7 @@ For older release notes, [please see the version 2.x documentation][old-release-
[3.6.0-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.6.0+Release%22
[3.6.1-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.6.1+Release%22
[3.6.2-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.6.2+Release%22
[3.6.3-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.6.3+Release%22
<!-- 3.0.1 -->
[gh2013]: https://github.com/encode/django-rest-framework/issues/2013
@ -1298,3 +1326,37 @@ For older release notes, [please see the version 2.x documentation][old-release-
[gh4955]: https://github.com/encode/django-rest-framework/issues/4955
[gh4956]: https://github.com/encode/django-rest-framework/issues/4956
[gh4949]: https://github.com/encode/django-rest-framework/issues/4949
<!-- 3.6.3 -->
[gh5126]: https://github.com/encode/django-rest-framework/issues/5126
[gh5085]: https://github.com/encode/django-rest-framework/issues/5085
[gh4437]: https://github.com/encode/django-rest-framework/issues/4437
[gh4222]: https://github.com/encode/django-rest-framework/issues/4222
[gh4999]: https://github.com/encode/django-rest-framework/issues/4999
[gh5042]: https://github.com/encode/django-rest-framework/issues/5042
[gh4987]: https://github.com/encode/django-rest-framework/issues/4987
[gh4979]: https://github.com/encode/django-rest-framework/issues/4979
[gh5086]: https://github.com/encode/django-rest-framework/issues/5086
[gh3692]: https://github.com/encode/django-rest-framework/issues/3692
[gh4748]: https://github.com/encode/django-rest-framework/issues/4748
[gh5078]: https://github.com/encode/django-rest-framework/issues/5078
[gh5082]: https://github.com/encode/django-rest-framework/issues/5082
[gh5047]: https://github.com/encode/django-rest-framework/issues/5047
[gh5053]: https://github.com/encode/django-rest-framework/issues/5053
[gh5055]: https://github.com/encode/django-rest-framework/issues/5055
[gh5054]: https://github.com/encode/django-rest-framework/issues/5054
[gh5038]: https://github.com/encode/django-rest-framework/issues/5038
[gh5004]: https://github.com/encode/django-rest-framework/issues/5004
[gh5026]: https://github.com/encode/django-rest-framework/issues/5026
[gh5028]: https://github.com/encode/django-rest-framework/issues/5028
[gh5001]: https://github.com/encode/django-rest-framework/issues/5001
[gh5014]: https://github.com/encode/django-rest-framework/issues/5014
[gh5000]: https://github.com/encode/django-rest-framework/issues/5000
[gh4994]: https://github.com/encode/django-rest-framework/issues/4994
[gh4705]: https://github.com/encode/django-rest-framework/issues/4705
[gh4973]: https://github.com/encode/django-rest-framework/issues/4973
[gh4864]: https://github.com/encode/django-rest-framework/issues/4864
[gh4688]: https://github.com/encode/django-rest-framework/issues/4688
[gh4968]: https://github.com/encode/django-rest-framework/issues/4968
[gh5089]: https://github.com/encode/django-rest-framework/issues/5089
[gh5117]: https://github.com/encode/django-rest-framework/issues/5117

View File

@ -8,7 +8,7 @@ ______ _____ _____ _____ __
"""
__title__ = 'Django REST framework'
__version__ = '3.6.2'
__version__ = '3.6.3'
__author__ = 'Tom Christie'
__license__ = 'BSD 2-Clause'
__copyright__ = 'Copyright 2011-2017 Tom Christie'

View File

@ -3,6 +3,7 @@ Generic views that provide commonly needed behaviour.
"""
from __future__ import unicode_literals
from django.core.exceptions import ValidationError
from django.db.models.query import QuerySet
from django.http import Http404
from django.shortcuts import get_object_or_404 as _get_object_or_404
@ -18,7 +19,7 @@ def get_object_or_404(queryset, *filter_args, **filter_kwargs):
"""
try:
return _get_object_or_404(queryset, *filter_args, **filter_kwargs)
except (TypeError, ValueError):
except (TypeError, ValueError, ValidationError):
raise Http404

View File

@ -23,7 +23,7 @@ function formEntries (form) {
// Polyfill for new FormData(form).entries()
var formData = new FormData(form)
if (formData.entries !== undefined) {
return formData.entries()
return Array.from(formData.entries())
}
var entries = []
@ -59,6 +59,8 @@ $(function () {
var $selectedAuthentication = $('#selected-authentication')
var $authControl = $('#auth-control')
var $authTokenModal = $('#auth_token_modal')
var $authBasicModal = $('#auth_basic_modal')
var $authSessionModal = $('#auth_session_modal')
// Language Control
$('#language-control li').click(function (event) {
@ -260,8 +262,8 @@ $(function () {
event.preventDefault()
window.auth = null
$selectedAuthentication.text('none')
$authControl.children().removeClass('active')
$authControl.find("[data-auth='none']").addClass('active')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='none']").closest('li').addClass('active')
})
// Authentication: token
@ -276,8 +278,8 @@ $(function () {
'token': token
}
$selectedAuthentication.text('token')
$authControl.children().removeClass('active')
$authControl.find("[data-auth='token']").addClass('active')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='token']").closest('li').addClass('active')
$authTokenModal.modal('hide')
})
@ -293,9 +295,9 @@ $(function () {
'password': password
}
$selectedAuthentication.text('basic')
$authControl.children().removeClass('active')
$authControl.find("[data-auth='basic']").addClass('active')
$authTokenModal.modal('hide')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='basic']").closest('li').addClass('active')
$authBasicModal.modal('hide')
})
// Authentication: session
@ -305,8 +307,8 @@ $(function () {
'type': 'session'
}
$selectedAuthentication.text('session')
$authControl.children().removeClass('active')
$authControl.find("[data-auth='session']").addClass('active')
$authTokenModal.modal('hide')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='session']").closest('li').addClass('active')
$authSessionModal.modal('hide')
})
})

View File

@ -49,7 +49,7 @@
};
$('#selected-authentication').text('session');
$('#auth-control').children().removeClass('active');
$('#auth-control').find("[data-auth='session']").addClass('active');
$('#auth-control').find("[data-auth='session']").closest('li').addClass('active');
{% endif %}
</script>
</body>

View File

@ -2,6 +2,7 @@ from __future__ import unicode_literals
import pytest
from django.db import models
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.test import TestCase
from django.utils import six
@ -10,7 +11,8 @@ from rest_framework import generics, renderers, serializers, status
from rest_framework.response import Response
from rest_framework.test import APIRequestFactory
from tests.models import (
BasicModel, ForeignKeySource, ForeignKeyTarget, RESTFrameworkModel
BasicModel, ForeignKeySource, ForeignKeyTarget, RESTFrameworkModel,
UUIDForeignKeyTarget
)
factory = APIRequestFactory()
@ -647,3 +649,19 @@ class ApiViewsTests(TestCase):
view.delete('test request', 'test arg', test_kwarg='test')
assert view.called is True
assert view.call_args == data
class GetObjectOr404Tests(TestCase):
def setUp(self):
super(GetObjectOr404Tests, self).setUp()
self.uuid_object = UUIDForeignKeyTarget.objects.create(name='bar')
def test_get_object_or_404_with_valid_uuid(self):
obj = generics.get_object_or_404(
UUIDForeignKeyTarget, pk=self.uuid_object.pk
)
assert obj == self.uuid_object
def test_get_object_or_404_with_invalid_string_for_uuid(self):
with pytest.raises(Http404):
generics.get_object_or_404(UUIDForeignKeyTarget, pk='not-a-uuid')