Ejemplo n.º 1
0
def _mail_process_status(locale, member_user, approve, group_name, capacity):
    # current_locale = get_lang()
    # if locale == 'en':
    #     _reset_lang()
    # else:
    #     set_lang(locale)

    role_name = _(capacity)

    subject = hdx_util._SUBJECT_MEMBERSHIP_APPROVED if approve else hdx_util._SUBJECT_MEMBERSHIP_REJECTED
    message_template = hdx_util._MESSAGE_MEMBERSHIP_APPROVED if approve else hdx_util._MESSAGE_MEMBERSHIP_REJECTED

    message = message_template.format(**{
        'role': role_name,
        'organization': group_name
    })
    try:
        hdx_mail.send_mail(
            [{
                'display_name': member_user.display_name
                or member_user.fullname,
                'email': member_user.email
            }], subject, message)
    except MailerException, e:
        log.error(e)
Ejemplo n.º 2
0
def hdx_send_new_org_request(context, data_dict):
    _check_access('hdx_send_new_org_request',context, data_dict)

    email = config.get('hdx.orgrequest.email', None)
    if not email:
        email = '*****@*****.**'
    display_name = 'HDX Feedback'

    ckan_username = c.user
    ckan_email = ''
    if c.userobj:
        ckan_email = c.userobj.email

    subject = _('New organization request:') + ' ' \
        + data_dict['title']
    body = _('New organization request \n' \
        'Organization Name: {org_name}\n' \
        'Organization Description: {org_description}\n' \
        'Organization URL: {org_url}\n' \
        'Person requesting: {person_name}\n' \
        'Person\'s email: {person_email}\n' \
        'Person\'s ckan username: {ckan_username}\n' \
        'Person\'s ckan email: {ckan_email}\n' \
        '(This is an automated mail)' \
    '').format(org_name=data_dict['title'], org_description = data_dict['description'],
               org_url = data_dict['org_url'], person_name = data_dict['your_name'], person_email = data_dict['your_email'],
               ckan_username=ckan_username, ckan_email= ckan_email)

    hdx_mail.send_mail([{'display_name': display_name, 'email': email}], subject, body)
Ejemplo n.º 3
0
def _mail_new_membership_request(locale, admin, group, url, user_obj, data_dict=None, admin_list=None):
    current_locale = get_lang()

    if locale == 'en':
        _reset_lang()
    else:
        set_lang(locale)
    subject = hdx_util._SUBJECT_MEMBERSHIP_REQUEST.format(**{
        'user_fullname': user_obj.display_name
    })

    user_message = data_dict.get('message') if data_dict else 'Please add me to this organisation'
    message = hdx_util._MESSAGE_MEMBERSHIP_REQUEST.format(**{
        'user_fullname': user_obj.display_name,
        'user_email': user_obj.email,
        'org_title': group.display_name,
        'org_add_member_url': (config['ckan.site_url'] + '/organization/members/{org_name}').format(
            org_name=group.name),
        'user_message': user_message
    })

    try:
        # mail_user(admin, subject, message)
        # HDX change
        if admin:
            hdx_mail.send_mail([{'display_name': admin.display_name or admin.fullname, 'email': admin.email}], subject,
                               message)
        else:
            hdx_mail.send_mail(admin_list, subject, message, True)

    except MailerException, e:
        log.error(e)
Ejemplo n.º 4
0
def hdx_send_editor_request_for_org(context, data_dict):
    _check_access('hdx_send_editor_request_for_org',context, data_dict)

    body = _('New request editor/admin role\n' \
    'Full Name: {fn}\n' \
    'Username: {username}\n' \
    'Email: {mail}\n' \
    'Organization: {org}\n' \
    'Message from user: {msg}\n' \
    '(This is an automated mail)' \
    '').format(fn=data_dict['display_name'], username=data_dict['name'], mail=data_dict['email'], 
               org=data_dict['organization'], msg=data_dict.get('message', ''))

    hdx_mail.send_mail(data_dict['admins'], _('New Request Membership'), body)
Ejemplo n.º 5
0
def hdx_send_editor_request_for_org(context, data_dict):
    _check_access('hdx_send_editor_request_for_org', context, data_dict)

    body = _('New request editor/admin role\n' \
             'Full Name: {fn}\n' \
             'Username: {username}\n' \
             'Email: {mail}\n' \
             'Organisation: {org}\n' \
             'Message from user: {msg}\n' \
             '(This is an automated mail)' \
             '').format(fn=data_dict['display_name'], username=data_dict['name'], mail=data_dict['email'],
                        org=data_dict['organization'], msg=data_dict.get('message', ''))
    if configuration.config.get('hdx.onboarding.send_confirmation_email',
                                'false') == 'true':
        hdx_mail.send_mail(data_dict['admins'],
                           _('New Request Membership'),
                           body,
                           one_email=True)
Ejemplo n.º 6
0
def hdx_send_new_org_request(context, data_dict):
    _check_access('hdx_send_new_org_request', context, data_dict)

    email = config.get('hdx.orgrequest.email', None)
    if not email:
        email = '*****@*****.**'
    display_name = 'HDX Feedback'

    ckan_username = c.user
    ckan_email = ''
    if c.userobj:
        ckan_email = c.userobj.email

    subject = _('New organisation request:') + ' ' \
              + data_dict.get('name')
    body = _('<h3>New organisation request </h3><br/>' \
             'Organisation Name: {org_name}<br/>' \
             'Organisation Description: {org_description}<br/>' \
             'Organisation Data Description: {org_description_data}<br/>' \
             'Work email: {org_work_email}<br/>' \
             'Organisation URL: {org_url}<br/>' \
             'Organisation Type: {hdx_org_type}<br/>' \
             'Organisation Acronym: {org_acronym}<br/>' \
             'Person requesting: {person_name}<br/>' \
             'Person\'s email: {person_email}<br/>' \
             'Person\'s ckan username: {ckan_username}<br/>' \
             'Person\'s ckan email: {ckan_email}<br/>' \
             'Request time: {request_time}<br/>' \
             '(This is an automated mail)<br/><br/>' \
             '').format(org_name=data_dict.get('name',''), org_description=data_dict.get('description',''),
                        org_description_data=data_dict.get('description_data',''),
                        org_work_email=data_dict.get('work_email', ''),
                        org_url=data_dict.get('org_url',''), org_acronym=data_dict.get('acronym',''),
                        hdx_org_type=data_dict.get('org_type',''),
                        person_name=data_dict.get('your_name',''),
                        person_email=data_dict.get('your_email',''),
                        ckan_username=ckan_username, ckan_email=ckan_email,
                        request_time=datetime.datetime.now().isoformat())
    if configuration.config.get('hdx.onboarding.send_confirmation_email',
                                'false') == 'true':
        hdx_mail.send_mail([{
            'display_name': display_name,
            'email': email
        }], subject, body)