コード例 #1
0
ファイル: Gardener.py プロジェクト: k2345rftf/dacha
 def showHistory(self, date):
     from database import isNone
     self.date = date
     if isNone(self.date):
         return ShowHistoryPayment().show_area(self.date)
     else:
         return ShowHistoryPayment().show_all()
コード例 #2
0
ファイル: Director.py プロジェクト: k2345rftf/dacha
    def InsertHistory(self, **kwargs):
        from database import HistoryRegion, isNone, Region
        import datetime
        self.kwargs = kwargs
        self.region = session.query(Region.region_id).filter(
            Region.number_region == self.kwargs.get("number")).all()
        self.row = session.query(HistoryRegion.id_transaction).filter(
            HistoryRegion.id_transaction >= 0).all()
        try:
            self.id_trans = self.row[len(self.row) - 1][0]
        except:
            self.id_trans = None
        if isNone(self.id_trans):
            self.id_transaction = -1
        else:
            self.id_transaction = self.id_trans
        try:
            self.region_id = self.region[0][0]
        except IndexError:
            self.region_id = -1

        self.b = HistoryRegion(id_transaction=self.id_transaction + 1,
                               date=datetime.datetime.now(),
                               region_id=self.region_id,
                               id_buyer=self.kwargs.get("user_id"),
                               share=self.kwargs.get("share"),
                               id_seller=int(self.kwargs.get("id_seller")))
        return session.add(self.b)
コード例 #3
0
ファイル: Director.py プロジェクト: k2345rftf/dacha
    def createUser(self, login, password, full_name, membership, privelege):
        from database import User, isNone
        self.login = login
        self.password = password
        self.full_name = full_name
        self.membership = membership
        self.privelege = privelege
        if isNone(self.check_user(self.login)):
            self.user_id = session.query(User.id).filter(User.id >= 0).all()
            try:
                self.id = self.user_id[len(self.user_id) - 1][0]
            except IndexError:
                self.id = -1

            self.b = User(id=self.id + 1,
                          login=self.login,
                          password=self.password,
                          NFC=self.full_name,
                          membership=self.membership,
                          privelege=self.privelege,
                          counter=0)
            return session.add(self.b)
        else:
            self.err = "Error456"
            return print(self.err)
コード例 #4
0
ファイル: Accountent.py プロジェクト: k2345rftf/dacha
 def showCompany(self, date):
     from database import isNone
     self.date = date
     if isNone(self.date):
         return ShowCompany().show_area(self.date)
     else:
         return ShowCompany().show_all()
コード例 #5
0
ファイル: Director.py プロジェクト: k2345rftf/project
    def InsertShare(self, login, share, number_region, doc):
        from database import User, Share, isNone
        self.login = login
        self.share = share
        self.number_region = int(number_region)
        self.doc = doc
        self.user_id = session.query(
            User.id).filter(User.login == self.login).all()
        try:
            self.find = session.query(Share.region_id).filter(
                Share.user_id == self.user_id[0][0]).filter(
                    Region.number_region == self.number_region).all()
        except:
            self.err = "Такого пользователя не существует!!!"
            return self.err
        if isNone(self.checkArea(self.number_region)) or self.checkArea == 0:
            self.err = "Данный регион либо не существует, либо полностью распределен!!!!!"
            return self.err
        if self.checkArea(self.number_region) - self.share < 0:
            self.err = "Регион переполнен, введите меньшее кол-во"
            return self.err
        self.y = []
        for self.i in range(len(self.find)):
            self.y.append(self.find[self.i][0])
        if self.number_region in self.y:
            self.InsertHistory(user_id=self.user_id[0][0],
                               number=self.number_region,
                               share=self.share,
                               id_seller=self.id)
            session.query(Share).filter(
                Share.user_id == self.user_id[0][0]).update({
                    "share": self.share,
                    "doc": self.doc
                })
            session.commit()
            return 0
        else:
            self.region = session.query(Region.region_id).filter(
                Region.number_region == self.number_region).all()
            self.InsertHistory(user_id=self.user_id[0][0],
                               number=self.number_region,
                               share=self.share,
                               id_seller=self.id)
            self.b = Share(user_id=self.user_id[0][0],
                           region_id=self.region[0][0],
                           share=self.share,
                           doc=self.doc)

            return self.b
コード例 #6
0
ファイル: Director.py プロジェクト: k2345rftf/dacha
    def InsertShare(self, login, share, number_region, doc):
        from database import User, Share, isNone
        self.login = login
        self.share = float(share.replace(",", "."))
        self.number_region = int(number_region)
        self.doc = doc
        self.user_id = session.query(
            User.id).filter(User.login == self.login).all()
        try:
            self.find = session.query(Share.user_id).filter(
                Share.user_id == self.user_id[0][0]).all()
        except:
            self.err = "Такого пользователя не существует!!!"
            return self.err
        if isNone(self.checkArea(self.number_region)) or self.checkArea == 0:
            self.err = "Данный регион либо не существует, либо полностью распределен!!!!!"
            return self.err
        if self.checkArea(self.number_region) - self.share < 0:
            self.err = "something"
            return self.err
        if self.find == []:
            self.region = session.query(Region.region_id).filter(
                Region.number_region == self.number_region).all()
            self.InsertHistory(user_id=self.user_id[0][0],
                               number=self.number_region,
                               share=self.share,
                               id_seller=self.id)
            self.b = Share(user_id=self.user_id[0][0],
                           region_id=self.region[0][0],
                           share=self.share,
                           doc=self.doc)

            return session.add(self.b)
        else:
            self.InsertHistory(user_id=self.user_id[0][0],
                               number=self.number_region,
                               share=self.share,
                               id_seller=self.id)
            return session.query(Share).filter(
                Share.user_id == self.user_id[0][0]).update({
                    "share": self.share,
                    "doc": self.doc
                })