예제 #1
0
    def notify_admin_users(self, org_obj, new_members, invited_memberes, role):

        context = self._get_context()
        org_admins = self._action('member_list')(context, {
            'id': org_obj.id,
            'capacity': 'admin',
            'object_type': 'user'
        })
        admins = []
        for admin_tuple in org_admins:
            admin_id = admin_tuple[0]
            admins.append(hdx_h.hdx_get_user_info(admin_id))
        admins_with_email = [admin for admin in admins if admin['email']]

        messages = []
        if new_members:
            messages.append(
                _('The following persons have been added to {} as {}: ').
                format(org_obj.display_name, role) + ', '.join(new_members))
        if invited_memberes:
            messages.append(
                _('The following persons have been invited to {} as {}: '
                  ).format(org_obj.display_name, role) +
                ', '.join(invited_memberes))

        data_dict = {
            'message':
            '\n\n'.join(messages),
            'subject':
            'HDX Notification: new members were added to {}'.format(
                org_obj.display_name),
            'admins':
            admins_with_email
        }
        org_helper.notify_admins(data_dict)
예제 #2
0
    def _current_user_info(self, member_list):
        if c.userobj:
            member_info = hdx_h.hdx_get_user_info(c.userobj.id)
            member_info['role'] = None
            for m in member_list:
                if m[0] == member_info['id']:
                    member_info['role'] = m[3]

            return member_info
        return {}
예제 #3
0
    def request_editor_for_org(self, org_id):
        '''
            user_email, name of user, username, organization name,  list with org-admins emails,
        '''
        try:
            msg = _('Please allow me to submit data to this organization ')
            user = hdx_h.hdx_get_user_info(c.user)
            context = {'model': model, 'session': model.Session,
                       'user': c.user or c.author}
            org_admins = tk.get_action('member_list')(context,{'id':org_id,'capacity':'admin','object_type':'user'})
            admins=[]
            for admin_tuple in org_admins:
                admin_id = admin_tuple[0]
                admins.append(hdx_h.hdx_get_user_info(admin_id))
            admins_with_email = [admin for admin in admins if admin['email']]

            data_dict = {'display_name': user['display_name'], 'name': user['name'],
                         'email': user['email'], 'organization': org_id, 
                         'message': msg, 'admins': admins_with_email}
            tk.get_action('hdx_send_editor_request_for_org')(context, data_dict)
            h.flash_success(_('Message sent'))
        except hdx_mail.NoRecipientException, e:
            h.flash_error(_(str(e)))
예제 #4
0
    def request_editor_for_org(self, org_id):
        '''
            user_email, name of user, username, organization name,  list with org-admins emails,
        '''
        try:
            msg = _('Please allow me to submit data to this organization ')
            user = hdx_h.hdx_get_user_info(c.user)
            context = {
                'model': model,
                'session': model.Session,
                'user': c.user or c.author
            }
            org_admins = tk.get_action('member_list')(context, {
                'id': org_id,
                'capacity': 'admin',
                'object_type': 'user'
            })
            admins = []
            for admin_tuple in org_admins:
                admin_id = admin_tuple[0]
                admins.append(hdx_h.hdx_get_user_info(admin_id))
            admins_with_email = [admin for admin in admins if admin['email']]

            data_dict = {
                'display_name': user['display_name'],
                'name': user['name'],
                'email': user['email'],
                'organization': org_id,
                'message': msg,
                'admins': admins_with_email
            }
            tk.get_action('hdx_send_editor_request_for_org')(context,
                                                             data_dict)
            h.flash_success(_('Message sent'))
        except hdx_mail.NoRecipientException, e:
            h.flash_error(_(str(e)))