-
Notifications
You must be signed in to change notification settings - Fork 42
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 #186 from apache/AIRAVATA-3698-fix-page-revision-c…
…ontent-type AIRAVATA-3698 management command to fix up the content type id in page revision json
- Loading branch information
Showing
15 changed files
with
30 additions
and
304 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
django_airavata/wagtailapps/base/management/commands/fix_page_revision_content_type.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,23 @@ | ||
|
||
import json | ||
|
||
from django.core.management.base import BaseCommand | ||
from wagtail.core.models import PageRevision | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Fix the content_type id in the page revisions content_type which may be correct due to being imported from a different Django instance" | ||
|
||
def handle(self, **options): | ||
fixed_count = 0 | ||
for pr in PageRevision.objects.all(): | ||
content_json = json.loads(pr.content_json) | ||
if content_json['content_type'] != pr.page.content_type.id: | ||
content_json['content_type'] = pr.page.content_type.id | ||
pr.content_json = json.dumps(content_json) | ||
pr.save() | ||
fixed_count = fixed_count + 1 | ||
if fixed_count > 0: | ||
self.stdout.write( | ||
self.style.SUCCESS(f"Successfully fixed the content type of {fixed_count} page revisions") | ||
) |
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
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_cybergateway_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_default_gateway.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_hpcgateway_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_nanoconfinement_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_osu_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_phasta_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_seagrid_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_searching_sra_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_simccs_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_simvascular_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_siu_data.py
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
django_airavata/wagtailapps/base/management/commands/load_south_dakota_data.py
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