<commit_before>from ckan.logic.action import get as get_core
from ckan.plugins import toolkit
import ckan.lib.helpers as h


@toolkit.side_effect_free
def package_show(context, data_dict):
    ''' This action is overriden so that the extra field "theme" is added.
    This is needed because when a dataset is exposed to DCAT it needs this
    field.

    Themes are coming from groups where a dataset is added to. The field
    "theme" exists in group's schema.'''

    result = get_core.package_show(context, data_dict)

    dataset_id = result.get('id')
    owner_org = result.get('owner_org')
    model = context.get('model')
    package = model.Package.get(dataset_id)
    groups = package.get_groups(group_type='group')
    themes = []

    for group in groups:
        theme = group.extras.get('theme')

        if theme:
            themes.append(theme)

    result = result.copy()
    extras = result.get('extras')
    extra_theme_found = False
    extra_publisher_email_found = False
    extra_publisher_url_found = False

    if extras:
        for extra in extras:
            if extra.get('key') == 'theme':
                extra['value'] = themes<commit_msg>Fix creating new showcase<commit_after>from ckan.logic.action import get as get_core
from ckan.plugins import toolkit
import ckan.lib.helpers as h


@toolkit.side_effect_free
def package_show(context, data_dict):
    ''' This action is overriden so that the extra field "theme" is added.
    This is needed because when a dataset is exposed to DCAT it needs this
    field.

    Themes are coming from groups where a dataset is added to. The field
    "theme" exists in group's schema.'''

    result = get_core.package_show(context, data_dict)

    dataset_id = result.get('id')
    owner_org = result.get('owner_org')
    model = context.get('model')
    package = model.Package.get(dataset_id)

    if package.type == 'showcase':
        return result

    groups = package.get_groups(group_type='group')
    themes = []

    for group in groups:
        theme = group.extras.get('theme')

        if theme:
            themes.append(theme)

    result = result.copy()
    extras = result.get('extras')
    extra_theme_found = False
    extra_publisher_email_found = False
    extra_publisher_url_found = False

    if extras:
        for extra in extras:
            if extra.get('key') == 'theme':
                extra['value'] = themes
{'fraction_non_alphanumeric': 0.09283050145047658, 'fraction_numerical': 0.0, 'mean_word_length': 2.9252032520325204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4650778', 'n_tokens_mistral': 730, 'n_tokens_neox': 702, 'n_words': 221}