示例#1
0
def test_unsaved_contact(admin_user):
    payment_method = get_default_payment_method()
    _assign_component_for_service(payment_method,
                                  [PersonContact.get_default_group()])
    person = PersonContact(name="Kalle")
    source = _get_source_for_contact(admin_user, payment_method)
    source.customer = person
    assert not person.pk and not source.customer.pk
    _test_service_availability(source, payment_method, False)
示例#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_person_contact_group_repr_and_str():
    pdg = PersonContact.get_default_group()
    assert repr(pdg) == '<ContactGroup:%d-default_person_group>' % pdg.pk
    assert str(pdg) == 'Person Contacts'
示例#4
0
def test_default_person_contact_group_repr_and_str():
    pdg = PersonContact.get_default_group()
    assert repr(pdg) == '<ContactGroup:%d-default_person_group>' % pdg.pk
    assert str(pdg) == 'Person Contacts'
示例#5
0
def test_person_name_init_by_first_and_last_name():
    john = PersonContact(first_name="John", last_name="Smith")
    assert john.name == "John Smith"
    assert john.first_name == "John"
    assert john.last_name == "Smith"
示例#6
0
 def filter(self):
     return json.dumps({"groups": [PersonContact.get_default_group().pk]})
示例#7
0
 def filter(self):
     return json.dumps({"groups": [PersonContact.get_default_group().pk]})