コード例 #1
0
        def create_tenant(tenant_name, attached_users=[]):
            from django.contrib.auth.models import Group
            from core.models import Tenant, FRRegistrationInfo
            from contacts.models import Address
            from invoicing.models import Currency

            tenant = Tenant(
                name=tenant_name,
                email='*****@*****.**',
                postal_address=Address(street_address='Street address'),
                billing_address=Address(street_address='Street address'),
                registration_info=FRRegistrationInfo(
                    share_capital='100 000 EUR',
                    siret='123 456 789 012 00001',
                    rcs_number='PARIS 005',
                    vat_number='FR01234567890'))

            # Tenant settings
            tenant.tenant_settings.invoicing.supported_currencies = [
                Currency.objects.get(symbol='EUR'),
                Currency.objects.get(symbol='USD')
            ]
            tenant.tenant_settings.invoicing.default_currency = Currency.objects.get(
                symbol='EUR')
            tenant.save()

            group = Group.objects.get(name=tenant.slug)
            for attached_user in attached_users:
                group.user_set.add(attached_user)
            group.save()
            return tenant
コード例 #2
0
        def create_tenant(tenant_name, attached_users=[]):
            from django.contrib.auth.models import Group
            from core.models import Tenant, FRRegistrationInfo
            from contacts.models import Address
            from invoicing.models import Currency

            tenant = Tenant(
                name=tenant_name,
                email='*****@*****.**',
                postal_address=Address(street_address='Street address'),
                billing_address=Address(street_address='Street address'),
                registration_info=FRRegistrationInfo(
                    share_capital='100 000 EUR',
                    siret='123 456 789 012 00001',
                    rcs_number='PARIS 005',
                    vat_number='FR01234567890'
                )
            )

            # Tenant settings
            tenant.tenant_settings.invoicing.supported_currencies = [
                Currency.objects.get(symbol='EUR'),
                Currency.objects.get(symbol='USD')
            ]
            tenant.tenant_settings.invoicing.default_currency = Currency.objects.get(symbol='EUR')
            tenant.save()

            group = Group.objects.get(name=tenant.slug)
            for attached_user in attached_users:
                group.user_set.add(attached_user)
            group.save()
            return tenant
コード例 #3
0
 def forwards(self, orm):
     supported_fonts = mapping.keys()
     for tenant in Tenant.objects():
         if tenant.report_settings.font_name.lower() in supported_fonts:
             font_name = tenant.report_settings.font_name.lower()
         else:
             font_name = 'bariol'
         tenant.update(set__report_settings__font_name=font_name)
コード例 #4
0
 def forwards(self, orm):
     supported_fonts = mapping.keys()
     for tenant in Tenant.objects():
         if tenant.report_settings.font_name.lower() in supported_fonts:
             font_name = tenant.report_settings.font_name.lower()
         else:
             font_name = 'bariol'
         tenant.update(set__report_settings__font_name=font_name)
コード例 #5
0
 def backwards(self, orm):
     supported_fonts = ('Courier', 'Helvetica', 'Bariol')
     for tenant in Tenant.objects():
         if tenant.report_settings.font_name.capitalize() in supported_fonts:
             font_name = tenant.report_settings.font_name.capitalize()
         else:
             font_name = 'Bariol'
         tenant.update(set__report_settings__font_name=font_name)
コード例 #6
0
 def backwards(self, orm):
     supported_fonts = ('Courier', 'Helvetica', 'Bariol')
     for tenant in Tenant.objects():
         if tenant.report_settings.font_name.capitalize(
         ) in supported_fonts:
             font_name = tenant.report_settings.font_name.capitalize()
         else:
             font_name = 'Bariol'
         tenant.update(set__report_settings__font_name=font_name)
コード例 #7
0
 def forwards(self, orm):
     for tenant in Tenant.objects():
         tenant.registration_info = FRRegistrationInfo(
             share_capital="10000 EUR",
             business_entity=u'SARL',
             vat_number=u'vat_number',
             siret=u'siret',
             rcs_number=u'rcs_number')
         tenant.save(validate=False)  # Disabled validation for VAT checks
コード例 #8
0
 def forwards(self, orm):
     for tenant in Tenant.objects():
         tenant.registration_info = FRRegistrationInfo(
             share_capital="10000 EUR",
             business_entity=u"SARL",
             vat_number=u"vat_number",
             siret=u"siret",
             rcs_number=u"rcs_number",
         )
         tenant.save(validate=False)  # Disabled validation for VAT checks
コード例 #9
0
    def forwards(self, orm):
        # Tenant
        for tenant in Tenant.objects():
            tenant._changed_fields = ['svg_logo', 'img_logo', 'terms', 'tenant_settings']
            tenant.save()

        # VosaeFile - Can't use `save()` because `uploaded_field` is required
        for vosae_file in VosaeFile.objects():
            vosae_file.update(set__tenant=vosae_file.tenant, set__issuer=vosae_file.issuer)

        # VosaeGroup
        for vosae_group in VosaeGroup.objects():
            vosae_group._changed_fields = ['tenant', 'created_by']
            vosae_group.save(force=True)

        # VosaeUser
        for vosae_user in VosaeUser.objects():
            vosae_user._changed_fields = ['tenant', 'groups']
            vosae_user.save()
コード例 #10
0
 def backwards(self, orm):
     for tenant in Tenant.objects():
         tenant.registration_info = RegistrationInfo(
             vat_number=u'vat_number')
         tenant.save()
コード例 #11
0
 def backwards(self, orm):
     for tenant in Tenant.objects():
         tenant.registration_info = RegistrationInfo(vat_number=u"vat_number")
         tenant.save()
コード例 #12
0
 def forwards(self, orm):
     for tenant in Tenant.objects():
         used_space = int(VosaeFile.objects.filter(tenant=tenant).sum('size'))
         tenant.tenant_settings.core.quotas.used_space = used_space
         tenant.tenant_settings.save()
コード例 #13
0
 def forwards(self, orm):
     for tenant in Tenant.objects():
         used_space = int(
             VosaeFile.objects.filter(tenant=tenant).sum('size'))
         tenant.tenant_settings.core.quotas.used_space = used_space
         tenant.tenant_settings.save()