Skip to content

Commit

Permalink
set type on existing content types (#2549)
Browse files Browse the repository at this point in the history
SDESK-7231
  • Loading branch information
petrjasek committed Apr 4, 2024
1 parent 2800e0a commit 0f83280
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
34 changes: 34 additions & 0 deletions superdesk/data_updates/00032_20240404-123019_content_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- 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 : petr
# Creation: 2024-04-04 12:30

from superdesk.commands.data_updates import BaseDataUpdate


class DataUpdate(BaseDataUpdate):
resource = "content_types"

def forwards(self, mongodb_collection, mongodb_database):
mongodb_collection.update_many(
{"type": {"$exists": False}, "_id": {"$nin": ["text", "picture", "video", "audio"]}},
{
"$set": {
"type": "text",
},
},
)

def backwards(self, mongodb_collection, mongodb_database):
mongodb_collection.update_many(
{"type": "text"},
{
"$unset": {
"type": 1,
},
},
)
9 changes: 9 additions & 0 deletions superdesk/factory/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ def get_manager(app):
:param app: superdesk app instance
"""
return SuperdeskManager(app, superdesk.COMMANDS)


if __name__ == "__main__":
from .app import get_app
import superdesk.commands

app = get_app()

get_manager(app).run()

0 comments on commit 0f83280

Please sign in to comment.