-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1638 from dandi/dynamic-metadata
- Loading branch information
Showing
19 changed files
with
186 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
dandiapi/api/migrations/0042_asset_remove_computed_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 4.1.1 on 2023-06-27 17:29 | ||
|
||
from django.db import migrations, models | ||
|
||
from dandiapi.api.models.asset import ASSET_COMPUTED_FIELDS | ||
|
||
|
||
def remove_unpublished_asset_fields(apps, schema_editor): | ||
Asset = apps.get_model('api', 'Asset') | ||
Asset.objects.filter(published=False, metadata__has_any_keys=ASSET_COMPUTED_FIELDS).update( | ||
metadata=models.F('metadata') - ASSET_COMPUTED_FIELDS | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('api', '0041_assetblob_download_count_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(remove_unpublished_asset_fields), | ||
] |
56 changes: 56 additions & 0 deletions
56
dandiapi/api/migrations/0043_asset_asset_metadata_no_computed_keys_or_published.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Generated by Django 4.1.1 on 2023-06-27 17:50 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('api', '0042_asset_remove_computed_fields'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddConstraint( | ||
model_name='asset', | ||
constraint=models.CheckConstraint( | ||
check=models.Q( | ||
models.Q( | ||
('published', False), | ||
models.Q( | ||
( | ||
'metadata__has_any_keys', | ||
[ | ||
'id', | ||
'path', | ||
'identifier', | ||
'contentUrl', | ||
'contentSize', | ||
'digest', | ||
'datePublished', | ||
'publishedBy', | ||
], | ||
), | ||
_negated=True, | ||
), | ||
), | ||
models.Q( | ||
('published', True), | ||
( | ||
'metadata__has_keys', | ||
[ | ||
'id', | ||
'path', | ||
'identifier', | ||
'contentUrl', | ||
'contentSize', | ||
'digest', | ||
'datePublished', | ||
'publishedBy', | ||
], | ||
), | ||
), | ||
_connector='OR', | ||
), | ||
name='asset_metadata_no_computed_keys_or_published', | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.