-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds an upgrade command `edrn_nukephotos` which should be run once at upgrade time to nuke all the PI photos that have been duplicated over time - Adjusts site ingest so that it checks for an existing photo first and re-uses it - Changes name of photo to include not just surname but also ID number so we can better re-use photos - Adds update steps to cbiit-deploy, cbiit-deploy-prod, and devrebuild
- Loading branch information
1 parent
3ab9520
commit 6e33ed9
Showing
7 changed files
with
110 additions
and
13 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/eke.knowledge/src/eke/knowledge/management/commands/edrn_nukephotos.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,40 @@ | ||
# encoding: utf-8 | ||
|
||
'''😌 EDRN Site Content: nuke photos.''' | ||
|
||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
from wagtail.images.models import Image | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Delete specific instances of duplicate photos' | ||
|
||
_to_nuke = ( | ||
'Photo of Chinnaiyan', | ||
'Photo of Feng', | ||
'Photo of Hanash', | ||
'Photo of Semmes', | ||
'Photo of Srivastava', | ||
'Photo of Stass', | ||
) | ||
|
||
def nuke_photos(self): | ||
for title in self._to_nuke: | ||
count = Image.objects.filter(title=title).count() | ||
if count > 0: | ||
self.stdout.write(f'Deleting {count} instance(s) of {title}') | ||
Image.objects.filter(title=title).delete() | ||
|
||
def handle(self, *args, **options): | ||
self.stdout.write('Deleting specific instances of duplicate photos') | ||
|
||
old = getattr(settings, 'WAGTAILREDIRECTS_AUTO_CREATE', True) | ||
try: | ||
settings.WAGTAILREDIRECTS_AUTO_CREATE = False | ||
settings.WAGTAILSEARCH_BACKENDS['default']['AUTO_UPDATE'] = False | ||
self.nuke_photos() | ||
finally: | ||
settings.WAGTAILREDIRECTS_AUTO_CREATE = old | ||
settings.WAGTAILSEARCH_BACKENDS['default']['AUTO_UPDATE'] = True | ||
self.stdout.write("Job's done!") |
20 changes: 20 additions & 0 deletions
20
src/eke.knowledge/src/eke/knowledge/migrations/0013_alter_person_photo.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,20 @@ | ||
# Generated by Django 4.1.9 on 2023-10-12 20:18 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('wagtailimages', '0025_alter_image_file_alter_rendition_file'), | ||
('ekeknowledge', '0012_datacollectionindex_preamble'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='person', | ||
name='photo', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='person_photograph', to='wagtailimages.image'), | ||
), | ||
] |
20 changes: 20 additions & 0 deletions
20
src/eke.knowledge/src/eke/knowledge/migrations/0014_alter_person_photo.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,20 @@ | ||
# Generated by Django 4.1.9 on 2023-10-12 21:17 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('wagtailimages', '0025_alter_image_file_alter_rendition_file'), | ||
('ekeknowledge', '0013_alter_person_photo'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='person', | ||
name='photo', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='person_photograph', to='wagtailimages.image'), | ||
), | ||
] |
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
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