-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
RESTful refactoring of /course access continued #1542
Conversation
else: | ||
return HttpResponseNotFound() | ||
|
||
|
||
@login_required | ||
@ensure_csrf_cookie | ||
def course_listing(request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this here and renamed from user.index()
Move index access into the url Move course creation into the url Add helper methods for testing to serialize json data and set accept header.
else: | ||
course_creator_status = 'granted' | ||
|
||
return course_creator_status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be clearer to return early, rather than set a variable and return it at the end of the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally prefer single points of return (generally advised in "clean code"). And I wrote that code. :)
@singingwolfboy @cahrens May I merge this? (the test failure is a false alarm on quality) |
👍 |
@@ -46,6 +45,6 @@ def login_page(request): | |||
def howitworks(request): | |||
"Proxy view" | |||
if request.user.is_authenticated(): | |||
return index(request) | |||
return redirect('/course') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use Django's reverse
function, rather than hard-coding the URL
😩 👍 😩 |
RESTful refactoring of /course access continued
Move index access into the url
Move course creation into the url
Add helper methods for testing to serialize json data and set accept header.
@cahrens this is part of my story but seemed big enuf to do as a PR, plz revie
@singingwolfboy plz review