예제 #1
0
    def test_send_invite_email_with_group(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        group = factories.Group()
        role = 'member'

        # send email
        mailer.send_invite(user_obj, group_dict=group, role=role)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        msg = msgs[0]
        body = self.get_email_body(msg[3])
        assert_in(group['title'], body)
        assert_in(h.roles_translated()[role], body)
예제 #2
0
    def test_send_invite_email_with_org(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        org = factories.Organization()
        role = 'admin'

        # send email
        mailer.send_invite(user_obj, group_dict=org, role=role)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        msg = msgs[0]
        body = self.get_email_body(msg[3])
        assert_in(org['title'], body)
        assert_in(h.roles_translated()[role], body)
예제 #3
0
파일: test_mailer.py 프로젝트: vjf/ckan
    def test_send_invite_email_with_org(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        org = factories.Organization()
        role = 'admin'

        # send email
        mailer.send_invite(user_obj, group_dict=org, role=role)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        msg = msgs[0]
        body = self.get_email_body(msg[3])
        assert_in(org['title'], body)
        assert_in(h.roles_translated()[role], body)
예제 #4
0
파일: test_mailer.py 프로젝트: vjf/ckan
    def test_send_invite_email_with_group(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        group = factories.Group()
        role = 'member'

        # send email
        mailer.send_invite(user_obj, group_dict=group, role=role)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        msg = msgs[0]
        body = self.get_email_body(msg[3])
        assert_in(group['title'], body)
        assert_in(h.roles_translated()[role], body)
예제 #5
0
    def test_send_invite_email_with_org(self, mail_server):
        user = factories.User()
        user_obj = model.User.by_name(user["name"])

        org = factories.Organization()
        role = "admin"

        # send email
        mailer.send_invite(user_obj, group_dict=org, role=role)

        # check it went to the mock smtp server
        msgs = mail_server.get_smtp_messages()
        msg = msgs[0]
        body = self.get_email_body(msg[3])
        assert org["title"] in six.ensure_text(body)
        assert h.roles_translated()[role] in six.ensure_text(body)
예제 #6
0
    def test_send_invite_email_with_group(self, mail_server):
        user = factories.User()
        user_obj = model.User.by_name(user["name"])

        group = factories.Group()
        role = "member"

        # send email
        mailer.send_invite(user_obj, group_dict=group, role=role)

        # check it went to the mock smtp server
        msgs = mail_server.get_smtp_messages()
        msg = msgs[0]
        body = self.get_email_body(msg[3])
        assert group["title"] in six.ensure_text(body)
        assert h.roles_translated()[role] in six.ensure_text(body)
예제 #7
0
    def test_send_invite_email_with_org(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        org = factories.Organization()
        role = 'admin'

        # We need to provide a context as url_for is used internally
        with self.app.flask_app.test_request_context():
            # send email
            mailer.send_invite(user_obj, group_dict=org, role=role)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        msg = msgs[0]
        body = self.get_email_body(msg[3])
        assert_in(org['title'], body)
        assert_in(h.roles_translated()[role], body)
예제 #8
0
파일: mailer.py 프로젝트: PublicaMundi/ckan
def get_invite_body(user, group_dict=None, role=None):
    if group_dict:
        group_type = (_('organization') if group_dict['is_organization']
                      else _('group'))

    extra_vars = {
        'reset_link': get_reset_link(user),
        'site_title': config.get('ckan.site_title'),
        'site_url': config.get('ckan.site_url'),
        'user_name': user.name,
    }
    if role:
        extra_vars['role_name'] = h.roles_translated().get(role, _(role))
    if group_dict:
        extra_vars['group_type'] = group_type
        extra_vars['group_title'] = group_dict.get('title')

    # NOTE: This template is translated
    return render_jinja2('emails/invite_user.txt', extra_vars)
예제 #9
0
파일: mailer.py 프로젝트: xiaokaixi/ckan
def get_invite_body(user, group_dict=None, role=None):
    if group_dict:
        group_type = (_('organization')
                      if group_dict['is_organization'] else _('group'))

    extra_vars = {
        'reset_link': get_reset_link(user),
        'site_title': config.get('ckan.site_title'),
        'site_url': config.get('ckan.site_url'),
        'user_name': user.name,
    }
    if role:
        extra_vars['role_name'] = h.roles_translated().get(role, _(role))
    if group_dict:
        extra_vars['group_type'] = group_type
        extra_vars['group_title'] = group_dict.get('title')

    # NOTE: This template is translated
    return render_jinja2('emails/invite_user.txt', extra_vars)