def get_form(self, form_class): fg = FormGroup(**self.get_form_kwargs()) for kind in self.address_kinds: fg.add_form_def(kind, form_class=self.address_form_classes.get(kind, self.address_form_class)) if self.company_form_class and not self.request.customer: fg.add_form_def("company", self.company_form_class, required=False) return fg
def get_form(self, form_class=None): kwargs = self.get_form_kwargs() kwargs["initial"] = dict(self.request.GET.items()) fg = FormGroup(**kwargs) form_parts = self.get_form_parts(None) for form_part in form_parts: for form_def in form_part.get_form_defs(): fg.form_defs[form_def.name] = form_def fg.instantiate_forms() return fg
def get_form(self, form_class=None): order = self.get_object() form_group = FormGroup(**self.get_form_kwargs()) address_form_class = cached_load("SHUUP_ADDRESS_MODEL_FORM") form_group.add_form_def( "billing_address", address_form_class, kwargs={"initial": get_data_dict(order.billing_address) if order.billing_address else {}}) form_group.add_form_def( "shipping_address", address_form_class, kwargs={"initial": get_data_dict(order.shipping_address) if order.shipping_address else {}}) return form_group
def get_form(self, form_class=None): kwargs = self.get_form_kwargs() instance = kwargs.pop("instance", None) form_group = FormGroup(**kwargs) form_group.add_form_def( name="base", form_class=TaskForm, kwargs=dict(instance=instance, request=self.request) ) if self.object.pk: form_group.add_form_def( name="comment", form_class=TaskCommentForm, kwargs=dict(request=self.request, task=instance), required=False ) return form_group
def get_form(self, form_class): contact = get_person_contact(self.request.user) form_group = FormGroup(**self.get_form_kwargs()) form_group.add_form_def("billing", AddressForm, kwargs={"instance": contact.default_billing_address}) form_group.add_form_def("shipping", AddressForm, kwargs={"instance": contact.default_shipping_address}) form_group.add_form_def("contact", PersonContactForm, kwargs={"instance": contact}) return form_group
def make_form_group(**kwargs): AddressForm = modelform_factory(MutableAddress, fields=("name", )) fg = FormGroup(**kwargs) fg.add_form_def("address1", AddressForm, required=True) fg.add_form_def("address2", AddressForm, required=False) fg.add_form_def("general", GeneralForm, required=True) return fg
def get_form(self, form_class): contact = get_person_contact(self.request.user) form_group = FormGroup(**self.get_form_kwargs()) address_form_class = cached_load("SHUUP_ADDRESS_MODEL_FORM") form_group.add_form_def("billing", address_form_class, kwargs={"instance": contact.default_billing_address}) form_group.add_form_def("shipping", address_form_class, kwargs={"instance": contact.default_shipping_address}) form_group.add_form_def("contact", PersonContactForm, kwargs={"instance": contact}) return form_group
def get_form(self, form_class): form_group = FormGroup(**self.get_form_kwargs()) address_kwargs = {} saved_address_kwargs = {} if self.instance: address_kwargs["instance"] = self.instance.address saved_address_kwargs["initial"] = { "role": self.instance.role, "status": self.instance.status, "title": self.instance.title, } form_group.add_form_def("address", cached_load("SHUUP_ADDRESS_MODEL_FORM"), kwargs=address_kwargs) form_group.add_form_def( "saved_address", SavedAddressForm, kwargs=saved_address_kwargs ) return form_group
def get_form(self, form_class): kwargs = self.get_form_kwargs() fg = FormGroup(data=kwargs.get("data"), files=kwargs.get("files")) fg.add_form_def("billing", self.billing_address_form_class) fg.add_form_def("shipping", self.shipping_address_form_class) fg.add_form_def( "order", self.order_form_class, kwargs={"basket": self.request.basket, "shop": self.request.shop} ) return fg
def get_form(self, form_class): fg = FormGroup(**self.get_form_kwargs()) default_address_form_class = cached_load("SHUUP_ADDRESS_MODEL_FORM") for kind in self.address_kinds: fg.add_form_def(kind, form_class=self.address_form_classes.get(kind, default_address_form_class)) fg.add_form_def("saved_{}".format(kind), form_class=SavedAddressForm, required=False, kwargs={"kind": kind, "owner": self.basket.customer}) if self.company_form_class and not self.request.customer: fg.add_form_def("company", self.company_form_class, required=False) return fg
def get_form(self, form_class): user = self.request.user company = get_company_contact(user) person = get_person_contact(user) form_group = FormGroup(**self.get_form_kwargs()) address_form_class = cached_load("SHUUP_ADDRESS_MODEL_FORM") form_group.add_form_def( "billing", address_form_class, kwargs={ "instance": _get_default_address_for_contact(company, "default_billing_address", person) } ) form_group.add_form_def( "shipping", address_form_class, kwargs={ "instance": _get_default_address_for_contact(company, "default_shipping_address", person) } ) form_group.add_form_def("contact", CompanyContactForm, kwargs={"instance": company}) return form_group
def get_form(self, form_class=None): kwargs = self.get_form_kwargs() instance = kwargs.pop("instance", None) form_group = FormGroup(**kwargs) form_group.add_form_def(name="base", form_class=TaskForm, kwargs=dict(instance=instance, request=self.request)) if self.object.pk: form_group.add_form_def(name="comment", form_class=TaskCommentForm, kwargs=dict(request=self.request, task=instance), required=False) return form_group
def get_form(self, **kwargs): """ Create a `FormGroup` and put the necessary forms inside. """ kwargs.update(self.get_form_kwargs()) form_group = FormGroup(**kwargs) form_group.add_form_def("base", self.base_form_class, required=True) default_language = settings.PARLER_DEFAULT_LANGUAGE_CODE # the first form must be the first form, and required, as it is the fallback form_group.add_form_def(default_language, self.multilingual_form_class, required=True) for language, __ in settings.LANGUAGES: # the default language was already added! if language == default_language: continue form_group.add_form_def(language, self.multilingual_form_class, required=False) return form_group
def get_form(self, form_class=None): fg = FormGroup(**self.get_form_kwargs()) default_address_form_class = cached_load("SHUUP_ADDRESS_MODEL_FORM") for kind in self.address_kinds: fg.add_form_def(kind, form_class=self.address_form_classes.get( kind, default_address_form_class)) fg.add_form_def("saved_{}".format(kind), form_class=SavedAddressForm, required=False, kwargs={ "kind": kind, "owner": self.basket.customer }) if self.company_form_class and allow_company_registration( self.request.shop) and not self.request.customer: fg.add_form_def("company", self.company_form_class, required=False, kwargs={"request": self.request}) return fg
def get_form(self, form_class): user = self.request.user company = get_company_contact(user) person = get_person_contact(user) form_group = FormGroup(**self.get_form_kwargs()) form_group.add_form_def( "billing", AddressForm, kwargs={ "instance": _get_default_address_for_contact(company, "default_billing_address", person) } ) form_group.add_form_def( "shipping", AddressForm, kwargs={ "instance": _get_default_address_for_contact(company, "default_shipping_address", person) } ) form_group.add_form_def("contact", CompanyContactForm, kwargs={"instance": company}) return form_group
def get_form(self, form_class=None): order = self.get_object() form_group = FormGroup(**self.get_form_kwargs()) address_form_class = cached_load("SHUUP_ADDRESS_MODEL_FORM") form_group.add_form_def("billing_address", address_form_class, kwargs={ "initial": get_data_dict(order.billing_address) if order.billing_address else {} }) form_group.add_form_def("shipping_address", address_form_class, kwargs={ "initial": get_data_dict(order.shipping_address) if order.shipping_address else {} }) return form_group
def get_form(self, form_class=None): form_group = FormGroup(**self.get_form_kwargs()) form_group.add_form_def(name=self.login_form_key, form_class=LoginView.form_class, required=False) form_group.add_form_def(name=self.checkout_method_choice_key, form_class=ChooseToRegisterForm, required=False) return form_group
def get_form(self, form_class): fg = FormGroup(**self.get_form_kwargs()) for kind in self.address_kinds: fg.add_form_def(kind, form_class=self.address_form_classes.get(kind, self.address_form_class)) return fg
def get_form(self, form_class=None): form_group = FormGroup(**self.get_initial_form_group_kwargs()) form_group.add_form_def(name=self.login_form_key, form_class=LoginView.form_class, required=False, kwargs={"request": self.request}) form_group.add_form_def(name=self.checkout_method_choice_key, form_class=ChooseToRegisterForm, required=False) return form_group