Commit Graph

3194 Commits

Author SHA1 Message Date
Ryan P Kilby
1a667f420d Reimplement request attribute access w/ __getattr__ (#5617)
* Add tests for proxying WSGIRequest attributes in Request.

* Add request attribute exception test

* Reimplement request attribute access
2017-11-22 11:42:59 +01:00
Michał Bielawski
134a6f66f9 Fixed schema generation for filter backends (#5613) 2017-11-22 00:11:59 -05:00
Ryan P Kilby
a3df1c1199 Test Serializer exclude for declared fields (#5599)
* Test current behavior of exclude+declared field

* Assert declared fields are not present in exclude
2017-11-20 09:51:16 +01:00
Jon Dufresne
ff556a91fd Remove references to unsupported Django versions in docs and code (#5602)
Per the trove classifiers, DRF only supports Django versions 1.10+. Can
drop documentation, code comments, and workarounds for older Django
versions.
2017-11-20 09:35:54 +01:00
Ryan P Kilby
9f66e8badd Fix request body/POST access (#5590)
* Modernize middleware tests

* Added a failing test for #5582

* Set data ref on underlying django request
2017-11-15 20:58:37 +01:00
Ryan P Kilby
15024f3f07 Remove set_rollback() from compat (#5591)
* Remove Django 1.6 transaction compat

* Move set_rollback from compat => views
2017-11-14 09:55:59 +01:00
Éric Araujo
265375c104 add missing template change for #5584 (#5587) 2017-11-11 08:43:00 +01:00
Éric Araujo
57ad208dc6 add pygments CSS block in browsable API views (#5584) 2017-11-10 09:42:21 +01:00
Ryan P Kilby
8d7ce3726d Compat cleanup (#5581)
* Reenable flake8 on compat, cleanup style/imports

* Cleanup compat urls imports

* Refactor compat url pattern/resolver imports

* Add comment re dropping pytz compat

... when dropping Django 1.10

* Strip whitespace

Grrr. GitHub web editor 😡
2017-11-10 09:41:03 +01:00
Jon Dufresne
f9c67f04d4 Clean up all whitespace throughout project (#5578)
* Remove trailing whitespace from lines
* Remove trailing nad leading whitespace from files

Allows for cleaner diffs in future changes. For editors that
automatically clean up whitespace on save, will avoid unrelated line
changes in diffs.
2017-11-09 20:57:53 +01:00
Jon Dufresne
f8e8381c00 Drop compat wrapper for TimeDelta.total_seconds() (#5577)
TimeDelta.total_seconds() was introduced in Python 2.7 and 3.2. It is
available on all supported Python versions.

https://docs.python.org/2/library/datetime.html#datetime.timedelta.total_seconds
https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds
2017-11-09 09:03:48 +01:00
Jon Dufresne
ea81000160 Remove ulrparse compatability shim; use six instead
The urlparse shim in compat.py duplicates Django's bundled six. Can rely
on upstream instead of duplicating their works. Unifies shim with other
files already using six.
2017-11-08 21:30:33 -08:00
Carlton Gibson
0f33e63e10
Update version and release notes for v3.7.3 (#5568) 2017-11-06 16:32:12 +01:00
Xavier Ordoquy
d6a8e02021 Move django.contrib.auth import out of compat.
Fixed some regressions where compat was imported during app loading and
led to importing django.contrib.auth.models which ended in a
`AppRegistryNotReady` exception.
2017-11-06 09:57:51 -05:00
Carlton Gibson
3dc40f9572
Version 3.7.2 Release (#5563)
* Begin release notes for 3.7.2

* Add release notes fro merged issues.

* Finalise release notes

* Increment version number to 3.7.2

* Update translations
2017-11-06 12:05:08 +01:00
Yuri Nikulin
7a278b3540 fix processing unicode symbols in query_string by Python 2 (#5552)
* fix processing unicode symbols in query_string by Python 2

* Add comments for encoded test strings.

* Add file encoding for Python 2.
2017-11-06 11:46:37 +01:00
Sergei Azarkin
d49d796c85 Change ImageField validation pattern, use validators from DjangoImageField (#5539) 2017-11-06 11:14:37 +01:00
Jon Dufresne
0552810410 Use dict and set literals instead of calls to dict() and set() (#5559)
Set literals are available on all supported Python versions. They are
idiomatic and always faster:

$ python3 -m timeit '{}'
10000000 loops, best of 3: 0.0357 usec per loop
$ python3 -m timeit 'dict()'
10000000 loops, best of 3: 0.104 usec per loop

$ python3 -m timeit '{1, 2, 3}'
10000000 loops, best of 3: 0.0754 usec per loop
$ python3 -m timeit 'set([1, 2, 3])'
1000000 loops, best of 3: 0.228 usec per loop
2017-11-06 10:03:01 +01:00
Jon Dufresne
f77e794dc8 Fix all BytesWarning caught during tests (#5561)
Running the tests with bytes warning enabled shows some bytes/str
mixups. Fix them all.

Some examples of mixing usage:

str(b'foo') -- calling str() on bytes
b'foo' == 'foo' -- compare str with bytes
'foo' + b'bar' -- concatenating str and bytes
2017-11-06 10:02:48 +01:00
Carlton Gibson
331c31370f
Add rounding parameter to DecimalField (#5562)
* Adding rounding parameter to DecimalField.

* Using standard `assert` instead of `self.fail()`.

* add testcase and PEP8 multilines fix

* flake8 fixes

* Use decimal module constants in tests.

* Add docs note for `rounding` parameter.
2017-11-06 09:55:09 +01:00
Carlton Gibson
565c722762
Add interactive docs error template (#5548) 2017-11-06 09:04:07 +01:00
Stephen Chisholm
93e75ec138 Catch OverflowError for "out of range" datetimes (#5546)
* Add test for #5545 
* Catch OverflowError for "out of range" datetimes
2017-10-31 10:17:08 +01:00
Tom Christie
2b6245db53
Ensure Location header is strictly a 'str', not subclass. Closes #5541 (#5544) 2017-10-30 13:08:52 +00:00
Ryan P Kilby
5009aeff18 Fields with 'allow_null=True' should imply a default serialization value (#5518)
* Add test for dotted source + allow_null

* Field 'allow_null' implies 'default=None'

* Field 'allow_null' provides serialization default
2017-10-30 10:17:53 +01:00
Carlton Gibson
1f693c331e Fix dotted source ordering (#5533)
* replaced '.' for '__' in dotted ordering sources

* Add test for non-dotted source.
2017-10-25 11:46:21 +02:00
Carlton Gibson
7261ae653a Schema: Exclude OPTIONS/HEAD for ViewSet actions (#5532)
Closes #5528.

Viewset custom actions (@detail_route etc) OPTIONS (and HEAD) methods were not being excluded from Schema Generations.

This PR adds a test reproducing the reported error and adjusts `EndpointEnumerator.get_allowed_methods()` to filter ViewSet actions in the same way as other `APIView`s
2017-10-25 10:56:40 +02:00
Jamie Cockburn
efb047fa07 JSONField renders as textarea (#5529) (#5530) 2017-10-25 10:55:41 +02:00
Jamie Cockburn
91fa8b923a Stop JSONBoundField mangling invalid JSON (#5526) (#5527) 2017-10-25 10:54:38 +02:00
Carlton Gibson
1c9ad52cb6 Clarify pagination system check (#5524)
* Add `id` to allow silencing.
* Expand `hint` to clarify.

Ref #5170 Closes #5523
2017-10-23 12:31:59 +02:00
andrewhannum
916a4a27ef Interactive docs - make bottom sidebar items sticky (#5516) 2017-10-23 12:02:04 +02:00
Matteo Nastasi
9ec81e32da substitute '@@' code block delimiter with triple backtick, more con… (#5513)
* substitute '@@' code block delimiter with triple back-tick,  more consistent with other markdown extensions

* remove development print and allow spaces between triple backtick and syntax name in codeblock

* update comparison content for markdown test
2017-10-20 11:39:29 +02:00
Jason Kraus
22a71a6322 include date and date-time format for swagger 2 schema generation (#5511) 2017-10-20 09:14:33 +02:00
Dustin Wyatt
e704dd2e40 Add import for TextLexer. (#5512)
If pygments did not recognize the language name it was being passed,
this would raise a `NameError` because `TextLexer` import was missing.
2017-10-18 20:53:05 +02:00
Mariusz Felisiak
1a526c153e Fixed Django 2.1 compatibility due to removal of django.contrib.auth.login()/logout() views. (#5510) 2017-10-18 09:46:27 +02:00
Carlton Gibson
80320ed615 Version 3.7.1 Release (#5505)
* Release notes for 3.7.1

* Update version to 3.7.1
2017-10-16 15:11:54 +02:00
Marcin
5d7b6e5b2f Fixed issues with schema name collisions (#5486)
* Fixed issues with schema name collisions

* Fixed mutating issues in python 3

* Optimized solution

* Fixed isort

* Removed not needed cast

* Fix for key collision

* Added preferred key to preserve if available

* Add accidently removed test
2017-10-16 11:32:48 +02:00
Carlton Gibson
c7fb60bcd4 Django 2.0a1 compat (#5503)
* Update remaing `include` calls

Missed as part of #5481 cleanup.

* Provide app_name in include_docs_urls

* Update remaining get_regex_pattern usages

* Allow functools.partial in is_simple_callable check
2017-10-16 11:31:13 +02:00
Ryan P Kilby
cbfa444454 Fix HiddenField stripping in BrowsableAPIRenderer (#5499) 2017-10-16 09:35:53 +02:00
Maxim Kuznetsov
c91b081837 Support URLPattern and URLResolver from Django 2.0 (#5500)
* Support URLPattern and URLResolver from Django 2.0

* fix import order
2017-10-16 09:33:31 +02:00
Levi Payne
41188dfba0 Interactive documentation always uses false for boolean fields in requests (#5492) 2017-10-11 21:11:44 +02:00
Carlton Gibson
eb3d078a2c Version 3.7: Announcement etc (#5437)
* Set version number for 3.7.0 release

* Rename release notes section

Moved issue links to top for easier access.
(Can move back later)

* Add release note for #5273

* Add release note for #5440

* Add release note for #5265

Strict JSON handling

* Add release note for #5250

* Add release notes for #5170

* Add release notes for #5443

* Add release notes for #5448

* Add release notes for #5452

* Add release not for #5342

* Add release notes for 5454

* Add release notes for #5058 & #5457

Remove Django 1.8 & 1.9 from README and setup.py

* Release notes for merged 3.6.5 milestone tickets

Tickets migrated to 3.7.0 milestone.

* Add release notes for #5469

* Add release notes from AM 2ndOct

* Add final changes to the release notes.

* Add date and milestone link

Move issue links back to bottom.

* Update translations from transifex

* Begin releae anouncement

* Add release note for #5482

* 3.7 release announcement & related docs.
2017-10-06 13:18:31 +02:00
Carlton Gibson
b2ca2c1911 Remove deprecated schema code from DefaultRouter (#5482) 2017-10-05 21:29:56 +02:00
Carlton Gibson
c674687782 Remove Django 1.8 & 1.9 compatibility code (#5481)
* Identify code that needs to be pulled out of/removed from compat.py

* Extract modern code from get_names_and_managers in compat.py and remove compat code

* Extract modern code from is_authenticated() in compat.py and remove.

* Extract modern code from is_anonymous() in compat.py and remove

* Extract modern code from get_related_model() from compat.py and remove

* Extract modern code from value_from_object() in compat.py and remove

* Update postgres compat

JSONField now always available.

* Remove DecimalValidator compat

* Remove get_remote_field compat

* Remove template_render compat

Plus isort.

* Remove set_many compat

* Remove include compat
2017-10-05 20:41:38 +02:00
Carlton Gibson
2edeb74e0e Have is_list_view recognise RetrieveModel… views (#5480)
Fixes #5165
2017-10-05 20:41:14 +02:00
Carlton Gibson
d8da6bb29b Update coreapi JS to 0.1.1 (#5479)
Ref #5059
2017-10-05 13:40:28 +02:00
Jascha Geerds
161dc2df2c Call Django's authenticate function with the request object (#5295)
As of Django 1.11 the `authenticate` function accepts a request as an
additional argument. This commit fixes compatibility between newer Django
versions and custom authentication backends which already depend on the request
object.

See also:

[Django 1.11 release](https://docs.djangoproject.com/en/1.11/releases/1.11/)

```
authenticate() now passes a request argument to the authenticate() method of
authentication backends. Support for methods that don’t accept request as the
first positional argument will be removed in Django 2.1.
```
2017-10-05 10:43:49 +01:00
Carlton Gibson
d138f30a86 Fix naming collisions in Schema Generation (#5464)
* Add failing tests for #4704

* Add generic view based test case.

* Adjust insert_into to raise ValueError
2017-10-05 11:06:09 +02:00
Jerome Leclanche
cc7f4f543f Fix missing six.text_type() call on APIException.__str__ (#5476)
Pull up method from subclass to superclass

The call was added in 426547c61c
to allow for dict-style arguments to ValidationError but does not
apply to other APIException descendants.
2017-10-04 09:00:21 +02:00
Carlton Gibson
dc4a98fbe8 Fix documentation data rendering (#5472)
* Add failing test for #5395

* Add data filter for use in templates

Closes #5395

* Fix isort
2017-10-02 13:26:44 +02:00
Matteo Nastasi
063534ae50 Docstrings highlighting with pygments (#5462)
* add 'docstrings-with-pygments' feature without packages checks and tests

* move syntax_highlight doc filter in compatibility module and define it conditionally

* typo fixed

* add test for optional code highlight ('pygments' and 'markdown' packages must be installed)
2017-10-02 11:44:29 +02:00