Пример #1
0
def organization_update(context, data_dict):
    try:
        org_show = tk.get_action('organization_show')({}, {
            'id': data_dict['name']
        })

        if 'orgportals_portal_created' not in org_show:
            _create_portal(data_dict['name'])

        data_dict.update({'orgportals_portal_created': u'1'})
        org = update_core.organization_update(context, data_dict)

        return org
    except p.toolkit.ValidationError:
        return update_core.organization_update(context, data_dict)
Пример #2
0
def organization_patch(context, data_dict):
    '''Patch an organization

    :param id: the id or name of the organization
    :type id: string

    The difference between the update and patch methods is that the patch will
    perform an update of the provided parameters, while leaving all other
    parameters unchanged, whereas the update methods deletes all parameters
    not explicitly provided in the data_dict
    '''
    _check_access('organization_patch', context, data_dict)

    show_context = {
        'model': context['model'],
        'session': context['session'],
        'user': context['user'],
        'auth_user_obj': context['auth_user_obj'],
    }

    organization_dict = _get_action('organization_show')(
        show_context, {
            'id': _get_or_bust(data_dict, 'id')
        })

    patched = dict(organization_dict)
    patched.pop('display_name', None)
    patched.update(data_dict)
    return _update.organization_update(context, patched)
Пример #3
0
def organization_patch(context, data_dict):
    '''Patch an organization

    :param id: the id or name of the organization
    :type id: string

    The difference between the update and patch methods is that the patch will
    perform an update of the provided parameters, while leaving all other
    parameters unchanged, whereas the update methods deletes all parameters
    not explicitly provided in the data_dict
    '''
    _check_access('organization_patch', context, data_dict)

    show_context = {
        'model': context['model'],
        'session': context['session'],
        'user': context['user'],
        'auth_user_obj': context['auth_user_obj'],
        }

    organization_dict = _get_action('organization_show')(
        show_context,
        {'id': _get_or_bust(data_dict, 'id')})

    patched = dict(organization_dict)
    patched.pop('display_name', None)
    patched.update(data_dict)
    return _update.organization_update(context, patched)
Пример #4
0
def organization_update(context, data_dict):

    # Check if state is set from pending to active so we can notify users

    old_org_dict = p.toolkit.get_action('organization_show')({},
            {'id': data_dict.get('id') or data_dict.get('name')})
    old_state = old_org_dict.get('state')

    new_org_dict = update_core.organization_update(context, data_dict)
    new_state = new_org_dict.get('state')

    if old_state == 'approval_needed' and new_state == 'active':
        # Notify users
        _send_activation_notification_email(context, new_org_dict)
        h.flash_success('Publisher activated, a notification email has been sent to its administrators.')

    return new_org_dict
Пример #5
0
def organization_update(context, data_dict):

    # Check if state is set from pending to active so we can notify users

    old_org_dict = p.toolkit.get_action('organization_show')({},
            {'id': data_dict.get('id') or data_dict.get('name')})
    old_state = old_org_dict.get('state')

    new_org_dict = update_core.organization_update(context, data_dict)
    new_state = new_org_dict.get('state')

    if old_state == 'approval_needed' and new_state == 'active':
        # Notify users
        _send_activation_notification_email(context, new_org_dict)
        h.flash_success('Publisher activated, a notification email has been sent to its administrators.')

    return new_org_dict
Пример #6
0
def organization_update(context, data_dict):

    # Check if state is set from pending to active so we can notify users
    old_org_dict = p.toolkit.get_action('organization_show')(
        {}, {
            'id': data_dict.get('id') or data_dict.get('name')
        })
    old_state = old_org_dict.get('state')

    new_org_dict = update_core.organization_update(context, data_dict)
    new_state = new_org_dict.get('state')

    if old_state == 'approval_needed' and new_state == 'active':
        # Notify users
        _send_activation_notification_email(context, new_org_dict)
        h.flash_success(
            'Publisher activated, a notification email has been sent to its administrators.'
        )

    old_org_name = old_org_dict.get('name', '')
    new_org_name = new_org_dict.get('name', '')

    # Only sysadmin is allowed to change the publisher id (no need of any check here)
    if old_org_name != new_org_name:
        log.info(
            "Organization name changed - updating package name in background job"
        )
        job = jobs.enqueue(
            publisher_tasks.update_organization_dataset_names,
            [old_org_name, new_org_name,
             new_org_dict.get('id', '')])
        log.info("Job id: {}".format(job.id))
        h.flash_success(
            'Please reload the page after sometime to reflect change in publisher id for all datasets.'
        )
    return new_org_dict