-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix: an error when an anonymous user fills the form #13
Conversation
SaveDBAction.execute method uses request.user for form_user but request.user is not an instance of User for AnonymousUsers therefore we need to check for whether the user is logged in or not
@arunk Well spotted! Thank you! |
Cleaner way of checking for anonymous user Co-authored-by: Fabian Braun <[email protected]>
Do you mean record the key "login_required" in the FormEntry ? or do you mean record that the user was anonymous? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #13 +/- ##
=======================================
Coverage ? 62.79%
=======================================
Files ? 21
Lines ? 1419
Branches ? 219
=======================================
Hits ? 891
Misses ? 487
Partials ? 41 ☔ View full report in Codecov by Sentry. |
I'm also having trouble figuring out where the Action is supposed to go. I have finally put it in apps.py in the ready method, where I load the actions module and register an object to do the FormAction. I'm not sure if this is the right approach. If it is, then I'll submit another PR, to update the docs saying how to do this. If the FormAction should be in another file, I tried forms.py, actions.py none of them worked. Then let me know and I'll do likewise and update the README.rst and submit a PR |
Now, this should record any logged-in user and leave the "form_user" entry empty ( |
Yes, that works. The form action has to be somewhere where it is imported upon django startup. I have often imported them from |
SaveDBAction.execute method uses request.user for
form_user but request.user is not an instance of User for AnonymousUsers therefore we need to check for whether the user is logged in or not