Skip to content

Commit

Permalink
Fix up enumerator stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisKSeal committed Mar 3, 2024
1 parent c89914d commit 780f152
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 76 deletions.
52 changes: 0 additions & 52 deletions tardis/apps/projects/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
has_sensitive_access,
has_write,
)
from tardis.tardis_portal.enumerators import AppList, CustomFilters
from tardis.tardis_portal.models.access_control import UserAuthentication

from .models import (
Expand Down Expand Up @@ -225,57 +224,6 @@ def get_or_create_user(username: str) -> User:
user = User.objects.get(username=username)
return user


def build_identifier_aware_filter(
model_type: IdentifierObjects,
orm_filters: Dict[str, Any],
filters: Dict[str, Any],
) -> Dict[str, Any]:
"""Function to check if the identifier app is active and if the identifier key is present in
the query. If both are, update the orm_filters to query on these.
Args:
model_type (IdentifierObjects): The name of the model that has an identifier model added.
orm_filters (Dict[str,Any]): The partial ORM filter to be updated
filters (Dict[str,Any]): Any filters that have been passed
Returns:
Dict[str, Any]: The updated ORM filter
"""
if (
AppList.IDENTIFIERS.value in settings.INSTALLED_APPS
and model_type.value in settings.OBJECTS_WITH_IDENTIFIERS
and CustomFilters.IDENTIFIERS.value in filters
):
query = filters[CustomFilters.IDENTIFIERS.value]
qset = Q(identifiers__identifier__iexact=query)
orm_filters[CustomFilters.IDENTIFIERS.value] = qset
return orm_filters


def apply_identifier_aware_filter(
model_type: IdentifierObjects,
applicable_filters: Dict[str, Any],
) -> Tuple[Any, Dict[str, Any]]:
"""Function to check if the identifier app is active. Clean the filter if it is and return
a custom filter value for semi-filtering.
Args:
model_type (IdentifierObjects): The name of the model that has an identifier model added.
applicable_filters (Dict[str,Any]): Filters to be applied
Returns:
Tuple[Any, Dict[str, Any]]: The custom filter and the cleaned filters.
"""
custom = None
if (
AppList.IDENTIFIERS.value in settings.INSTALLED_APPS
and model_type.value in settings.OBJECTS_WITH_IDENTIFIERS
):
custom = applicable_filters.pop(CustomFilters.IDENTIFIERS.value, None)
return (custom, applicable_filters)


class ProjectACLAuthorization(Authorization):
"""A Project-specific Authorisation class for Tastypie, rather than bloating
the existing generic MyTardis-API ACLAuthorization class further. It would be
Expand Down
4 changes: 0 additions & 4 deletions tardis/tardis_portal/enumerators/__init__.py

This file was deleted.

10 changes: 0 additions & 10 deletions tardis/tardis_portal/enumerators/applist.py

This file was deleted.

10 changes: 0 additions & 10 deletions tardis/tardis_portal/enumerators/customfilters.py

This file was deleted.

0 comments on commit 780f152

Please sign in to comment.