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

Navigate to index page after OK logo clicked in staff mode #1345

Merged

Conversation

Royserg
Copy link
Contributor

@Royserg Royserg commented Jan 15, 2019

Instead of getting assignments page, navigate to the student mode index page.
My first contribution to OS, not sure if I did it right 🤞🤞

fix #1344

server/controllers/admin.py Outdated Show resolved Hide resolved
@Royserg Royserg force-pushed the bug/Royserg/OK-logo-navigate-to-index-page branch from ee59405 to 9f27c5b Compare January 15, 2019 23:30
Clicking OK logo as a staff was redirecting to assignment page
of the first course user is assigned to as a staff.

ticket okpy#1344
@Royserg Royserg force-pushed the bug/Royserg/OK-logo-navigate-to-index-page branch from 9f27c5b to 699add2 Compare January 15, 2019 23:38
<a href="{{ url_for('admin.index') }}" class="navbar-brand">
{% else %}
<a href="{{ url_for('student.index') }}" class="navbar-brand">
{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

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

If the current user is an admin, isn't the url for student.index the same as the url for admin.index? In other words, isn't this entire code block the same as the following?

<a href="{{ url_for('student.index') }}" class="navbar-brand">

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so. Those are two entirely different routes.

Copy link
Contributor

@pbitutsky pbitutsky Jan 16, 2019

Choose a reason for hiding this comment

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

I'm running a local server and when I impersonate a random non-admin user, I can view both http://localhost:5000/ and http://localhost:5000/admin/course/. But when I'm impersonating an admin, http://localhost:5000/ (aka student.index) seems to redirect to http://localhost:5000/admin/course/ (admin.index) automatically.

Copy link
Member

Choose a reason for hiding this comment

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

Is that true even if you enroll the admin as a student in a course?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes

Copy link
Member

Choose a reason for hiding this comment

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

Ok, disregard then.

Copy link
Contributor Author

@Royserg Royserg Jan 17, 2019

Choose a reason for hiding this comment

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

@pbitutsky @colinschoen
I think that replacing that if else block with link to student.index only won't do the trick
<a href="{{ url_for('student.index') }}" class="navbar-brand">

If only link to student.index would stay, then an user who is an admin(has is_admin true) by clicking on OK logo will be redirected to admin dashboard of a first course they have on the list. Even on the all courses view clicking logo would redirect to that one particular course and it feels weird. Little demo below. Logged in as: chelseacurry9@berkeley.edu

admin redirected to one of the courses

Leaving that if else block introduced in the commit redirects in this case admins always to their admin view list of all courses (same as clicking courses > View All Courses) and rest of the users behave normal as follow:

In case of those users who are also a staff for a course, they will get to the student.index but staff edition (staff dashboard). Logged in as: ctf3@gmail.com

staff_logged

And finally normal student (not a staff for any course) will always get redirected to the student.index and is not able to access admin dashboard
Logged in as: gzg@gmail.com

image

Please, let me know if I understood it correctly and if any more changes are neccessary :)

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, this PR LGTM.

@colinschoen
Copy link
Member

The issue @pbitutsky filed suggests one of the places the header can link to is the student index. I don't think this is super useful. I think we should just link to the list of courses (in the staff view) for everyone (not just admins).

@pbitutsky
Copy link
Contributor

@colinschoen If I'm understanding you correctly, you would like for the OK logo to navigate to http://localhost:5000/admin/course/. However, there is already navigation to get there: in the navbar, under courses > View All Courses. However, there is no way to navigate to the student index (http://localhost:5000/) via the UI. So won't it be better if the logo were to navigate to the student index?

@colinschoen
Copy link
Member

@pbitutsky Ah, ok that does sound ok too. Yeah navigating to the student index makes sense.

@colinschoen colinschoen merged commit e5eb36e into okpy:master Jan 25, 2019
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.

"OK" Logo in Admin Mode should navigate to the main index page
3 participants