Ejemplo n.º 1
0
    def find(self) -> LibraryClient:
        print('Znajdź użytkownika')
        username = input('  imię i nazwisko: ')

        first_name, last_name = username.split(' ')

        user = LibraryClient().get_or_create(
            first_name=FirstName().get_or_create(name=first_name)[0],
            last_name=LastName().get_or_create(name=last_name)[0])[0]

        return user
Ejemplo n.º 2
0
    def add(self) -> int:
        """ Dodawanie nowych użytkowników do bazy """
        first_name = FirstName().get_or_create(name=input('Podaj imię: '))[
            0]  # zwracana tupla, pierwszy element zawiera imie
        last_name = LastName().get_or_create(name=input('Podaj nazwisko: '))[0]

        first_name.save()
        last_name.save()

        client = LibraryClient(first_name=first_name, last_name=last_name)
        client.save()

        return client.id
Ejemplo n.º 3
0
    def add(self) -> int:
        """ Dodawanie nowych użytkowników do bazy. """
        print('Dodawanie nowego użytkownika')

        first_name = FirstName().get_or_create(name=input('Podaj imię: '))[0]
        last_name = LastName().get_or_create(name=input('Podaj nazwisko: '))[0]

        first_name.save()
        last_name.save()

        client = LibraryClient(first_name=first_name, last_name=last_name)
        client.save()

        return client.id
Ejemplo n.º 4
0
    def add_authors(self, authors: List[str]) -> List[Author] or None:  # List wymusza na nas typowanie
        result = []

        for author_name in authors:
            try:
                first_name, last_name= author_name.split(' ')
            except ValueError:
                first_name, last_name = author_name, None
            author = Author().get_or_create(
                    first_name = FirstName().get_or_create(name=first_name)[0],
                    last_name = LastName().get_or_create(name=last_name)[0] if last_name else None
            )[0]
            result.append(author)

        return result
Ejemplo n.º 5
0
    def add_authors(self, authors: List[str]) -> List[Author]:
        """Dodawanie nowych autorów."""
        result = []

        for author_name in authors:
            try:
                first_name, last_name = author_name.split(' ')
            except ValueError:
                first_name, last_name = author_name, None

            author = Author().get_or_create(
                first_name=FirstName().get_or_create(name=first_name)[0],
                last_name=LastName().get_or_create(name=last_name)[0] if last_name else None
            )[0]

            result.append(author)

        return result