def _create_unexisting_org(self, org_name):
        try:
            p.toolkit.get_action('organization_show')({}, {'id': org_name})

        except p.toolkit.ObjectNotFound:
            context = {"model": model, 'session': Session, 'user': self.config['user']}
            organization_create(context, {"name": org_name})
示例#2
0
def organization_create(context, data_dict):
    try:
        data_dict.update({'orgportals_portal_created': u'1'})
        org = create_core.organization_create(context, data_dict)
        _create_portal(data_dict['name'])

        return org
    except p.toolkit.ValidationError:
        return create_core.organization_create(context, data_dict)
示例#3
0
def organization_create(context, data_dict):

    # When creating a publisher, if the user is not a sysadmin it will be
    # created as pending, and sysadmins notified

    notify_sysadmins = False
    try:
        p.toolkit.check_access('sysadmin', context, data_dict)
    except p.toolkit.NotAuthorized:
        # Not a sysadmin, create as pending and notify sysadmins (if all went
        # well)
        context['__iati_state_pending'] = True
        data_dict['state'] = 'approval_needed'
        notify_sysadmins = True

    org_dict = create_core.organization_create(context, data_dict)

    if data_dict.get(
            'state', ''
    ) == "approval_needed":  # Send email if created user is not sysadmin
        try:
            user = context['auth_user_obj']
            body = emailer.new_publisher_email_to_publisher_body.format(
                user_name=context['user'])
            subject = "[IATI Registry] New Publisher: {0} - Status: {1}".format(
                data_dict['title'].encode('utf8'), "Pending")
            emailer.send_email(body, subject, user.email, content_type='html')
        except Exception as e:
            log.error("Failed to send notification email to publisher")
            log.error(e)

    if notify_sysadmins:
        _send_new_publisher_email(context, org_dict)

    return org_dict
示例#4
0
def organization_create(context, data_dict):

    # When creating an organization, if the user is not a sysadmin it will be
    # created as pending, and sysadmins notified

    org_dict = create_core.organization_create(context, data_dict)

    # We create an organization as usual because we can't set
    # state=approval_needed on creation step and then
    # we patch the organization

    notify_sysadmins = False
    user = get_core.user_show(context, {'id': context['user']})
    if not user['sysadmin']:
        # Not a sysadmin, create as pending and notify sysadmins (if all went
        # well)
        context['__unhcr_state_pending'] = True
        org_dict = patch_core.organization_patch(context, {
            'id': org_dict['id'],
            'state': 'approval_needed'
        })
        notify_sysadmins = True

    if notify_sysadmins:
        try:
            mail_data_container_request_to_sysadmins(context, org_dict)
        except MailerException:
            message = '[email] Data container request notification is not sent: {0}'
            log.critical(message.format(org_dict['title']))

    return org_dict
示例#5
0
def organization_create(context, data_dict):

    # When creating a publisher, if the user is not a sysadmin it will be
    # created as pending, and sysadmins notified

    notify_sysadmins = False
    try:
        p.toolkit.check_access('sysadmin', context, data_dict)
    except p.toolkit.NotAuthorized:
        # Not a sysadmin, create as pending and notify sysadmins (if all went
        # well)
        context['__iati_state_pending'] = True
        data_dict['state'] = 'approval_needed'
        notify_sysadmins = True
    org_dict = create_core.organization_create(context, data_dict)

    if notify_sysadmins:
        _send_new_publisher_email(context, org_dict)

    return org_dict
示例#6
0
def organization_create(context, data_dict):

    # When creating a publisher, if the user is not a sysadmin it will be
    # created as pending, and sysadmins notified

    notify_sysadmins = False
    try:
        p.toolkit.check_access('sysadmin', context, data_dict)
    except p.toolkit.NotAuthorized:
        # Not a sysadmin, create as pending and notify sysadmins (if all went
        # well)
        context['__iati_state_pending'] = True
        data_dict['state'] = 'approval_needed'
        notify_sysadmins = True
    org_dict = create_core.organization_create(context, data_dict)

    if notify_sysadmins:
        _send_new_publisher_email(context, org_dict)

    return org_dict