Skip to content

Commit

Permalink
Merge pull request #686 from xchem/staging
Browse files Browse the repository at this point in the history
Merge staging changes into production for 2024.11.1
  • Loading branch information
mwinokan authored Nov 4, 2024
2 parents 4d5f6c0 + a32021f commit f346b79
Show file tree
Hide file tree
Showing 30 changed files with 616 additions and 422 deletions.
7 changes: 3 additions & 4 deletions api/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,16 @@ def user_is_member_of_target(
"""
Returns true if the user has access to any proposal the target belongs to.
"""
target_proposals = [p.title for p in target.project_id.all()]
user_proposals = self.get_proposals_for_user(
user, restrict_public_to_membership=restrict_public_to_membership
)
is_member = any(proposal in user_proposals for proposal in target_proposals)
is_member = target.project.title in user_proposals
if not is_member:
logger.warning(
"Failed membership check user='%s' target='%s' target_proposals=%s",
user.username,
target.title,
target_proposals,
target.pk,
target.project.title,
)
return is_member

Expand Down
5 changes: 5 additions & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@
router.register(
"metadata_upload", viewer_views.UploadMetadataView, basename='metadata_upload'
)
router.register(
"computedset_download",
viewer_views.DownloadComputedSetView,
basename='computedset_download',
)

# Squonk Jobs
router.register(
Expand Down
1 change: 1 addition & 0 deletions fragalysis/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@
# To simplify error messages when the match fails you can also
# add an error message.
TAS_REGEX: str = os.environ.get("TAS_REGEX", r"^(lb\d{5})(-(\d+)){0,1}$")

TAS_REGEX_ERROR_MSG: str = os.environ.get(
"TAS_REGEX_ERROR_MSG",
"Must begin 'lb' followed by 5 digits, optionally followed by a hyphen and a number.",
Expand Down
2 changes: 1 addition & 1 deletion hotspots/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class HotspotView(ISPyBSafeQuerySet):
queryset = HotspotMap.objects.all()
serializer_class = HotspotMapSerializer
filterset_fields = ("map_type", "target", "site_observation")
filter_permissions = "target__project_id"
filter_permissions = "target__project"
6 changes: 3 additions & 3 deletions hypothesis/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ class InteractionView(ISPyBSafeQuerySet):
"prot_smarts",
"mol_smarts",
)
filter_permissions = "interaction_point__targ_res__target_id__project_id"
filter_permissions = "interaction_point__targ_res__target_id__project"


class InteractionPointView(ISPyBSafeQuerySet):
queryset = InteractionPoint.objects.all()
serializer_class = InteractionPointSerializer
filterset_fields = ("site_observation", "protein_atom_name", "molecule_atom_name")
filter_permissions = "targ_res__target_id__project_id"
filter_permissions = "targ_res__target_id__project"


class TargetResidueView(ISPyBSafeQuerySet):
queryset = TargetResidue.objects.all()
serializer_class = TargetResidueSerialzier
filterset_fields = ("target_id", "res_name", "res_num", "chain_id")
filter_permissions = "target_id__project_id"
filter_permissions = "target_id__project"
44 changes: 7 additions & 37 deletions media_serve/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,6 @@

logger = logging.getLogger(__name__)

# def prot_download(request, file_path):
# """
# Download a protein by nginx redirect
# :param request: the initial request
# :param file_path: the file path we're getting from the static
# :return: the response (a redirect to nginx internal)
# """
# logger.info("+ Received file_download file path: %s", file_path)
# ispy_b_static = ISpyBSafeStaticFiles2()
# ispy_b_static.model = SiteObservation
# ispy_b_static.request = request
# # ispy_b_static.permission_string = "target_id__project_id"
# # ispy_b_static.permission_string = "target__project_id"
# ispy_b_static.permission_string = "experiment__experiment_upload__target__project_id"
# # ispy_b_static.field_name = "pdb_info"
# ispy_b_static.field_name = "apo_file"
# ispy_b_static.content_type = "application/x-pilot"
# ispy_b_static.prefix = "/pdbs/"
# # ispy_b_static.prefix = "/target_loader_data/"
# ispy_b_static.input_string = file_path
# return ispy_b_static.get_response()


def file_download(request, file_path):
"""
Expand All @@ -40,11 +18,8 @@ def file_download(request, file_path):
# ispy_b_static = ISpyBSafeStaticFiles()
ispy_b_static.model = SiteObservation
ispy_b_static.request = request
# ispy_b_static.permission_string = "target_id__project_id"
# the following 2 aren't used atm
ispy_b_static.permission_string = (
"experiment__experiment_upload__target__project_id"
)
ispy_b_static.permission_string = "experiment__experiment_upload__target__project"
# ispy_b_static.field_name = "pdb_info"
ispy_b_static.field_name = "apo_file"
ispy_b_static.content_type = "application/x-pilot"
Expand All @@ -68,11 +43,8 @@ def tld_download(request, file_path):
# ispy_b_static = ISpyBSafeStaticFiles()
ispy_b_static.model = SiteObservation
ispy_b_static.request = request
# ispy_b_static.permission_string = "target_id__project_id"
# the following 2 aren't used atm
ispy_b_static.permission_string = (
"experiment__experiment_upload__target__project_id"
)
ispy_b_static.permission_string = "experiment__experiment_upload__target__project"
ispy_b_static.field_name = "apo_file"
ispy_b_static.content_type = "application/x-pilot"
ispy_b_static.prefix = "/target_loader_data/"
Expand All @@ -92,9 +64,7 @@ def cspdb_download(request, file_path):
ispy_b_static.model = SiteObservation
ispy_b_static.request = request
# the following 2 aren't used atm
ispy_b_static.permission_string = (
"experiment__experiment_upload__target__project_id"
)
ispy_b_static.permission_string = "experiment__experiment_upload__target__project"
ispy_b_static.field_name = "apo_file"
ispy_b_static.content_type = "application/x-pilot"
ispy_b_static.prefix = "/computed_set_data/"
Expand All @@ -112,7 +82,7 @@ def bound_download(request, file_path):
ispy_b_static = ISPyBSafeStaticFiles()
ispy_b_static.model = SiteObservation
ispy_b_static.request = request
ispy_b_static.permission_string = "target_id__project_id"
ispy_b_static.permission_string = "target_id__project"
ispy_b_static.field_name = "bound_info"
ispy_b_static.content_type = "application/x-pilot"
ispy_b_static.prefix = "/bound/"
Expand All @@ -130,7 +100,7 @@ def map_download(request, file_path):
ispy_b_static = ISPyBSafeStaticFiles()
ispy_b_static.model = SiteObservation
ispy_b_static.request = request
ispy_b_static.permission_string = "target_id__project_id"
ispy_b_static.permission_string = "target_id__project"

substrings = file_path.split('.')[0].split('_')
substring = [x for x in substrings if x in ['2fofc', 'fofc', 'event']]
Expand Down Expand Up @@ -166,7 +136,7 @@ def metadata_download(request, file_path):
ispy_b_static = ISPyBSafeStaticFiles()
ispy_b_static.model = Target
ispy_b_static.request = request
ispy_b_static.permission_string = "project_id"
ispy_b_static.permission_string = "project"
ispy_b_static.field_name = "metadata"
ispy_b_static.content_type = "application/x-pilot"
ispy_b_static.prefix = "/metadata/"
Expand All @@ -184,7 +154,7 @@ def archive_download(request, file_path):
ispy_b_static = ISPyBSafeStaticFiles()
ispy_b_static.model = Target
ispy_b_static.request = request
ispy_b_static.permission_string = "project_id"
ispy_b_static.permission_string = "project"
ispy_b_static.field_name = "zip_archive"
ispy_b_static.content_type = "application/zip"
ispy_b_static.prefix = "/targets/"
Expand Down
4 changes: 2 additions & 2 deletions scoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ViewSceneView(
# filter_backends = (filters.DjangoFilterBackend,)
serializer_class = ViewSceneSerializer
filterset_fields = ("user_id", "uuid")
filter_permissions = "snapshot__session_project__target__project_id"
filter_permissions = "snapshot__session_project__target__project"
permission_classes = [IsObjectProposalMember]

def put(self, request, *args, **kwargs):
Expand Down Expand Up @@ -113,7 +113,7 @@ class SiteObservationGroupView(
queryset = SiteObservationGroup.objects.all()
serializer_class = SiteObservationGroupSerializer
filterset_fields = ("group_type", "site_observation", "target", "description")
filter_permissions = "target__project_id"
filter_permissions = "target__project"
permission_classes = [IsObjectProposalMember]


Expand Down
130 changes: 0 additions & 130 deletions viewer/compound_set_upload.py

This file was deleted.

Loading

0 comments on commit f346b79

Please sign in to comment.