Beispiel #1
0
    def person(self) -> None:
        MenuUtils.title('EDIT PERSON')
        uuid = MenuUtils.prompt('Enter uuid')
        found = self.person_service.get(uuid)
        if not found:
            MenuUtils.print_error("Person does not exist", uuid)
        else:
            try:
                found.name = MenuUtils.prompt('Name',
                                              ContactValidator.validate_name,
                                              found.name)
                found.age = MenuUtils.prompt('Age',
                                             PersonValidator.validate_age,
                                             found.age)
                found.phone = MenuUtils.prompt('Phone',
                                               ContactValidator.validate_phone,
                                               found.phone)
                found.email = MenuUtils.prompt('Email',
                                               PersonValidator.validate_email,
                                               found.email)
                found.address = MenuUtils.prompt(
                    'Address',
                    on_blank_abort=False,
                    validator=ContactValidator.validate_address)
                found.complement = MenuUtils.prompt(
                    'Complement',
                    on_blank_abort=False,
                    validator=ContactValidator.validate_complement)
                self.person_service.save(found)
            except InputAbortedError:
                MenuUtils.wait_enter('Operation aborted. Press [Enter]...')

            MenuUtils.wait_enter()
Beispiel #2
0
 def by_uuid(self) -> None:
     MenuUtils.title('SEARCH BY UUID')
     try:
         name = MenuUtils.prompt('Person or Company uuid')
         all_persons = self.person_service.list(
             filters='uuid={}'.format(name))
         all_companies = self.company_service.list(
             filters='uuid={}'.format(name))
         self.display_contacts(all_persons, all_companies)
     except InputAbortedError:
         pass
Beispiel #3
0
    def company(self) -> None:
        MenuUtils.title('EDIT COMPANY')
        uuid = MenuUtils.prompt('Enter uuid')
        found = self.company_service.get(uuid)
        if not found:
            MenuUtils.print_error("Company does not exist", uuid)
        else:
            try:
                found.name = MenuUtils.prompt('Name',
                                              ContactValidator.validate_name,
                                              found.name)
                found.phone = MenuUtils.prompt('Phone',
                                               ContactValidator.validate_phone,
                                               found.phone)
                found.website = MenuUtils.prompt(
                    'WebSite', CompanyValidator.validate_website,
                    found.website)
                found.address = MenuUtils.prompt(
                    'Address',
                    on_blank_abort=False,
                    validator=ContactValidator.validate_address)
                found.complement = MenuUtils.prompt(
                    'Complement',
                    on_blank_abort=False,
                    validator=ContactValidator.validate_complement)
                self.company_service.save(found)
            except InputAbortedError:
                MenuUtils.wait_enter('Operation aborted. Press [Enter]...')

            MenuUtils.wait_enter()
Beispiel #4
0
    def company(self) -> None:
        MenuUtils.title('CREATE COMPANY')
        company = Company()
        try:
            company.name = MenuUtils.prompt('Name',
                                            ContactValidator.validate_name)
            company.phone = MenuUtils.prompt('Phone',
                                             ContactValidator.validate_phone)
            company.website = MenuUtils.prompt(
                'WebSite', CompanyValidator.validate_website)
            company.address = MenuUtils.prompt(
                'Address',
                on_blank_abort=False,
                validator=ContactValidator.validate_address)
            company.complement = MenuUtils.prompt(
                'Complement',
                on_blank_abort=False,
                validator=ContactValidator.validate_complement)
            self.company_service.save(company)
        except InputAbortedError:
            MenuUtils.wait_enter('Operation aborted. Press [Enter]...')

        MenuUtils.wait_enter()
Beispiel #5
0
    def execute(self) -> Optional[Menu]:
        """TODO"""

        while self.selected != 0 and not self.done:
            sysout(str(self))
            try:
                self.selected = MenuUtils.prompt(end='$ ')
                if not self.selected:
                    continue
                if self.selected.isalnum() and self.is_valid_option():
                    return self.trigger_menu_item()
                MenuUtils.print_error("Invalid option", self.selected)
                self.selected = None
            except InputAbortedError:
                continue
Beispiel #6
0
    def person(self) -> None:
        MenuUtils.title('CREATE PERSON')
        person = Person()
        try:
            person.name = MenuUtils.prompt('Name',
                                           ContactValidator.validate_name)
            person.age = MenuUtils.prompt('Age', PersonValidator.validate_age)
            person.phone = MenuUtils.prompt('Phone',
                                            ContactValidator.validate_phone)
            person.email = MenuUtils.prompt('Email',
                                            PersonValidator.validate_email)
            person.address = MenuUtils.prompt(
                'Address',
                on_blank_abort=False,
                validator=ContactValidator.validate_address)
            person.complement = MenuUtils.prompt(
                'Complement',
                on_blank_abort=False,
                validator=ContactValidator.validate_complement)
            self.person_service.save(person)
        except InputAbortedError:
            MenuUtils.wait_enter('Operation aborted. Press [Enter]...')

        MenuUtils.wait_enter()