-
Notifications
You must be signed in to change notification settings - Fork 70
Decorators for instructor and coordinator #143
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
base: revampv2
Are you sure you want to change the base?
Conversation
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 |
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.
why have this function if it is not doing anything?
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 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.
workshop_app/views.py
Outdated
| if not is_instructor(args[0].user): | ||
| return func(*args, **kwargs) | ||
| return redirect(reverse('workshop_status_instructor')) | ||
|
|
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.
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): |
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.
please use on inner if needed, inner1 seems a little odd
…into instructor-decorator