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

Raise error when user object is not found. #3312

Merged
merged 3 commits into from Apr 4, 2019

Conversation

jkmarx
Copy link
Member

@jkmarx jkmarx commented Apr 3, 2019

Resolves #3175

  • Handles the api error when the anon user is missing. Happens when user does not run fab vm update on a fresh instance.

Notes from issue
"Once project is configured to work with django-guardian, calling syncdb management command would create User instance for anonymous user support (with name of AnonymousUser)." https://django-guardian.readthedocs.io/en/stable/configuration.html?highlight=anon

@jkmarx jkmarx self-assigned this Apr 3, 2019
@jkmarx jkmarx added this to the Release 1.6.9 milestone Apr 3, 2019
@jkmarx jkmarx requested review from hackdna and removed request for hackdna April 3, 2019 17:26
@codecov
Copy link

codecov bot commented Apr 3, 2019

Codecov Report

Merging #3312 into develop will decrease coverage by 0.87%.
The diff coverage is 37.5%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3312      +/-   ##
===========================================
- Coverage    67.32%   66.44%   -0.88%     
===========================================
  Files          375      375              
  Lines        25472    24648     -824     
  Branches       939      939              
===========================================
- Hits         17149    16378     -771     
+ Misses        8323     8270      -53
Impacted Files Coverage Δ
refinery/user_files_manager/utils.py 76% <37.5%> (-14.25%) ⬇️
refinery/core/serializers.py 86.66% <0%> (-4.93%) ⬇️
refinery/core/views.py 60% <0%> (-3%) ⬇️
refinery/core/api.py 28.01% <0%> (-1.65%) ⬇️
refinery/core/models.py 81.2% <0%> (-0.65%) ⬇️
refinery/core/test_models.py 99.85% <0%> (-0.03%) ⬇️
refinery/core/test_views.py 100% <0%> (ø) ⬆️
refinery/core/urls.py 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8022bde...29fe2e8. Read the comment docs.

@jkmarx jkmarx requested a review from hackdna April 3, 2019 18:56
@hackdna
Copy link
Member

hackdna commented Apr 3, 2019

Thanks, missing AnonymousUser appears to be the root cause. That was addressed in #1103, so I'll reopen it and move it to the Next milestone.

Copy link
Member

@hackdna hackdna left a comment

Choose a reason for hiding this comment

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

Looks good, just one additional item.

@@ -1,4 +1,5 @@
from django.contrib.auth.models import User
from django.http import Http404
Copy link
Member

Choose a reason for hiding this comment

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

Also, replace the line above with:

from guardian.compat import get_user_model

then:

User = get_user_model()

as described here: https://django-guardian.readthedocs.io/en/latest/configuration.html

@jkmarx jkmarx requested a review from hackdna April 4, 2019 13:33
@jkmarx jkmarx merged commit 8a98dcf into develop Apr 4, 2019
@jkmarx jkmarx deleted the jkmarx/resolve-user-files-bug-missing-anon branch April 4, 2019 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants