Beispiel #1
0
    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
Beispiel #2
0
    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
Beispiel #3
0
 def dispatch(self, request, *args, **kwargs):
     if not allow_company_registration(request.shop):
         return HttpResponseNotFound()
     return super(CompanyEditView, self).dispatch(request, *args, **kwargs)
Beispiel #4
0
 def dispatch(self, request, *args, **kwargs):
     if not allow_company_registration(request.shop):
         return redirect("shuup:registration_register")
     return super(CompanyRegistrationView,
                  self).dispatch(request, *args, **kwargs)
Beispiel #5
0
 def dispatch(self, request, *args, **kwargs):
     if not (bool(get_company_contact(self.request.user))
             or allow_company_registration(self.request.shop)):
         return redirect("shuup:customer_edit")
     return super(CompanyEditView, self).dispatch(request, *args, **kwargs)
Beispiel #6
0
def is_company_registration_allowed(context, request=None):
    current_request = request or context[
        "request"]  # From macros it doesn't seem to always pass context correctly
    return allow_company_registration(current_request.shop)
Beispiel #7
0
 def dispatch(self, request, *args, **kwargs):
     if not (bool(get_company_contact(self.request.user)) or allow_company_registration(self.request.shop)):
         return redirect("shuup:customer_edit")
     return super(CompanyEditView, self).dispatch(request, *args, **kwargs)
Beispiel #8
0
 def show_on_menu(self):
     # Only show this on menu if customer is company
     return (isinstance(self.request.customer, CompanyContact)
             or allow_company_registration(self.request.shop))
Beispiel #9
0
 def show_on_menu(self):
     # Only show this on menu if customer is company
     return (isinstance(self.request.customer, CompanyContact) or allow_company_registration(self.request.shop))
Beispiel #10
0
def is_company_registration_allowed(context, request=None):
    current_request = request or context["request"]  # From macros it doesn't seem to always pass context correctly
    return allow_company_registration(current_request.shop)
Beispiel #11
0
 def dispatch(self, request, *args, **kwargs):
     if not allow_company_registration(request.shop):
         return redirect("shuup:registration_register")
     return super(CompanyRegistrationView, self).dispatch(request, *args, **kwargs)