django-rest-framework-jwt
django-rest-framework-jwt copied to clipboard
refactor views to provide serializer_valid and serializer_invalid as …
…hooks for subclasses.
I'm using this app for a project of my own, and wanted to set user.last_login
.
I felt like what I had to do to accomplish this wasn't very DRY, as I had to re-serialize the request data in order to get to the user.
So I decided to factor that out in a manner reminicient of the form_valid
and form_invalid
methods of Django's generic views.
Codecov Report
Merging #413 into master will decrease coverage by
0.28%
. The diff coverage is76.92%
.
@@ Coverage Diff @@
## master #413 +/- ##
==========================================
- Coverage 90.67% 90.38% -0.29%
==========================================
Files 14 12 -2
Lines 847 822 -25
Branches 29 29
==========================================
- Hits 768 743 -25
Misses 66 66
Partials 13 13
Flag | Coverage Δ | |
---|---|---|
#codecov | 90.38% <76.92%> (-0.29%) |
:arrow_down: |
#dj110 | 87.1% <76.92%> (-0.39%) |
:arrow_down: |
#dj111 | 87.1% <76.92%> (-0.39%) |
:arrow_down: |
#dj18 | 89.53% <76.92%> (-0.31%) |
:arrow_down: |
#dj19 | 89.53% <76.92%> (-0.31%) |
:arrow_down: |
#drf31 | 89.53% <76.92%> (-0.31%) |
:arrow_down: |
#drf32 | 89.53% <76.92%> (-0.31%) |
:arrow_down: |
#drf33 | 89.53% <76.92%> (-0.31%) |
:arrow_down: |
#drf34 | 90.38% <76.92%> (-0.29%) |
:arrow_down: |
#drf35 | 90.02% <76.92%> (-0.3%) |
:arrow_down: |
#drf36 | 90.02% <76.92%> (-0.3%) |
:arrow_down: |
#py27 | 90.38% <76.92%> (-0.29%) |
:arrow_down: |
#py33 | 89.17% <76.92%> (-0.32%) |
:arrow_down: |
#py34 | 90.02% <76.92%> (+0.53%) |
:arrow_up: |
#py35 | 87.1% <76.92%> (?) |
|
#py36 | 87.1% <76.92%> (?) |
Impacted Files | Coverage Δ | |
---|---|---|
rest_framework_jwt/views.py | 93.18% <76.92%> (+0.68%) |
:arrow_up: |
rest_framework_jwt/utils.py | ||
rest_framework_jwt/models.py |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 0a0bd40...52c8b7b. Read the comment docs.
I'm aware that this pull request decreases code coverage as currently measured.
However, this is the case because of refactoring for flexibility, not because I introduce any new behavior; I looked at the existing tests, they all seem to test views as a whole, and I don't see how I could contribute tests that cover my changes (although I'm open to suggestions!).
Also, #410 is evidence that I'm not alone in wanting something like this.