Ejemplo n.º 1
0
    def _create_emails(self):
        if persons.contact_model_is_custom():
            self.fail(
                'Cannot use _EmailsTestCase._create_emails() with custom Contact model.'
            )

        if persons.organisation_model_is_custom():
            self.fail(
                'Cannot use _EmailsTestCase._create_emails() with custom Organisation model.'
            )

        user = self.user

        create_c = partial(Contact.objects.create, user=user)
        contacts = [
            create_c(first_name='Vincent',
                     last_name='Law',
                     email='*****@*****.**'),
            create_c(first_name='Daedalus',
                     last_name='??',
                     email='*****@*****.**'),
        ]

        create_o = partial(Organisation.objects.create, user=user)
        orgas = [
            create_o(name='Venus gate', email='*****@*****.**'),
            create_o(name='Nerv', email='*****@*****.**'),
        ]

        url = self._build_create_entitymail_url(contacts[0])
        self.assertGET200(url)

        response = self.client.post(
            url,
            data={
                'user':
                user.id,
                'sender':
                '*****@*****.**',
                'c_recipients':
                self.formfield_value_multi_creator_entity(
                    contacts[0], contacts[1]),
                'o_recipients':
                self.formfield_value_multi_creator_entity(orgas[0], orgas[1]),
                'subject':
                'Under arrest',
                'body':
                'Freeze',
                'body_html':
                '<p>Freeze !</p>',
            })
        self.assertNoFormError(response)

        emails = EntityEmail.objects.all()
        self.assertEqual(4, len(emails))

        return emails
Ejemplo n.º 2
0
# -*- coding: utf-8 -*-

from django.urls import re_path

from creme import persons
from creme.creme_core.conf.urls import Swappable, swap_manager

from .views import vcf  # TODO: merge in a views.py ??

urlpatterns = [
    re_path(r'^(?P<contact_id>\d+)/generate_vcf[/]?$',
            vcf.vcf_export,
            name='vcfs__export'),
    *swap_manager.add_group(
        lambda: persons.contact_model_is_custom() or persons.
        organisation_model_is_custom() or persons.address_model_is_custom(),
        Swappable(re_path(r'^vcf[/]?', vcf.vcf_import, name='vcfs__import')),
        app_name='vcfs',
    ).kept_patterns(),
]
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-

from unittest import skipIf

from creme import persons
from creme.documents import get_document_model
from creme.documents.tests.base import _DocumentsTestCase

skip_address_tests = persons.address_model_is_custom()
skip_contact_tests = persons.contact_model_is_custom()
skip_organisation_tests = persons.organisation_model_is_custom()

Document = get_document_model()

Address = persons.get_address_model()
Contact = persons.get_contact_model()
Organisation = persons.get_organisation_model()


def skipIfCustomAddress(test_func):
    return skipIf(skip_address_tests, 'Custom Address model in use')(test_func)


def skipIfCustomContact(test_func):
    return skipIf(skip_contact_tests, 'Custom Contact model in use')(test_func)


def skipIfCustomOrganisation(test_func):
    return skipIf(skip_organisation_tests,
                  'Custom Organisation model in use')(test_func)