FinalsClub / karmaworld

KarmaNotes.org v3.0
GNU Affero General Public License v3.0
7 stars 6 forks source link

Andrew cannot load quizzes or keywords for some courses #427

Closed btbonval closed 9 years ago

btbonval commented 9 years ago

@AndrewMagliozzi reports 500 errors on both these links with the new push to production:

Both look fine to me, and I got 10/10 on the quiz. However, I'm signed out. There might be something fancy it tries to do if a user is signed in. I asked @AndrewMagliozzi to sign out and see if the problem persists (in which case it might just be his system), or if he can duplicate the experience that being logged off makes the problem go away (in which case something fancy for logged in users is going wrong).

AndrewMagliozzi commented 9 years ago

It works when logged out.

It may also be a problem that my account is an "admin" account. Let's test with a random student user account to see what happens.

btbonval commented 9 years ago

Beta and production systems allow access to Quiz and Keyword pages when not signed in.

Can reproduce the internal server error on beta when accessing either Quiz or Keyword pages when logged in with an admin user.

Can reproduce the internal server error on beta when accessing either Quiz or Keyword pages when logged in with a normal user.

keywords error in server logs:

2015-03-30T17:03:53.664991+00:00 app[web.1]:   File "/app/karmaworld/apps/notes/views.py", line 76, in note_page_context_helper
2015-03-30T17:03:53.664964+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 113, in get_response
2015-03-30T17:03:53.664994+00:00 app[web.1]: NameError: global name 'ObjectDoesNotExist' is not defined

quiz error in server logs:

2015-03-30T17:03:55.277428+00:00 app[web.1]:   File "/app/karmaworld/apps/notes/views.py", line 76, in note_page_context_helper
2015-03-30T17:03:55.277431+00:00 app[web.1]: NameError: global name 'ObjectDoesNotExist' is not defined

Both errors point to this line: https://github.com/FinalsClub/karmaworld/blob/master/karmaworld/apps/notes/views.py#L72-L77

The line only triggers if the user is authed (explaining why unauthed user is okay) and if there is some registered value for whether the note has been thanked or not by that user.

The helper function above is only called from NoteKeywordsView and NoteQuizView, which explains why the error only presents in keywords and quizzes. https://github.com/FinalsClub/karmaworld/blob/master/karmaworld/apps/notes/views.py#L178-L189

btbonval commented 9 years ago

ObjectDoesNotExist comes from django.core.exceptions. https://github.com/FinalsClub/karmaworld/blob/625ca18aa572839f8d0387d7857ae294043e77b5/karmaworld/apps/users/tests.py#L6

Going back through the history, this import was always missing. If I am reading this correctly, the quiz and keywords should have always errored for the same reason (unless the note had been thanked or thanks revoked).

btbonval commented 9 years ago

Fix confirmed on beta. Merged into master and pushing to production.