Esempio n. 1
0
 def logout(self):
     while True:
         settings.CURRENT_USER_ROLE=""
         home_admin = view.Home()
         home_admin.welcome()
         k=inputs("Registration '1' and Login '2'")
         if k=='1' and settings.FIRST_RUN==True:
             self.Regis()
             self.Client()
         elif k=='2':
             self.login()
         else:
             print('kayta engiz')
Esempio n. 2
0
    def Registration(self):
        settings.CURRENT_USER_ROLE = ''
        view.Home().welcome()
        while True:
            t = inputs('Registration -1, login-2:')
            if t == '1':
                settings.CURRENT_USER_ROLE = ''
                usr = inputs('username:'******'password:'******'data/users.txt', 'r') as f:
                    data = f.read().split('\n')
                    data.pop()
                    for i in data:
                        a = i.split(',')
                        f_list.append(a)
                    for i in range(len(f_list)):
                        if f_list[i][0] == usr and f_list[i][
                                1] == pwd and f_list[i][3] == 'True':
                            print('bul account saitta tirkelgen')
                            self.Registration()
                        elif f_list[i][0] == usr and f_list[i][
                                1] == pwd and f_list[i][5] == 'True':
                            print('bul account siteta tirkelgen')
                            self.Registration()
                        elif f_list[i][0] == usr and f_list[i][
                                1] == pwd and f_list[i][6] == 'True':
                            print('bul account siteta tirkelgen')
                            self.Registration()
                        elif f_list[i][0] == usr and f_list[i][
                                1] == pwd and f_list[i][4] == 'True':
                            print('bul account siteta tirkelgen')
                            self.Registration()

                    if usr != '' and pwd != '':
                        user = module.User()
                        user.is_client = True
                        user.add(usr, pwd)
                        settings.CURRENT_USER_ROLE = 'Client'
                        settings.CURRENT_USER = usr
                        self.log(usr, pwd, settings.CURRENT_USER_ROLE)
                        self.client()
                    else:
                        print('Енгізген аккаунт қате, дұрыстап енгізіңіз!')

            elif t == '2':
                self.login()
Esempio n. 3
0
 def run(self):
     print("Running the AzatAI Python Shop system self checking")
     self.system_check()
     self.prepare_file()
     if self.fr is False: # super admin already exist
         print("In the case super admin already exist")
         # TODO
     else:
         home = view.Home()
         home.superadmin()
         user_name = inputs('Please input a username for SUPERADMIN:\n')
         user_pw = inputs(f'Please input a password for SUPERADMIN {user_name}:\n')
         user = module.User()
         user.is_admin = True
         user.add(user_name,user_pw)
         settings.SUPER_ADMIN = user_name
         settings.SUPER_ADMIN_PW = user_pw
         settings.CURRENT_USER = user_name
         settings.CURRENT_USER_ROLE = "ADMIN"
         self.admin()
Esempio n. 4
0
    def admin(self):
        while True:
            f_list=[]
            user = module.User()
            user.is_admin=True
            settings.CURRENT_USER_ROLE="ADMIN"
            home_admin = view.Home()
            home_admin.welcome()
            admin_choice = inputi("Please select your choice: logout - '1' , adamdar tizimin korginiz kelse - '2', adamdar kirgen jane wikkan uakiti-'3' : ")
            if admin_choice==1:
                view.Home()
                k=inputs("Registration '1' and Login '2'")
                if k=='1':
                    self.Regis()
                    self.Client()
                elif k=='2':
                    self.login()
            elif admin_choice==2:
                print("index, Login, Password, Create date,                                   admin, staff, client, manager")
                with open('data/users.txt','r') as f:
                    d=f.read().split('\n')
                    d.pop()
                for i in d:
                    f1=i.split(',')
                    f_list.append(f1)
                for index,each in enumerate(f_list):
                    print(index,each)
                # for index,item  in enumerate(range(len(f_list))):
                #     if f_list[item][5]=="True":
                #         print(index,f_list[item])
                oz=inputi(' Адам статусын өзгерткіңіз келсе "1", logout -- "2" ,basty bet -"3" : ')
                if oz==1:
                    try:
                        if len(f_list)>1:
                                x=inputi('Өзгертетін адамның index енгізіңіз: ')
                                while True:
                                        q=inputi('''Client-->Staff = '1',  Client-->manager = '2'
                                        Staff-->Manager = '3': ''')
                                        for index,i in enumerate(range(len(f_list))):
                                            if q==1 and f_list[i][5]=="True":
                                                    if x==index:
                                                        user = module.User()
                                                        f_list[i][4]='True'
                                                        user.is_staff=True
                                                        f_list[i][5]='False'
                                                        user.is_client=False
                                                        f_list.insert(x,f_list[x])
                                                        del f_list[x+1]
                                                        print("index, Login, Password, Create date,                                  admin, staff, client, manager")
                                                        for index, i1 in enumerate(range(len(f_list))):
                                                                print(index,f_list[i1])
                                                                with open('data/users.txt','w') as f:
                                                                    for i2 in range(len(f_list)):
                                                                        f.write(str(f_list[i2][0])+','+ str(f_list[i2][1])+','+ str(f_list[i2][2])+','+str(f_list[i2][3])+','+str(f_list[i2][4])+','+str(f_list[i2][5])+','+str(f_list[i2][6])+'\n')
                                                    g=inputs('logout "1", basty bet "2" , zhalgastiru "3" : ')
                                                    home_admin.list_user(3)
                                                    if g=='1':
                                                        self.end()
                                                        view.Home()
                                                        self.logout()
                                                    elif g=='2':
                                                        self.admin()
                                                    elif g=='3':
                                                        pass

                                            elif q==2 and f_list[i][5]=="True":
                                                    if x==index:
                                                        user = module.User()
                                                        f_list[i][6]='True'
                                                        user.is_manager=True
                                                        f_list[i][5]='False'
                                                        user.is_client=False
                                                        f_list.insert(x,f_list[x])
                                                        del f_list[x+1]
                                                        print("index, Login, Password, Create date,                                  admin, staff, client, manager")
                                                        for index, i1 in enumerate(range(len(f_list))):
                                                                print(index,f_list[i1])
                                                                with open('data/users.txt','w') as f:
                                                                    for i2 in range(len(f_list)):
                                                                        f.write(str(f_list[i2][0])+','+ str(f_list[i2][1])+','+ str(f_list[i2][2])+','+str(f_list[i2][3])+','+str(f_list[i2][4])+','+str(f_list[i2][5])+','+str(f_list[i2][6])+'\n')
                                                    g=inputs('logout "1", basty bet "2", Zhalgastiru "3" : ')
                                                    home_admin.list_user(3)
                                                    if g=='1':
                                                        self.end()
                                                        view.Home()
                                                        self.logout()
                                                    elif g=='2':
                                                        self.admin()
                                                    elif g=='3':
                                                        pass

                                            elif q==3 and f_list[i][4]=="True":
                                                    if x==index:
                                                            user = module.User()
                                                            f_list[i][6]='True'
                                                            user.is_manager=True
                                                            f_list[i][4]='False'
                                                            user.is_staff=False
                                                            f_list.insert(x,f_list[x])
                                                            del f_list[x+1]
                                                            print("index, Login, Password, Create date,                                  admin, staff, client, manager")
                                                            for index, i1 in enumerate(range(len(f_list))):
                                                                    print(index,f_list[i1])
                                                                    with open('data/users.txt','w') as f:
                                                                        for i2 in range(len(f_list)):
                                                                            f.write(str(f_list[i2][0])+','+ str(f_list[i2][1])+','+ str(f_list[i2][2])+','+str(f_list[i2][3])+','+str(f_list[i2][4])+','+str(f_list[i2][5])+','+str(f_list[i2][6])+'\n')

                                                    g=inputs('logout "1", basty bet "2" , Zhalgastiru "2": ')
                                                    home_admin.list_user(3)
                                                    if g=='1':
                                                        self.end()
                                                        view.Home()
                                                        self.logout()
                                                    elif g=='2':
                                                        self.admin()
                                                    elif g=='3':
                                                        pass

                                            elif q not in [1,2,3] and f_list[i][4]!="True" and f_list[i][5]!="True" and f_list[i][6]!="True":
                                                while True:
                                                    print(" Ozgeris zhasalmaidy , tomendegi nuskalardy tandaniz ")
                                                    g=inputs(' logout - "1", basty bet- "2" , zhalgastirgin kelse - "3" ')
                                                    home_admin.list_user(3)
                                                    if g=='1':
                                                        self.end()
                                                        self.logout()
                                                    elif g=='2':
                                                        self.admin()
                                                    elif g=='3':
                                                        pass






                        else:
                                    print(' Сайтқа тіркелген адам табылмады ')
                                    g=inputs(' logout - "1", basty bet- "2" ')
                                    home_admin.list_user(3)
                                    if g=='1':
                                        self.end()
                                        self.logout()
                                    elif g=='2':
                                        self.admin()

                    except(ValueError):
                        pass
                elif oz==2:
                        self.end()
                        view.Home()
                        self.logout()
                elif oz==3:
                        self.admin()


            elif admin_choice==3:
                while True:
                    with open('data/log.txt','r') as f:
                        d=f.read().split('\n')
                        d.pop()
                    for i in d:
                        f1=i.split(',')
                        f_list.append(f1)
                    for index,each in enumerate(f_list):
                        print(index,each)
                    g=inputs(' logout - "1", basty bet- "2" ')
                    home_admin.list_user(3)
                    if g=='1':
                        self.end()
                        self.logout()
                    elif g=='2':
                        self.admin()
                                        
Esempio n. 5
0
 def manager(self):
      while True:
         user = module.User()
         user.is_manager=True
         settings.CURRENT_USER_ROLE="Manager"
         home_admin = view.Home()
         home_admin.welcome()
         sh=inputs(' жалғастырғыңыз келсе "1" ,  logout "2" , basty bet "3" : ')
         if sh=='1':
            while True:
             q=inputs('''тауарларды көргіңіз келсе "1" , сатылған тауарды көргіңіз келсе "2", тауардың бірін өшіргіңіз келсе "3", logout "4" , basty bet "5" : ''')
             if q=='1':
                 new_tauar=[]
                 with open('tauarlar_tizimi.txt','r+') as e:
                     r=e.read()
                     r_split=r.split('\n')
                     r_split.pop()
                 for each in r_split:
                     r2_split=each.split("-")
                     new_tauar.append(tuple(r2_split))
                 for index,item in enumerate(new_tauar):
                     print(index,item)
             elif q=='2':
                 with open('tauarr','r') as f:
                         g=f.read()
                         print(g)
             elif q=='3':
                 new_tauar=[]
                 new1_tauar=[]
                 with open('tauarlar_tizimi.txt','r+') as e:
                     r=e.read()
                     r_split=r.split('\n')
                     r_split.pop()
                 for each in r_split:
                     r2_split=each.split("-")
                     new_tauar.append(tuple(r2_split))
                 for index,item in enumerate(new_tauar):
                     print(index,item)
                 x=inputi(" Жоятын тауар номерін енгізіңіз : ")
                 for index,item in enumerate(new_tauar):
                     if x==index:
                         new_tauar.remove(new_tauar[index])
                         for each in new_tauar:
                             new1_tauar.append(each)
                         for index,i1 in enumerate(new1_tauar):
                             print(index,i1)
                         with open('tauarlar_tizimi.txt','w') as f:
                             for i in new1_tauar:
                                 f.write(str(i[0])+ '-' +str(i[1]) +'\n')
             elif q=='4':
                 self.end()
                 view.Home()
                 self.logout()
             elif q=='5':
                 self.manager()
         elif sh=='2':
             self.end()
             view.Home()
             self.logout()
         elif sh=='3':
             self.manager()
Esempio n. 6
0
    def staff(self):
        while True:
            user = module.User()
            user.is_staff=True
            settings.CURRENT_USER_ROLE="Staff"
            home_admin = view.Home()
            home_admin.welcome()
            sh=inputs(' жалғастырғыңыз келсе "1" ,  logout "2" , basty bet "3" : ')
            if sh=='1':
                while True:
                        q=inputs(' тауарларды көргіңіз келсе "1" , тауар қосқыңыз келсе "2", тауар бағасын өзгерткіңіз келсе "3" , logout "4" , basty bet "5" : ')
                        if q=='1':
                            new_tauar=[]
                            with open('tauarlar_tizimi.txt','r+') as e:
                                r=e.read()
                                r_split=r.split('\n')
                                r_split.pop()
                            for each in r_split:
                                r2_split=each.split("-")
                                new_tauar.append(tuple(r2_split))
                            for index,item in enumerate(new_tauar):
                                print(index,item)
                        elif q=='2':
                            new_tauar=[]
                            with open('tauarlar_tizimi.txt','r+') as e:
                                r=e.read()
                                r_split=r.split('\n')
                                r_split.pop()
                            for each in r_split:
                                r2_split=each.split("-")
                                new_tauar.append(tuple(r2_split))
                            for index,item in enumerate(new_tauar):
                                print(index,item)
                            while True:
                                t_engizu=inputs(' тауар енгізгіңіз келсе "1" , тоқтатқыңыз келсе "2": ')
                                if t_engizu=='1':
                                    t_list=[]
                                    tauar_aty=inputs(" тауар атын енгізіңіз : ")
                                    tauar_bagasy=inputf(" тауар бағасын енгізіңіз : ")
                                    t_list.append(tauar_aty)
                                    t_list.append(tauar_bagasy)
                                    new_tauar.append(tuple(t_list))
                                    for index,i in enumerate(new_tauar):
                                        print(index,i)
                                    with open('tauarlar_tizimi.txt','w') as f:
                                        for i in new_tauar:
                                            f.write(str(i[0])+ '-' +str(i[1]) +'\n')
                                elif t_engizu=='2':
                                    break
                        elif q=='3':
                            new_tauar=[]
                            with open('tauarlar_tizimi.txt','r+') as e:
                                r=e.read()
                                r_split=r.split('\n')
                                r_split.pop()
                            for each in r_split:
                                r2_split=each.split("-")
                                new_tauar.append(tuple(r2_split))
                            for index,item in enumerate(new_tauar):
                                print(index,item)

                            x=inputi(" Өзгертетін тауар нөмірін енгізіңіз : ")
                            for index,i in enumerate(new_tauar):
                                if x==index:
                                    tauar_bagasi=inputs(" тауар бағасын енгізіңіз : ")
                                    e=list(new_tauar[x])
                                    e[1]=tauar_bagasi
                                    e1=tuple(e)
                                    new_tauar.insert(x,e1)
                                    del new_tauar[x+1]
                                    for index, i in enumerate(new_tauar):
                                        print(index,i)
                                    with open('tauarlar_tizimi.txt','w') as f:
                                        for i in new_tauar:
                                            f.write(str(i[0])+ '-' +str(i[1]) +'\n')
                        elif q=='4':
                            self.end()
                            view.Home()
                            self.logout()
                        elif q=='5':
                            self.staff()
            elif sh=='2':
                    self.end()
                    view.Home()
                    self.logout()
            elif sh=='3':
                self.staff()
Esempio n. 7
0
 def Client(self):
     while True:
                 user = module.User()
                 user.is_client=True
                 settings.CURRENT_USER_ROLE="Client"
                 home_admin = view.Home()
                 home_admin.welcome()
                 tauar_tizim=[]
                 new_tauar=[]
                 with open('tauarlar_tizimi.txt','r+') as e:
                     r=e.read()
                     r_split=r.split('\n')
                     r_split.pop()
                 for each in r_split:
                     r2_split=each.split("-")
                     new_tauar.append(tuple(r2_split))
                 for index,item in enumerate(new_tauar):
                     print(index,item)
                 while True:
                     sh=inputs(' жалғастырғыңыз келсе "1" ,  logout "2", basty bet "3" : ')
                     if sh=='1':
                         sum_list=[]
                         sum=0
                         st=True
                         karzhy=inputi(" Қаржы көлемін енгізіңіз : ")
                         while True:
                             for index,item in enumerate(new_tauar):
                                 print(index,item)
                             client_zh=inputs(' жалғастырғыңыз келсе "1" , тоқтатқыңыз келсе "2": ')
                             if client_zh=='1':
                                 client_t=inputi("Сатып алғыңыз келетін тауар номерін енгізіңіз : ")
                                 if client_t<len(new_tauar) and client_t>=0:
                                     t_tizim=new_tauar[client_t]
                                     if int(t_tizim[1])<=karzhy:
                                         sum+=int(t_tizim[1])
                                         sum_list.append(sum)
                                         if st:
                                             while st:
                                                 tauar_tizim.append(t_tizim)
                                                 karzhy-=int(t_tizim[1])
                                                 u=subprocess.check_output('date').decode('utf-8')
                                                 tauar_tizim.append(u)
                                                 print(f" Алған тауарыңыз {t_tizim}, сізде қалған қаржыңыз {karzhy}")
                                                 st=False
                                         elif sum>200000:
                                             tauar_tizim.append(t_tizim)
                                             print('Сіз біздің VIP клиентіміз болдыңыз, сізде 15% жеңілдік бар')
                                             karzhy-=(int(t_tizim[1])-int(t_tizim[1])*0.15)
                                             u=subprocess.check_output('date').decode('utf-8')
                                             tauar_tizim.append(u)
                                             print(f" Алған тауарыңыз {t_tizim}, сізде қалған қаржыңыз {karzhy}")
                                     else:
                                          print(f'Кешіріңіз сіздің қаржыңыз тауарды алуға жеткіліксіз !!!')
                                 else:
                                     print('Қате шықты қайта енгізіңіз : ')
                              elif client_zh=='2':
                                 if sum==0:
                                     break
                                 elif sum>0:
                                     name='Сатып алынған тауар тізімі'
                                     print(f''' \n\n1mall online дүкенінен сауда жасағаныңызға көп рахмет !!!
                          {name.center(50,'-')}
                          '''+'\n')
                                     for i in range(0,len(new_tauar),2):
                                         print(new_tauar[i])
                                     j='❤❤❤'
                                     print(f''' {j.center(50,"-")} ''')
                                     print(f" Total : {sum} \n Time: {subprocess.check_output('date').decode('utf-8')} \n     Қолдау көрсеткен компания \n {subprocess.check_output('azt').decode('utf-8')}")
                                     with open('tauarr','a') as f:
                                             for i in new_tauar:
                                                 f.write(str(i)+'\n')
                                     sh=inputs(' жалғастырғыңыз келсе "1" ,  logout "2" , basty bet "3" :  ')
                                     if sh=='1':
                                         pass
                                     elif sh=='2':
                                         self.end()
                                         view.Home()
                                         self.logout()
                                     elif sh=='3':
                                         self.Client()
                     elif sh=='2':
                         self.end()
                         view.Home()
                         self.logout()
                     elif sh=='3':
                         self.Client()
Esempio n. 8
0
    def admin(self):
        view.Home().welcome()
        while True:
            admin_choice = inputi(
                "Please select your choice: 1-logout; 2-тізімдегі адамдарды көру; 3-кірген, шыққан адамдарды көрсету; 4-basty bet \n"
            )
            if admin_choice == 1:
                self.adminlogout()
            elif admin_choice == 2:
                view.Home().welcome()
                print(
                    'usr,pwd,                  date created            ,admin,staff, client , manager  '
                )
                with open('data/users.txt', 'r') as f:
                    data = f.read().split('\n')
                    data.pop()
                    for i in data:
                        print(i)
                    while True:
                        t = inputs(
                            'Сайттағы адамдардың статусын өзгерту -1, logout-2, басты бет-3: '
                        )
                        if t == '1':
                            if len(data) == 1:
                                print(
                                    'Тізімде тек Админ ғана бар, сіз-Админ өз статусыңызды өзгерте ала алмайсыз!!!'
                                )
                                while True:
                                    r1 = inputs(
                                        "q- басты бетке оралу; 1-logout ; 2-артқа қайту: "
                                    )
                                    if r1 == 'q':
                                        self.admin()
                                    elif r1 == '1':
                                        self.adminlogout()
                                    elif r1 == '2':
                                        break
                            elif len(data) > 1:
                                f_list = []
                                with open('data/users.txt', 'r+') as f:
                                    data = f.read().split('\n')
                                    data.pop()
                                    for i in data:
                                        a = i.split(',')
                                        f_list.append(a)
                                    print(
                                        '  usr,  pwd,                      date created                   , admin ,   staff , client , manager  '
                                    )
                                    for i, i1 in enumerate(f_list):
                                        print(i, i1)
                                    while True:
                                        t1 = inputs(
                                            'Статусты өзгерткіңіз келсе сол адам индексін енгізіңіз; q- басты бетке оралу; q1-logout,q2-артқа қайту :  '
                                        )
                                        if t1 == 'q':
                                            self.admin()
                                        elif t1 == 'q1':
                                            self.adminlogout()
                                        elif t1 == 'q2':
                                            break
                                        else:
                                            try:
                                                if int(t1) < len(
                                                        f_list) and int(
                                                            t1) != 0:
                                                    while True:
                                                        t2 = inputs(
                                                            'Client>>Manager-1, Client>>Staff-2 , Staff>>Manager-3:'
                                                        )
                                                        if t2 == '1':
                                                            if f_list[int(
                                                                    t1
                                                            )][5] == 'True' and f_list[int(
                                                                    t1
                                                            )][6] == 'False' and f_list[int(
                                                                    t1
                                                            )][3] != 'True' and f_list[
                                                                    int(
                                                                        t1
                                                                    )][4] != 'True':
                                                                f_list[int(
                                                                    t1
                                                                )][5] = 'False'
                                                                f_list[int(
                                                                    t1
                                                                )][6] = 'True'

                                                                print(
                                                                    '  usr,  pwd,                      date created                   , admin ,   staff , client , manager  '
                                                                )
                                                                with open(
                                                                        'data/users.txt',
                                                                        'w+'
                                                                ) as d1:
                                                                    for i in f_list:
                                                                        for it in i:
                                                                            d1.write(
                                                                                it
                                                                                +
                                                                                ','
                                                                            )
                                                                        d1.write(
                                                                            '\n'
                                                                        )
                                                                        print(
                                                                            i)
                                                                while True:
                                                                    r2 = inputs(
                                                                        "1- басты бетке оралу; q-logout ,2-артқа қайту: "
                                                                    )
                                                                    if r2 == '1':
                                                                        self.admin(
                                                                        )
                                                                    elif r2 == 'q':
                                                                        self.adminlogout(
                                                                        )
                                                                    elif r2 == '2':
                                                                        break

                                                            else:
                                                                while True:
                                                                    tr = inputs(
                                                                        '''Өзгеріс орындалмады, біреуін таңдаңыз:
                                                                    1- басты бетке оралу; q-logout;3-артқа қайту '''
                                                                    )
                                                                    if tr == '1':
                                                                        self.admin(
                                                                        )
                                                                    elif tr == 'q':
                                                                        self.adminlogout(
                                                                        )
                                                                    elif tr == '3':
                                                                        break

                                                        elif t2 == '2':
                                                            if f_list[int(
                                                                    t1
                                                            )][5] == 'True' and f_list[int(
                                                                    t1
                                                            )][4] == 'False' and f_list[int(
                                                                    t1
                                                            )][3] != 'True' and f_list[
                                                                    int(
                                                                        t1
                                                                    )][4] != 'True':
                                                                f_list[int(
                                                                    t1
                                                                )][5] = 'False'
                                                                f_list[int(
                                                                    t1
                                                                )][4] = 'True'
                                                                print(
                                                                    '  usr,  pwd,                      date created                   , admin ,   staff , client , manager  '
                                                                )
                                                                with open(
                                                                        'data/users.txt',
                                                                        'w+'
                                                                ) as d2:
                                                                    for i in f_list:
                                                                        for it in i:
                                                                            d2.write(
                                                                                it
                                                                                +
                                                                                ','
                                                                            )
                                                                        d2.write(
                                                                            '\n'
                                                                        )
                                                                        # with open('data/users.txt', 'r') as d112:
                                                                        #     data11 = d112.read().split('\n')
                                                                        #     data11.pop()
                                                                        #     for i in data11:
                                                                        print(
                                                                            i)
                                                                while True:
                                                                    r2 = inputs(
                                                                        "1- басты бетке оралу; q-logout , 2-артқа қайту: "
                                                                    )
                                                                    if r2 == '1':
                                                                        self.admin(
                                                                        )
                                                                    elif r2 == 'q':
                                                                        self.adminlogout(
                                                                        )
                                                                    elif r2 == '2':
                                                                        break
                                                            else:
                                                                while True:
                                                                    tr = inputs(
                                                                        '''Өзгеріс орындалмады, біреуін таңдаңыз:
                                                                    1- басты бетке оралу; q-logout;3-артқа қайту '''
                                                                    )
                                                                    if tr == '1':
                                                                        self.admin(
                                                                        )
                                                                    elif tr == 'q':
                                                                        self.adminlogout(
                                                                        )
                                                                    elif tr == '3':
                                                                        break

                                                        elif t2 == '3':
                                                            if f_list[int(
                                                                    t1
                                                            )][4] == 'True' and f_list[int(
                                                                    t1
                                                            )][6] == 'False' and f_list[int(
                                                                    t1
                                                            )][3] != 'True' and f_list[
                                                                    int(
                                                                        t1
                                                                    )][5] != 'True':
                                                                f_list[int(
                                                                    t1
                                                                )][4] = 'False'
                                                                f_list[int(
                                                                    t1
                                                                )][6] = 'True'
                                                                print(
                                                                    '  usr,  pwd,                      date created                   , admin ,   staff , client , manager  '
                                                                )
                                                                with open(
                                                                        'data/users.txt',
                                                                        'w+'
                                                                ) as d3:
                                                                    for i in f_list:
                                                                        for it in i:
                                                                            d3.write(
                                                                                it
                                                                                +
                                                                                ','
                                                                            )
                                                                        d3.write(
                                                                            '\n'
                                                                        )
                                                                        # with open('data/users.txt', 'r') as d31:
                                                                        #     data13 = d31.read().split('\n')
                                                                        #     data13.pop()
                                                                        #     for i in data13:
                                                                        print(
                                                                            i)
                                                                while True:
                                                                    r2 = inputs(
                                                                        "1- басты бетке оралу; q-logout,2-артқа қайту : "
                                                                    )
                                                                    if r2 == '1':
                                                                        self.admin(
                                                                        )
                                                                    elif r2 == 'q':
                                                                        self.adminlogout(
                                                                        )
                                                                    elif r2 == '2':
                                                                        break
                                                            else:
                                                                while True:
                                                                    tr = inputs(
                                                                        '''Өзгеріс орындалмады, біреуін таңдаңыз:
                                                                    1- басты бетке оралу; q-logout ; 3-артқа қайту: '''
                                                                    )
                                                                    if tr == '1':
                                                                        self.admin(
                                                                        )
                                                                    elif tr == 'q':
                                                                        self.adminlogout(
                                                                        )
                                                                    elif tr == '3':
                                                                        break
                                                                    else:
                                                                        print(
                                                                            'Kaita engiz'
                                                                        )
                                                        else:
                                                            while True:
                                                                tr = inputs(
                                                                    '''Өзгеріс орындалмады, біреуін таңдаңыз:
                                                                1- басты бетке оралу; q-logout;3-артқа қайту : '''
                                                                )
                                                                if tr == '1':
                                                                    self.admin(
                                                                    )
                                                                elif tr == 'q':
                                                                    self.adminlogout(
                                                                    )
                                                                elif tr == '3':
                                                                    break
                                                                else:
                                                                    print(
                                                                        'Kaita engiz'
                                                                    )
                                                else:
                                                    print('Kaita engiz!!!')
                                            except (ValueError):
                                                print('Kaita engiz')

                        elif t == '2':
                            self.adminlogout()
                        elif t == '3':
                            self.admin()

            elif admin_choice == 3:
                with open('data/log.txt', 'r') as f1:
                    print(f1.read())
                    while True:
                        tanda1 = inputs('1-басты бетке бару, q-loqout:')
                        if tanda1 == '1':
                            self.admin()
                        elif tanda1 == 'q':
                            self.adminlogout()
            elif admin_choice == 4:
                self.admin()
Esempio n. 9
0
    def staff(self):
        view.Home().welcome()
        while True:
            tan = inputs('1-Жалғастыру, 2-logout, 3-басты бет')
            if tan == '1':
                view.Home().welcome()
                while True:
                    tandau = inputs(
                        '1-списокке жаңа тауар қосу, 2-бағаларын өзгерту,3-барлық тауарлaрды көру,0-басты бет, q-logout:'
                    )
                    if tandau == '1':
                        while True:
                            n = []
                            with open('1mall.txt', 'r') as fi:
                                data = fi.read()
                                data_split = data.split('\n')
                                for i in data_split:
                                    i2 = i.split('-')
                                    n.append(tuple(i2))
                            n.pop()
                            for index, item in enumerate(n):
                                print(index, item)
                            product = inputs(
                                'Қандай продукты енгізгіңіз келеді? Атын енгізіңіз:'
                            )
                            price = inputi('Продуктының бағасы:')
                            n.append(tuple([product, price]))
                            with open('1mall.txt', 'w') as fil:
                                for item in n:
                                    fil.write(
                                        str(item[0]) + '-' + str(item[1]) +
                                        '\n')
                            while True:
                                surak = inputs(
                                    "Тізімге жаңа продукт енгізесіз бе? ok -жалғастыру үшін, q -басты бет, q1- logout :"
                                )
                                if surak == 'q':
                                    self.staff()
                                elif surak == 'ok':
                                    break
                                elif surak == 'q1':
                                    self.stafflogout()
                                else:
                                    print('Kaita engiz!')
                    elif tandau == '2':
                        n1 = []
                        with open('1mall.txt', 'r') as fi7:
                            data = fi7.read()
                            data_split = data.split('\n')
                            for i in data_split:
                                i3 = i.split('-')
                                n1.append(tuple(i3))
                        n1.pop()
                        for index, item in enumerate(n1):
                            print(index, item)
                        while True:
                            surak = inputs(
                                "Өзгерту үшін-1 , артқа қайту -2, басты бет-3, q-logout: :"
                            )
                            if surak == '1':
                                prod_index = inputi(
                                    'Қай продуктыны өзгерткіңіз келeді?: ')
                                if prod_index < len(n1) and prod_index >= 0:
                                    prod_item = list(n1[prod_index])
                                    print(prod_item[0], end=' ')
                                    change_price = inputi(
                                        'Продуктың жаңа бағасы:')
                                    prod_item.insert(1, change_price)
                                    prod_item.pop()
                                    n1.insert(prod_index, tuple(prod_item))
                                    n1.pop(prod_index + 1)
                                    with open('1mall.txt', 'w') as d4:
                                        for item in n1:
                                            d4.write(
                                                str(item[0]) + '-' +
                                                str(item[1]) + '\n')

                                else:
                                    print(
                                        f" {prod_index} -Өкінішке орай сіз қателестіңіз, бұндай продукт жоқ! "
                                    )
                            elif surak == '2':
                                break
                            elif surak == '3':
                                self.staff()
                            elif surak == 'q':
                                self.stafflogout()

                    elif tandau == '3':
                        print('Продукты тізімі:')
                        with open('1mall.txt', 'r') as f1:
                            print(f1.read())
                            while True:
                                surau = inputs(
                                    'q-logout, 1-басты бет,2-артқа қайту')
                                if surau == 'q':
                                    self.stafflogout()
                                elif surau == '1':
                                    self.staff()
                                elif surau == '2':
                                    break
                    elif tandau == '0':
                        self.staff()
                    elif tandau == 'q':
                        self.stafflogout()
            elif tan == '2':
                self.stafflogout()
            elif tan == '3':
                self.staff()
Esempio n. 10
0
    def manager(self):
        view.Home().welcome()
        while True:
            tanda = inputs('1-Жалғастыру, 2-loqout , 3-басты бет \n')
            if tanda == '1':
                view.Home().welcome()
                while True:
                    tandau = inputi(
                        '1-барлық продукты тізімін көру,2-тізімнен продуктыны өшіру, 3-сатылған продуктылардың тізімін көру, 4-басты бет, 5-logout:'
                    )
                    if tandau == 1:
                        with open('1mall.txt', 'r') as f:
                            print(f.read())
                        while True:
                            engiz4 = inputs(
                                ' басты бетке оралу -q, logout -1, артқа қайту-2: '
                            )
                            if engiz4 == 'q':
                                self.manager()
                            elif engiz4 == '1':
                                self.managerlogout()
                            elif engiz4 == '2':
                                break
                    elif tandau == 2:
                        n2 = []
                        with open('1mall.txt', 'r') as fi8:
                            data = fi8.read()
                            data_split = data.split('\n')
                            for i in data_split:
                                i3 = i.split('-')
                                n2.append(tuple(i3))
                        n2.pop()
                        for index, item in enumerate(n2):
                            print(index, item)
                        while True:
                            engiz = inputs(
                                'Жалғастыру үшін-ok , басты бет -q, logout -1,  артқа қайту-2: '
                            )
                            if engiz == 'ok':
                                tandau1 = inputi(
                                    'Тізімдегі қай продуктыны өшіресіз? ')
                                if tandau1 >= 0 and tandau1 < len(n2):
                                    n2.remove(n2[tandau1])
                                    with open('1mall.txt', 'w') as d5:
                                        for i in n2:
                                            d5.write(i[0] + '-' + i[1] + '\n')
                                    break
                                else:
                                    print('Бұндай продукты тізімде жоқ!')
                            elif engiz == 'q':
                                self.manager()
                            elif engiz == '1':
                                self.managerlogout()
                            elif engiz == '2':
                                break
                    elif tandau == 3:
                        with open('zakaz.txt', 'r') as z:
                            print(z.read())
                            while True:
                                engiz4 = inputs(
                                    ' басты бетке оралу -q, logout -1,артқа қайту -2: '
                                )
                                if engiz4 == 'q':
                                    self.manager()
                                elif engiz4 == '1':
                                    self.managerlogout()
                                elif engiz4 == '2':
                                    break
                    elif tandau == 4:
                        self.manager()
                    elif tandau == 5:
                        self.managerlogout()

            elif tanda == '2':
                self.managerlogout()
            elif tanda == '3':
                self.manager()
Esempio n. 11
0
    def client(self):
        view.Home().welcome()
        while True:
            tanda = inputs('1-Жалғастыру, 2-loqout , 3-басты бет \n')
            if tanda == '1':
                view.Home().welcome()
                sum = 0
                shopping_list = []
                print('Бізде бар продуктылар тізімі: ')
                n3 = []
                with open('1mall.txt', 'r') as fi8:
                    data = fi8.read()
                    data_split = data.split('\n')
                    for i in data_split:
                        i3 = i.split('-')
                        n3.append(tuple(i3))
                n3.pop()
                for index, item in enumerate(n3):
                    print(index, item)
                surau = inputi('Сіздің жалақыңыз қанша?: ')
                zhalaky = surau
                while True:
                    surau1 = inputs(
                        "Онлайн шоппингті жалғастыру -'ok', онлайн шоппингті тоқтату-'q', logout -1, басты бет-q1 "
                    )
                    if surau1 == 'ok':
                        print('Бізде бар продуктылар тізімі: ')
                        n2 = []
                        with open('1mall.txt', 'r') as fi8:
                            data = fi8.read()
                            data_split = data.split('\n')
                            for i in data_split:
                                i3 = i.split('-')
                                n2.append(tuple(i3))
                        n2.pop()
                        for index, item in enumerate(n2):
                            print(index, item)
                        surau3 = inputi(
                            "Қай продуктыны сатып алғыңыз келеді? ")
                        if surau3 < len(n2) and surau3 >= 0:
                            p_item = list(n2[surau3])
                            p_int = int(p_item[1])
                            if p_int <= surau:
                                shopping_list.append(tuple(p_item))
                                sum += p_int
                                surau -= p_int
                                print(
                                    f'Сіз таңдаған продукты жәшікке салынды, сіздің қазіргі балансыңыз {surau}'
                                )
                                timenow = subprocess.check_output(['date'
                                                                   ]).decode()
                                with open('zakaz.txt', 'a') as file:
                                    file.write(
                                        str(p_item[0]) + '-' + str(p_item[1]) +
                                        '-' + timenow)

                            else:
                                print(
                                    'Кешіріңіз, бірақ сіздің балансыңыз жетпейді!!!'
                                )
                        else:
                            print(
                                f"Бізде {surau3}-бұл продукт жоқ,  кешіріңіз... "
                            )
                    elif surau1 == 'q':
                        if sum > 0:

                            ch = set()
                            print('1mall онлайн магазин')
                            print(''.center(30, '-'))
                            timenow = subprocess.check_output(['date'
                                                               ]).decode()
                            print(timenow)
                            for i in shopping_list:
                                sd = (i, shopping_list.count(i))
                                ch.add(sd)
                            for each in ch:
                                print(each)
                            print(''.center(30, '-'))
                            with open('a.txt', 'r') as file:
                                data1 = file.read()
                            f_list = []
                            with open('data/log.txt', 'r') as f:
                                data = f.read().split('\n')
                                data.pop()
                                for i in data:
                                    a = i.split(',')
                                    f_list.append(a)
                            q = str(f_list[len(f_list) - 1][0])
                            q1 = str(f_list[len(f_list) - 1][1])
                            sum1 = 0
                            if q in data1 and q1 in data1:
                                print(
                                    'Сіз VIP клиeнтсіз,сізге жалпы -15% Скидка болады!!!'
                                )
                                sum1 = sum - sum * 0.15
                                print(f"ИТОГ         ={sum1}")
                                print('Сатып алғаныңыз үшін рахмет!')
                            else:
                                print(f"ИТОГ         ={zhalaky - surau}")
                                print('Сатып алғаныңыз үшін рахмет!')
                            if sum >= 200000:
                                f_list = []
                                with open('data/log.txt', 'r') as f:
                                    data = f.read().split('\n')
                                    data.pop()
                                    for i in data:
                                        a = i.split(',')
                                        f_list.append(a)
                                q = str(f_list[len(f_list) - 1][0])
                                q1 = str(f_list[len(f_list) - 1][1])
                                with open('a.txt', 'a') as file:
                                    file.write(q + ',' + q1 + '\n')
                            while True:
                                tr = inputs(
                                    '''1- басты бетке оралу; q-logout;3-артқа қайту : '''
                                )
                                if tr == '1':
                                    self.client()
                                elif tr == 'q':
                                    self.clientlogout()
                                elif tr == '3':
                                    break

                        else:
                            self.client()

                    elif surau1 == '1':
                        self.clientlogout()
                    elif surau1 == 'q1':
                        self.client()
            elif tanda == '2':
                self.clientlogout()
            elif tanda == '3':
                self.client()