Пример #1
0
 def setUpClass(cls):
     from contacts.models import Organization
     super(ContactResourceTest, cls).setUpClass()
     # Create first an organization which will be referenced
     organization = Organization(tenant=settings.TENANT, creator=settings.VOSAE_USER, corporate_name=u"My Company", private=False)
     organization.save()
     contact_data.update(organization=cls.resourceDetailURI('organization', unicode(organization.id)))
     cls.created_documents = [organization]
Пример #2
0
 def setUpClass(cls):
     from contacts.models import Organization
     super(ContactResourceTest, cls).setUpClass()
     # Create first an organization which will be referenced
     organization = Organization(tenant=settings.TENANT,
                                 creator=settings.VOSAE_USER,
                                 corporate_name=u"My Company",
                                 private=False)
     organization.save()
     contact_data.update(organization=cls.resourceDetailURI(
         'organization', unicode(organization.id)))
     cls.created_documents = [organization]
Пример #3
0
def fill_tenant_initial_data(tenant, language_code):
    """
    This task creates inital data when a new :class:`~core.models.Tenant` is created
    """
    from core.models import VosaeUser
    from contacts.models import Contact, Organization, Email, Address
    from invoicing.models import Item, Tax, Currency

    with respect_language(language_code):
        initial_vosae_user = VosaeUser.objects.get(tenant=tenant)

        # Creates default taxes, based on registration country
        for tax_percent, tax_name in tenant.registration_info.DEFAULT_TAXES:
            Tax(tenant=tenant, name=tax_name, rate=tax_percent).save()

        # Creates a shared organization
        Organization(
            tenant=tenant,
            creator=initial_vosae_user,
            corporate_name=u'Vosae',
            emails=[
                Email(type=u'WORK', email=u'*****@*****.**')
            ],
            addresses=[
                Address(type=u'WORK', street_address=u'35 Rue Lesdiguières', postal_code=u'38000', city=u'Grenoble', country=u'France')
            ],
            note=_('We\'d like to make it right'),
            private=False
        ).save()

        # Creates a shared contact
        Contact(
            tenant=tenant,
            creator=initial_vosae_user,
            name=_('Support'),
            firstname=u'Vosae',
            role=_('The best support'),
            emails=[
                Email(type=u'WORK', email=u'*****@*****.**')
            ],
            organization=Organization.objects.get(tenant=tenant, corporate_name=u'Vosae'),
            private=False
        ).save()

        # Creates an item
        Item(
            tenant=tenant,
            reference=_('TEST-ITEM'),
            description=_('Test item'),
            unit_price=Decimal('1000'),
            currency=Currency.objects.get(symbol='EUR'),
            tax=Tax.objects.filter(tenant=tenant).first(),
            type=u'SERVICE'
        ).save()
Пример #4
0
    def forwards(self, orm):
        # Contact
        for contact in Contact.objects():
            contact._changed_fields = [
                'tenant', 'creator', 'photo', 'organization', 'subscribers'
            ]
            contact.save()

        # Organization
        for organization in Organization.objects():
            organization._changed_fields = [
                'tenant', 'creator', 'photo', 'subscribers'
            ]
            organization.save()

        # ContactGroup
        for contact_group in ContactGroup.objects():
            contact_group._changed_fields = ['tenant']
            contact_group.save()