Exemplo n.º 1
0
 def invoice_form(self):
     if not self.invoice_address.pk:
         initial = {
             'name_parts': {
                 k[21:].replace('-', '_'): v
                 for k, v in self.cart_session.get('widget_data', {}).items()
                 if k.startswith('invoice-address-name-')
             },
             'company': self.cart_session.get('widget_data', {}).get('invoice-address-company', ''),
             'is_business': bool(self.cart_session.get('widget_data', {}).get('invoice-address-company', '')),
             'street': self.cart_session.get('widget_data', {}).get('invoice-address-street', ''),
             'zipcode': self.cart_session.get('widget_data', {}).get('invoice-address-zipcode', ''),
             'city': self.cart_session.get('widget_data', {}).get('invoice-address-city', ''),
             'country': self.cart_session.get('widget_data', {}).get('invoice-address-country', ''),
         }
     else:
         initial = {}
     if not self.address_asked and self.request.event.settings.invoice_name_required:
         return InvoiceNameForm(data=self.request.POST if self.request.method == "POST" else None,
                                event=self.request.event,
                                request=self.request,
                                instance=self.invoice_address,
                                initial=initial,
                                validate_vat_id=False, all_optional=self.all_optional)
     return InvoiceAddressForm(data=self.request.POST if self.request.method == "POST" else None,
                               event=self.request.event,
                               request=self.request,
                               initial=initial,
                               instance=self.invoice_address,
                               validate_vat_id=self.eu_reverse_charge_relevant, all_optional=self.all_optional)
Exemplo n.º 2
0
    def invoice_form(self):
        wd = self.cart_session.get('widget_data', {})
        if not self.invoice_address.pk:
            wd_initial = {
                'name_parts': {
                    k[21:].replace('-', '_'): v
                    for k, v in wd.items()
                    if k.startswith('invoice-address-name-')
                },
                'company': wd.get('invoice-address-company', ''),
                'is_business': bool(wd.get('invoice-address-company', '')),
                'street': wd.get('invoice-address-street', ''),
                'zipcode': wd.get('invoice-address-zipcode', ''),
                'city': wd.get('invoice-address-city', ''),
                'country': wd.get('invoice-address-country', ''),
            }
        else:
            wd_initial = {}
        initial = dict(wd_initial)

        override_sets = self._contact_override_sets
        for overrides in override_sets:
            initial.update({
                k: v['initial']
                for k, v in overrides.items() if 'initial' in v
            })

        if not self.address_asked and self.request.event.settings.invoice_name_required:
            f = InvoiceNameForm(data=self.request.POST
                                if self.request.method == "POST" else None,
                                event=self.request.event,
                                request=self.request,
                                instance=self.invoice_address,
                                initial=initial,
                                validate_vat_id=False,
                                all_optional=self.all_optional)
        else:
            f = InvoiceAddressForm(
                data=self.request.POST
                if self.request.method == "POST" else None,
                event=self.request.event,
                request=self.request,
                initial=initial,
                instance=self.invoice_address,
                validate_vat_id=self.eu_reverse_charge_relevant,
                all_optional=self.all_optional)
        for name, field in f.fields.items():
            if wd_initial.get(name) and wd.get('fix', '') == 'true':
                field.disabled = True

        for overrides in override_sets:
            for fname, val in overrides.items():
                if 'disabled' in val and fname in f.fields:
                    f.fields[fname].disabled = val['disabled']

        return f
Exemplo n.º 3
0
 def invoice_form(self):
     if not self.request.event.settings.invoice_address_asked and self.request.event.settings.invoice_name_required:
         return InvoiceNameForm(data=self.request.POST if self.request.method == "POST" else None,
                                event=self.request.event,
                                request=self.request,
                                instance=self.invoice_address,
                                validate_vat_id=False)
     return InvoiceAddressForm(data=self.request.POST if self.request.method == "POST" else None,
                               event=self.request.event,
                               request=self.request,
                               instance=self.invoice_address,
                               validate_vat_id=self.eu_reverse_charge_relevant)