Exemple #1
0
    def add_ap(self):
        description = self.opis.get()
        for item in range(len(self.elements)):
            if self.elements[item] == description:
                description = self.descriptions_get[item]['id']
        status = self.status.get()

        if not description or not status or (status == "---"):
            messagebox.showinfo('Error', 'Podaj opis i status!')
            return

        if status == 'Wolny':
            try:
                apartment = api.create(
                    'Apartament',
                    attributes={
                        "zajety": False
                    },
                    relationships={
                        'opis': {
                            'type': 'OpisApartamentu',
                            'id': description
                        }
                    })
            except Exception:
                messagebox.showinfo('Error', 'Nie można utworzyć wolnego apartamentu!\n'
                                             'Sprawdź czy wszystkie dane zostałyn\n'
                                             'prawidłowo wprowadzone.')
                return
        elif status == 'Zajęty':
            try:
                apartment = api.create(
                    'Apartament',
                    attributes={
                        "zajety": True
                    },
                    relationships={
                        'opis': {
                            'type': 'OpisApartamentu',
                            'id': description
                        }
                    })
            except Exception:
                messagebox.showinfo('Error', 'Nie można utworzyć zajętego apartamentu!\n'
                                             'Sprawdź czy wszystkie dane zostałyn\n'
                                             'prawidłowo wprowadzone.')
                return
        else:
            messagebox.showinfo('Error', 'Nie można utworzyć apartamentu!\n'
                                         'Sprawdź czy wszystkie dane zostały\n'
                                         'prawidłowo wprowadzone.')
            return
        messagebox.showinfo('Info', f'Utworzono nowy: {(apartment["verbose_name"])}.')
    def add_desc(self):
        price = self.price_input.get()
        aptype = self.opis1.get()
        for item in range(len(self.type_elements)):
            if self.type_elements[item] == aptype:
                aptype = self.type_get[item]['id']

        location = self.opis.get()
        for item in range(len(self.loc_elements)):
            if self.loc_elements[item] == location:
                location = self.locations_get[item]['id']

        if not aptype or not location or not price:
            messagebox.showinfo('Error', 'Podaj rodzaj, lokalizację i cenę!')
            return

        if (aptype == '---') or (location == '---'):
            messagebox.showinfo('Error', 'Podaj rodzaj i lokalizację!')
            return

        try:
            new_descript = api.create(
                'OpisApartamentu',
                attributes={
                    'cena': price
                },
                relationships={
                    'rodzaj': {
                        'type': 'RodzajApartamentu',
                        'id': aptype
                    },
                    'lokalizacja': {
                        'type': 'Lokalizacja',
                        'id': location
                    }
                })
        except Exception:
            messagebox.showinfo('Error', 'Nie można utworzyć opisu apartamentu!\n'
                                         'Sprawdź czy wszystkie dane zostały\n'
                                         'prawidłowo wprowadzone.')
            return
        messagebox.showinfo('Info', f'Utworzono nowy: {(new_descript["verbose_name"])}.')
Exemple #3
0
    def add_desc(self):
        price = self.price_input.get()
        ittype = self.opis.get()
        for item in range(len(self.type_elements)):
            if self.type_elements[item] == ittype:
                ittype = self.type_get[item]['id']

        mark = self.opis1.get()
        for item in range(len(self.mark_elements)):
            if self.mark_elements[item] == mark:
                mark = self.mark_get[item]['id']

        if not ittype or not mark or not price:
            messagebox.showinfo('Error', 'Podaj rodzaj, producenta i cenę!')
            return

        if (ittype == '---') or (mark == '---'):
            messagebox.showinfo('Error', 'Podaj rodzaj i producenta!')
            return

        try:
            new_descript = api.create('OpisSprzetu',
                                      attributes={'cena': price},
                                      relationships={
                                          'rodzaj': {
                                              'type': 'RodzajSprzetu',
                                              'id': ittype
                                          },
                                          'producent': {
                                              'type': 'Producent',
                                              'id': mark
                                          }
                                      })
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie można utworzyć opisu sprzętu!\n'
                'Sprawdź czy wszystkie dane zostały\n'
                'prawidłowo wprowadzone.')
            return
        messagebox.showinfo(
            'Info', f'Utworzono nowy: {(new_descript["verbose_name"])}.')
Exemple #4
0
    def register(self):
        username = self.username_input.get()
        password1 = self.password_input.get()
        password2 = self.password_input2.get()
        name = self.name_input.get()
        lastname = self.lastname_input.get()
        email = self.email_input.get()
        card = self.card_input.get()
        address = self.address_input.get()

        self.register_button.config(bg='deep sky blue')

        if not username or (not password1 and not password2):
            messagebox.showinfo('Error', 'Podaj login i hasło!')
            self.register_button.config(bg='ghost white')
            return
        if password1 != password2:
            messagebox.showinfo('Error', 'Podano dwa różne hasła!')
            self.register_button.config(bg='ghost white')
            return
        if not name or not lastname:
            messagebox.showinfo(
                'Error', 'Potrzebujemy Twoich danych osobowych!\n'
                'Podaj imię i nazwisko.')
            self.register_button.config(bg='ghost white')
            return
        if not email or not address or not card:
            messagebox.showinfo(
                'Error', 'Ptrzebujemy Twoich danych kontaktowych!\n'
                'Podaj swój adres email, adres zamieszkania i numer karty.')
            self.register_button.config(bg='ghost white')
            return

        login_data = api.get('DaneLogowania', filters={'login': username})

        if login_data:
            messagebox.showinfo('Error', 'Ten login jest zajęty! Wymyśl inny.')
            self.register_button.config(bg='ghost white')
            return

        if not (len(card) == 19) or not (card[4] == ' ') or not (
                card[9] == ' ') or not (card[14] == ' '):
            messagebox.showinfo('Error', 'Podano nieprawidłowy numer karty!')
            return

        try:
            dane_logowania = api.create('DaneLogowania',
                                        attributes={
                                            "login": username,
                                            "email": email,
                                            "haslo": password1
                                        })
        except Exception:
            messagebox.showinfo('Error',
                                'Taki adres email nie ma prawa istnieć!.')
            self.register_button.config(bg='ghost white')
            return

        try:
            klient = api.create('Klient',
                                attributes={
                                    "imie": name,
                                    "nazwisko": lastname,
                                    "adres": address,
                                    "numer_karty": card
                                },
                                relationships={
                                    'dane_logowania': {
                                        'type': 'DaneLogowania',
                                        'id': username
                                    }
                                })
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie udało się utworzyć konta!\n'
                'Sprawdź, czy wszystkie wartości są\n'
                'prawidłowo wprowadzone.')
            return

        klient = api.get('Klient', filters={'dane_logowania.login': username})
        self.register_button.config(bg='ghost white')
        messagebox.showinfo('Dodano', f'Dodano klienta: {(username)}')
        self.controller.set_user(klient[0])
        self.controller.show_frame(KlientPage)
Exemple #5
0
import logging

from app.api import api

logging.basicConfig(level=logging.DEBUG)

dane_logowania = api.create('DaneLogowania',
                            attributes={
                                "login": "******",
                                "email": "*****@*****.**",
                                "haslo": "druuugi"
                            })

klient = api.create('Klient',
                    attributes={
                        "imie": "Jan",
                        "nazwisko": "Pawel",
                        "adres": "pl. Jana Pawla",
                        "numer_karty": "0000 0000 0000 0001"
                    },
                    relationships={
                        'dane_logowania': {
                            'type': 'DaneLogowania',
                            'id': 'JanPawel'
                        }
                    })

api.update('Klient',
           attributes={
               "imie": klient['imie'],
               "nazwisko": "inne nazwisko",
Exemple #6
0
    def reserve_apartment(self):
        apartment = self.apartment_list.get(tk.ACTIVE)
        new_id = self.controller.user_data["id"]
        start_date = self.start_date_input.get()
        end_date = self.end_date_input.get()

        for item in range(len(self.elements)):
            if self.elements[item] == apartment:
                apartment = self.apps_get[item]['id']
        if not apartment or not start_date or not end_date:
            messagebox.showinfo('Error', 'Wybierz apartament i podaj daty!')

        self.dane = api.get('Apartament',
                            filters={'id': apartment},
                            include=['opis'])

        try:
            reservation = api.create('RezerwacjeApartamentow',
                                     attributes={
                                         "data_wynajecia": start_date,
                                         "data_wymeldowania": end_date
                                     },
                                     relationships={
                                         'klient': {
                                             'type': 'Klient',
                                             'id':
                                             self.controller.user_data['id']
                                         },
                                         'apartament': {
                                             'type': 'Apartament',
                                             'id': apartment
                                         }
                                     })
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie można utworzyć rezerwacji apartamentu! '
                'Sprawdź czy wszystkie dane (np. daty) zostały '
                'prawidłowo wprowadzone.')
            return

        try:

            api.update('Apartament',
                       attributes={"zajety": True},
                       relationships={
                           'opis': {
                               'type': 'OpisApartamentu',
                               'id': self.dane[0]['opis']['id']
                           }
                       },
                       _id=apartment)
        except Exception:
            api.delete('RezerwacjeApartamentow', _id=reservation['id'])
            messagebox.showinfo(
                'Error', 'Nie można ustawić apartamentu na zajęty! '
                'Sprawdź czy wszystkie dane (np. daty) zostały '
                'prawidłowo wprowadzone.')
            return

        messagebox.showinfo(
            'Error',
            f'Dodano nową rezerwację od: {reservation["data_wynajecia"]}\n'
            f'Ustawiono apartament na zajęty.')