Skip to content

Commit

Permalink
Set project shared status to xform shared status if not the same
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisRayM committed Apr 8, 2021
1 parent 0e16356 commit ea88326
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions onadata/apps/logger/models/xform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,9 @@ def clear_project_cache(project_id):

def set_object_permissions(sender, instance=None, created=False, **kwargs):
# clear cache
clear_project_cache(instance.project.pk)
project = instance.project
project.refresh_from_db()
clear_project_cache(project.pk)
safe_delete('{}{}'.format(IS_ORG, instance.pk))

if created:
Expand All @@ -1065,7 +1067,7 @@ def set_object_permissions(sender, instance=None, created=False, **kwargs):
OwnerRole.add(instance.created_by, instance)

from onadata.libs.utils.project_utils import set_project_perms_to_xform
set_project_perms_to_xform(instance, instance.project)
set_project_perms_to_xform(instance, project)


post_save.connect(
Expand Down
3 changes: 1 addition & 2 deletions onadata/libs/utils/project_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def set_project_perms_to_xform(xform, project):
"""
# allows us to still use xform.shared and xform.shared_data as before
# only switch if xform.shared is False
xform_is_shared = xform.shared or xform.shared_data
if not xform_is_shared and project.shared != xform.shared:
if project.shared != xform.shared:
xform.shared = project.shared
xform.shared_data = project.shared
xform.save()
Expand Down

0 comments on commit ea88326

Please sign in to comment.