示例#1
0
def test_company_still_linked_if_customer_contact_edited(regular_user):
    get_default_shop()
    person = get_person_contact(regular_user)
    assert not get_company_contact(regular_user)

    company = CompanyContact()
    company.save()
    company.members.add(person)
    assert get_company_contact(regular_user)

    client = SmartClient()
    client.login(username=REGULAR_USER_USERNAME, password=REGULAR_USER_PASSWORD)
    customer_edit_url = reverse("shoop:customer_edit")
    soup = client.soup(customer_edit_url)

    data = default_customer_data()
    data.update(default_address_data("billing"))
    data.update(default_address_data("shipping"))

    response, soup = client.response_and_soup(customer_edit_url, data, "post")

    assert response.status_code == 302
    assert get_company_contact(regular_user)
示例#2
0
    def _create_contact_from_address(self, billing_address, is_company):
        name = billing_address.get("name", None)
        if not name:
            self.add_error(
                ValidationError(_("Name is required for customer"),
                                code="no_name"))
            return

        phone = billing_address.get("phone", "")
        email = billing_address.get("email", "")
        fields = {"name": name, "phone": phone, "email": email}
        if is_company:
            tax_number = billing_address.get("tax_number", None)
            if not tax_number:
                self.add_error(
                    ValidationError(_("Tax number is not set for company."),
                                    code="no_tax_number"))
                return

            fields.update({"tax_number": tax_number})
            customer = CompanyContact(**fields)
        else:
            customer = PersonContact(**fields)
        return customer
示例#3
0
def test_default_company_contact_group_repr_and_str():
    cdg = CompanyContact.get_default_group()
    assert repr(cdg) == '<ContactGroup:%d-default_company_group>' % cdg.pk
    assert str(cdg) == 'Company Contacts'
示例#4
0
def test_default_company_contact_group_repr_and_str():
    cdg = CompanyContact.get_default_group()
    assert repr(cdg) == '<ContactGroup:%d-default_company_group>' % cdg.pk
    assert str(cdg) == 'Company Contacts'
示例#5
0
def test_address_form():
    form = modelform_factory(Address, exclude=())(data=DEFAULT_ADDRESS_DATA)
    company = CompanyContact(name=u"Doge Ltd", vat_code="1000-1000")
    address = Address.objects.from_address_form(form, company=company)
    assert address.company == company.name, "Company name was copied correctly"
    assert address.vat_code == company.vat_code, "VAT code was copied correctly"