From bec9f48c72e2b8c1ce8a8e6c7d31e0715b2eacb9 Mon Sep 17 00:00:00 2001 From: marwoodandrew Date: Thu, 28 Jul 2016 12:38:45 +1000 Subject: [PATCH] [SD-5046] Add AAP specific IPTC subject codes --- server/aap/io/__init__.py | 11 +++++++++ server/aap/io/data/aap_subject_codes.json | 1 + server/aap/io/iptc_extension.py | 27 +++++++++++++++++++++++ server/settings.py | 3 ++- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 server/aap/io/data/aap_subject_codes.json create mode 100644 server/aap/io/iptc_extension.py diff --git a/server/aap/io/__init__.py b/server/aap/io/__init__.py index e69de29bb..db60f66ba 100644 --- a/server/aap/io/__init__.py +++ b/server/aap/io/__init__.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8; -*- +# +# This file is part of Superdesk. +# +# Copyright 2013, 2014 Sourcefabric z.u. and contributors. +# +# 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 + +import aap.io.iptc_extension # noqa diff --git a/server/aap/io/data/aap_subject_codes.json b/server/aap/io/data/aap_subject_codes.json new file mode 100644 index 000000000..efe21f9f1 --- /dev/null +++ b/server/aap/io/data/aap_subject_codes.json @@ -0,0 +1 @@ +{"99000000": "editorial", "99001000": "advisory", "99002000": "briefings", "99003000": "diary", "99004000": "filing", "99005000": "highlights", "99006000": "service", "99007000": "staff", "99008000": "style", "99009000": "system"} \ No newline at end of file diff --git a/server/aap/io/iptc_extension.py b/server/aap/io/iptc_extension.py new file mode 100644 index 000000000..0e713bcbd --- /dev/null +++ b/server/aap/io/iptc_extension.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8; -*- +# +# This file is part of Superdesk. +# +# Copyright 2013, 2014 Sourcefabric z.u. and contributors. +# +# 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 + +"""IPTC module""" + +import os +from datetime import datetime +from superdesk.io.iptc import load_codes +from superdesk.io.iptc import subject_codes + + +dirname = os.path.dirname(os.path.realpath(__file__)) +data_subject_codes = os.path.join(dirname, 'data', 'aap_subject_codes.json') +aap_subject_codes = load_codes(data_subject_codes) + + +def init_app(app): + last_modified = datetime(2016, 7, 28) + app.subjects.register(aap_subject_codes, last_modified) + subject_codes.update(aap_subject_codes) diff --git a/server/settings.py b/server/settings.py index 6ad5a1823..a964189f7 100644 --- a/server/settings.py +++ b/server/settings.py @@ -137,7 +137,8 @@ def env(variable, fallback_value=None): 'aap.publish.formatters', 'aap_mm', 'aap.io.feed_parsers', - 'aap.data_consistency' + 'aap.data_consistency', + 'aap.io.iptc_extension' ]) RENDITIONS = {