Decorators for instructor and coordinator#143
Open
pnshiralkar wants to merge 3 commits intoFOSSEE:revampv2from
Open
Decorators for instructor and coordinator#143pnshiralkar wants to merge 3 commits intoFOSSEE:revampv2from
pnshiralkar wants to merge 3 commits intoFOSSEE:revampv2from
Conversation
Contributor
pnshiralkar
commented
May 22, 2020
- Added is_instructor and is_coordinator decorators
- Replaced get_landing_page() to redirect_to_landing_page() func
…ng_page by redirect_to_landing_page func
| return redirect(get_landing_page(user)) | ||
|
|
||
| return redirect('/login/') | ||
| pass |
Contributor
There was a problem hiding this comment.
why have this function if it is not doing anything?
Contributor
Author
There was a problem hiding this comment.
This function redirects users who come to '/' route to their respective landing pages. As CMS app is not yet merged, not having this function will cause a 404 error on '/' route.
adityacp
reviewed
May 29, 2020
workshop_app/views.py
Outdated
| if not is_instructor(args[0].user): | ||
| return func(*args, **kwargs) | ||
| return redirect(reverse('workshop_status_instructor')) | ||
|
|
Contributor
There was a problem hiding this comment.
For these decorators create a separate file called decorators.py. This should not be done in views.
workshop_app/views.py
Outdated
| def get_landing_page(user): | ||
| # For now, landing pages of both instructor and coordinator are same | ||
| def instructor_only(func): | ||
| def inner1(*args, **kwargs): |
Contributor
There was a problem hiding this comment.
please use on inner if needed, inner1 seems a little odd
…into instructor-decorator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.