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

Utilize project-based lookup on individual element access #1812

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
43338b3
Construct table for project lookup by various ids
bctcvai Sep 3, 2024
22e90bf
Handle backporting existing elements into global lookup table
bctcvai Sep 3, 2024
0d48656
Add prepared statements for trigger usage
bctcvai Sep 3, 2024
c06344b
Hook up triggers to keep lookup table consistent
bctcvai Sep 3, 2024
312eca9
Move this setup to an earlier point to get proper insertion point
bctcvai Sep 3, 2024
88093be
Add lookup checks to unit tests (Media)
bctcvai Sep 3, 2024
caadcc7
Revert "Move this setup to an earlier point to get proper insertion p…
bctcvai Sep 4, 2024
b7a0f96
Call parent super function
bctcvai Sep 4, 2024
a3078ac
Add lookup check to locals + states
bctcvai Sep 4, 2024
93be9fe
Encorporate project into individual detail accessors [Conflict]
bctcvai Sep 4, 2024
d12285c
Fix test issue
bctcvai Sep 4, 2024
0d8e920
Fix typo
bctcvai Sep 5, 2024
ef216b9
Import model extensions.
bctcvai Sep 5, 2024
ce6030e
Add foreign object import
bctcvai Sep 6, 2024
fdc54e0
Add foreign object to replace foreign key
bctcvai Sep 6, 2024
e2fcd35
Fix missing keyword argument
bctcvai Sep 6, 2024
37b4e99
Fix new usage of media field
bctcvai Sep 6, 2024
9499c83
Switch these to tuples vs lists
bctcvai Sep 10, 2024
05ff0a1
Utilize new composite key
bctcvai Sep 10, 2024
c68d8e6
Add prepared statements for delete calls too
bctcvai Sep 10, 2024
ec5fd6c
Use new composite key
bctcvai Sep 10, 2024
c08d02f
Switch to composite key ManyToMany
bctcvai Sep 10, 2024
4115e9e
Add new composite-key many to many field to Resource objects
bctcvai Sep 10, 2024
49c9087
Switch to composite key for ResourceMedia
bctcvai Sep 10, 2024
33b0ab4
Fix up tests for new lookup strategy
bctcvai Sep 10, 2024
463d0ce
Fix resource usage in permalink presign
bctcvai Sep 10, 2024
3ab4af4
Fix rest of m2m usages
bctcvai Sep 10, 2024
98af363
Add migration from old to new m2m
bctcvai Sep 10, 2024
b0bec17
Add back in old field to make migration non-destructive
bctcvai Sep 10, 2024
39986d2
Fix migration utility
bctcvai Sep 10, 2024
4597373
Fix migration utility syntax a bit
bctcvai Sep 10, 2024
a36f672
Clean up naming + add unique constraint
bctcvai Sep 10, 2024
5a66713
Add custom M2M layer + disable legacy field to find usages
bctcvai Sep 10, 2024
298732d
Switch to custom M2M usage
bctcvai Sep 10, 2024
d2a71e0
Fix new many to many section capability
bctcvai Sep 10, 2024
20edf3f
Add migration capability
bctcvai Sep 10, 2024
c8374e8
Fix missing media_proj
bctcvai Sep 10, 2024
a3f2697
Fix logic to work with cloning
bctcvai Sep 10, 2024
c2e5401
Restore old field to make migration non-destructive
bctcvai Sep 10, 2024
765da7d
Add new custom M2M tables
bctcvai Sep 11, 2024
4844669
Add to migration utility
bctcvai Sep 11, 2024
547c19d
Fix constraint names
bctcvai Sep 11, 2024
b3ed252
Fix migration utility SQL (table name was plural)
bctcvai Sep 11, 2024
7dc0a56
Switch to new custom M2M fields
bctcvai Sep 11, 2024
e970364
Clean up usage of new custom M2M fields for state model
bctcvai Sep 12, 2024
2f43add
Clean up usage of media related searches to use media__proj
bctcvai Sep 12, 2024
3387f49
Clean up state_media interactions
bctcvai Sep 12, 2024
d9a65d0
Fix state graphic endpoint
bctcvai Sep 12, 2024
efbcd69
Make this less fragile
bctcvai Sep 12, 2024
0a86ef4
Fix up rest of query logic
bctcvai Sep 12, 2024
105ad61
Fix permission check for Merge/Trim state apis
bctcvai Sep 12, 2024
7a190b9
Make this not a destructive migration
bctcvai Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions api/main/_permission_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,18 +499,18 @@ def augment_permission(user, qs):
#

if model == Localization:
qs = qs.annotate(section=F("media__primary_section__pk"))
qs = qs.annotate(section=F("media_proj__primary_section__pk"))
elif model == State:
sb = Subquery(
Media.objects.filter(state__pk=OuterRef("pk")).values("primary_section__pk")[:1]
)
qs = qs.annotate(section=sb)

# Calculate a dictionary for permissions by section and version in this set
effected_media = qs.values("media__pk")
effected_media = qs.values("media_proj__pk")
effected_sections = (
Section.objects.filter(project=project, media__in=effected_media)
.values("pk")
SectionMediaM2M.objects.filter(project=project, media__in=effected_media)
.values("section")
.distinct()
)
effected_versions = qs.values("version__pk")
Expand Down Expand Up @@ -538,7 +538,7 @@ def augment_permission(user, qs):
}

section_cases = [
When(media__primary_section=section, then=Value(perm))
When(media_proj__primary_section=section, then=Value(perm))
for section, perm in section_perm_dict.items()
]
version_cases = [
Expand Down
2 changes: 1 addition & 1 deletion api/main/management/commands/backupresources.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Command(BaseCommand):
help = "Backs up any resource objects with `backed_up==False`."

def handle(self, **options):
resource_qs = Resource.objects.filter(media__deleted=False, backed_up=False)
resource_qs = Resource.objects.filter(media_proj__deleted=False, backed_up=False)

# Check for existence of default backup store
default_backup_store = get_tator_store(backup=True)
Expand Down
Loading
Loading