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

add a new migration script to update width for existing profile fields [SDESK-7099] #2495

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions superdesk/data_updates/00030_20231127-142300_content_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8; -*-
# This file is part of Superdesk.
# For the full copyright and license information, please see the
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license
#
# Author : Ketan
# Creation: 2023-11-27 14:23

from superdesk.commands.data_updates import BaseDataUpdate
from eve.utils import config


class DataUpdate(BaseDataUpdate):
resource = "content_types"

def forwards(self, mongodb_collection, mongodb_database):
for profile in mongodb_collection.find({}):
try:
editor = profile.get("editor", {})
for field, properties in editor.items():
if properties and "sdWidth" not in properties:
properties["sdWidth"] = "full"

mongodb_collection.update(
{"_id": profile.get(config.ID_FIELD)}, {"$set": {"editor": profile["editor"]}}
)
print(f"Content Profile {profile['_id']} updated successfully")
except Exception as e:
print(f"Error updating Content Profile {profile['_id']}: {str(e)}")

def backwards(self, mongodb_collection, mongodb_database):
raise NotImplementedError()
Loading