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

Update Buggy Code in Advance of Python 3 Update #3457

Merged
merged 25 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ea9ea10
save changes to model so that they propagate to tests
ilan-gold Sep 23, 2019
83ebc9a
remove uniquify in favor of list of set
ilan-gold Sep 23, 2019
7af0804
add travis debugging
ilan-gold Sep 24, 2019
c043529
revert travis debugging
ilan-gold Sep 24, 2019
4235b78
add more travis debugging
ilan-gold Sep 24, 2019
339852a
fix formatting issue
ilan-gold Sep 24, 2019
297e650
convert logger arguments
ilan-gold Sep 24, 2019
f71f036
format code properly
ilan-gold Sep 24, 2019
68382fd
app more debugging on default_app
ilan-gold Sep 24, 2019
c294e2e
final formatting change for logging
ilan-gold Sep 24, 2019
7470c9d
remove flake from tavis.yml
ilan-gold Sep 24, 2019
92a9ef4
update sorting to be specified by rank field is solr
ilan-gold Sep 25, 2019
a14f5bb
Merge branches 'develop' and 'ilan-gold/fix_problematic_python2_code'…
ilan-gold Oct 1, 2019
1812fa6
pass request in to the ToolSerializer for getting ownership
ilan-gold Oct 2, 2019
8a8aef2
revert debugging changes for celery
ilan-gold Oct 2, 2019
8a20abb
revert debugging changes for celery
ilan-gold Oct 2, 2019
f000d91
update user logout handling for data sets
ilan-gold Oct 2, 2019
4d15b37
test bam indexing for python3 package update
ilan-gold Oct 2, 2019
e682be6
test bam indexing for python3 package update
ilan-gold Oct 2, 2019
d9485e9
fix formatting issues
ilan-gold Oct 3, 2019
6adcad8
remove pysam testing
ilan-gold Oct 3, 2019
ad1d0cd
revert uniquify change
ilan-gold Oct 3, 2019
c209f97
remove sorting
ilan-gold Oct 3, 2019
eb4917f
remove try-catch on has_perm
ilan-gold Oct 10, 2019
c8ee5bc
re-insert space
ilan-gold Oct 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions refinery/analysis_manager/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def test__check_galaxy_history_state_progress_less_than_percent_complete(
galaxy_progress_mock
):
self.analysis_status.galaxy_history_progress = 25
self.analysis_status.save()
_check_galaxy_history_state(self.analysis.uuid)

analysis_status = AnalysisStatus.objects.get(analysis=self.analysis)
Expand All @@ -128,6 +129,7 @@ def test__check_galaxy_history_state_percent_complete_is_100(
galaxy_progress_mock
):
self.analysis_status.galaxy_history_progress = 100
self.analysis_status.save()
_check_galaxy_history_state(self.analysis.uuid)

analysis_status = AnalysisStatus.objects.get(analysis=self.analysis)
Expand Down
12 changes: 10 additions & 2 deletions refinery/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,16 @@ def data_set_slug(request, slug):
def data_set(request, data_set_uuid, analysis_uuid=None):
data_set = get_object_or_404(DataSet, uuid=data_set_uuid)
public_group = ExtendedGroup.objects.public_group()

if not request.user.has_perm('core.read_meta_dataset', data_set):
try:
perms = request.user.has_perm('core.read_meta_dataset', data_set)
except User.DoesNotExist:
Copy link
Member

Choose a reason for hiding this comment

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

If the user is not logged in, they are the anon user. What's throwing the exception exactly?

Copy link
Member Author

@ilan-gold ilan-gold Oct 9, 2019

Choose a reason for hiding this comment

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

I believe this has to do with the way in which the logged-in user is held in browser vs. what is happening on the backend - the browser still has everything it needs to have the permission/User but the User has been logged out already in the backend so when the cached user in the browser comes through, Django uses the load of it from the cache but can then not find it once inside the application logic.

Copy link
Member Author

@ilan-gold ilan-gold Oct 9, 2019

Choose a reason for hiding this comment

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

so this is indeed what appears to be happening in the Authentication middleware (i imagine little changed from 1.8 to 1.9 regarding this - check out the get_user function: https://github.com/django/django/blob/1.9/django/contrib/auth/middleware.py)

logger.error('User is not found for request - '
'likely logged out')
return HttpResponseForbidden(
custom_error_page(request, '404.html',
{user: request.user,
'msg': "User Not Found"}))
if not perms:
if 'read_meta_dataset' not in get_perms(public_group, data_set):
if request.user.is_authenticated():
return HttpResponseForbidden(
Expand Down
8 changes: 6 additions & 2 deletions refinery/tool_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def create(self, request, *args, **kwargs):
with transaction.atomic():
tool = create_tool(tool_launch_configuration, request.user)
tool.launch()
serializer = ToolSerializer(tool)
serializer = ToolSerializer(
tool, context={'request': request}
)
except Exception as e:
logger.error(e)
return HttpResponseBadRequest(e)
Expand Down Expand Up @@ -181,7 +183,9 @@ def relaunch(self, request, *args, **kwargs):
"currently running")
try:
visualization_tool.launch()
serializer = ToolSerializer(visualization_tool)
serializer = ToolSerializer(
visualization_tool, context={'request': request}
)
return JsonResponse(serializer.data)
except Exception as e:
logger.error(e)
Expand Down