sandy9999 / WorkGen

WorkGen is a collaboration with TeachForIndia in an effort to use technology to aid teachers around the country by automating question paper generation
https://workgen.org
4 stars 5 forks source link

Fix customized paper generation error when not logged in #58

Closed KIRA009 closed 3 years ago

KIRA009 commented 4 years ago

This fixes #34

As of this commit, the error that occurred while generating customized paper without logging in is fixed. The GeneratedCustomizedPaper takes a mentor username as a filter parameter, whereas, when not logged in, it was being fed AnonymousUser object, which was breaking the code.

This issue was fixed by checking if the user is authenticated right off the bat, thereby not waiting for the code to reach some stage where it could break, since anyways the user should not be allowed to generate a customised paper without logging in. The user is then prompted to log in, following which he is redirected to the required url from the 'next' query parameter, for which slight alteration is also done in login_view function