Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

836 Django 2.0 Upgrade #840

Merged
merged 9 commits into from
Oct 25, 2018
Merged

836 Django 2.0 Upgrade #840

merged 9 commits into from
Oct 25, 2018

Conversation

tbaxter-18f
Copy link
Contributor

@tbaxter-18f tbaxter-18f commented Oct 23, 2018

Description

Upgrades to Django 2.0.

A few things to note:

  • URL routing is all different, which has implications.
  • is_anonymous and is_authenticated are no longer called as methods
  • DRF had to be upgraded also, which also had some implications

@tbaxter-18f
Copy link
Contributor Author

tbaxter-18f commented Oct 23, 2018

Also worth noting: some tests are currently commented out, just so I can reduce the noise. They'll be back operational once I figure out what's up with the serializers.

Edit: you shouldn't see any commented-out tests any more.

@@ -33,50 +33,18 @@ def logout(request):
else:
return render(request, 'logout.html')

def handler400(request, exception):
return render(request, '400.html', {})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting: we don't actually have a 400.html, so we're not really testing this properly right now. I'm going to log a separate issue to sort that out.

@tbaxter-18f tbaxter-18f self-assigned this Oct 24, 2018
@codecov-io
Copy link

Codecov Report

Merging #840 into master will increase coverage by 0.22%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #840      +/-   ##
==========================================
+ Coverage   90.99%   91.22%   +0.22%     
==========================================
  Files          39       39              
  Lines        1754     1754              
==========================================
+ Hits         1596     1600       +4     
+ Misses        158      154       -4
Impacted Files Coverage Δ
hours/views.py 87.65% <0%> (ø) ⬆️
hours/urls/reports.py 100% <0%> (ø) ⬆️
api/views.py 98.55% <0%> (ø) ⬆️
hours/urls/timesheets.py 100% <0%> (ø) ⬆️
tock/urls.py 92.3% <0%> (ø) ⬆️
api/urls.py 100% <0%> (ø) ⬆️
employees/urls.py 100% <0%> (ø) ⬆️
employees/views.py 100% <0%> (ø) ⬆️
projects/models.py 99.15% <0%> (ø) ⬆️
tock/views.py 82.14% <0%> (+10.26%) ⬆️

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 703507c...823af32. Read the comment docs.

@tbaxter-18f tbaxter-18f changed the title [WIP] 836 Django upgrade 2 836 Django 2.0 Upgrade Oct 24, 2018
view=views.UserFormView.as_view(), name='UserFormView'),
path('', UserListView.as_view(), name='UserListView'),
path('<username>/', UserDetailView.as_view(), name='UserDetailView'),
path('e/<username>/', UserFormView.as_view(), name='UserFormView'),
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paths are no longer trying to match a pattern here. Is that no longer necessary? If so, use re_path would be necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the new path stuff is pretty interesting, and quite a bit cleaner. Underneath there's still a lot of regex stuff happening, but in urls.py you can ignore all that. You can pass arguments to path, no problem, and it's quite a bit cleaner to do so. In this particular case, we're just capturing username and passing it on to the view. Spiffy!

In my ideal world, I'd limit this to slug matches with slug:username but we allow characters in usernames that aren't allowed in slugs (like periods) so that won't work.

You should only need to dip down into re_path if you've got a full-on regex to match against or -- and I suspect this is the more common case) you've got an older URL that feels messy to match up to the new path style.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I was worrying that we are allowing more additional characters than we needed to. Just want to make sure that would be okay.

But sounds like it may not be a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a valid concern. We are leaving username pretty open here, but they should be validated when the user is created, and if an invalid character comes in it'll just 404.

Copy link
Member

@amymok amymok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me.

@tbaxter-18f tbaxter-18f merged commit 6ccc522 into master Oct 25, 2018
@Jkrzy Jkrzy deleted the 836-django-upgrade-2 branch May 14, 2019 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants