Exemplo n.º 1
0
    def test_sign_up(self, end_date_input, start_date_input, cost_est_input,
                     member_input, area_input, name_input, Type_input):
        input_array = [
            '2019-02-22', '2019-02-21', 2000, 200, 'area', 'name', 'type'
        ]
        end_date_input.return_value = input_array[0]
        start_date_input.return_value = input_array[1]
        cost_est_input.return_value = input_array[2]
        member_input.return_value = input_array[3]
        area_input.return_value = input_array[4]
        name_input.return_value = input_array[5]
        Type_input.return_value = input_array[6]

        Projects.Create_project(self.db)
        cursorObj = self.con.cursor()
        cursorObj.execute('''SELECT * from Projects where area=?''',
                          (input_array[4], ))
        output = cursorObj.fetchone()
        self.assertIsNotNone(output)
Exemplo n.º 2
0
    def BDO(buname):
        while True:
            print(
                "\nMenu\n(1)Create GPM accounts\n(2)Delete GPM accounts\n(3)Update GPM\n(4)Create Project\n(5)Update "
                "Project\n(6)Delete Project\n(7)Show GPM accounts\n(8)Show Projects\n(9)Show member accounts\n(10)See "
                "the complaints\n(11)Approve Pending Requests\n(12)Previous Menu"
            )
            choice = input(">>> ").lower().rstrip()
            if choice == "1":
                print('Here you can add new GPM accounts')
                bdoid = buname

                User.sign_up(con, 'gpm', bdoid)

            elif choice == "2":
                print('Here you can delete GPM accounts')
                gpms = Grama.List_of_gpms(con, buname)
                pd.set_option('display.width', None)
                df = pd.DataFrame(gpms)
                df.columns = [
                    'name', 'username', 'area', 'pincode', 'BdoUsername'
                ]
                print(df)
                uname = input("Please enter a username to be deleted : ")
                User.delete_account(con, uname, 'gpm')

            elif choice == "3":
                print('Here you can Update GPM accounts')
                gpms = Grama.List_of_gpms(con, buname)
                pd.set_option('display.width', None)
                df = pd.DataFrame(gpms)
                df.columns = [
                    'name', 'username', 'area', 'pincode', 'BdoUsername'
                ]
                print(df)
                gpmid = input('Enter the GpmId you want to update : ')
                Grama.Update_GPM(con, buname, gpmid)

            elif choice == "4":
                print('Here you can Create a project')
                Projects.Create_project(con)

            elif choice == "5":
                cursorObj = con.cursor()

                print('Here you can Update a ProjectMain')
                Projects.show_projects(con)
                projid = input(
                    'Enter the id of the project you want to edit : ')
                cursorObj.execute('SELECT * from Projects where Projectid=?',
                                  (projid, ))
                projects = cursorObj.fetchone()
                if projects is not None:
                    Projects.Update_project(con, projid)
                else:
                    print('No project found with the id', projid)

            elif choice == "6":
                print('Here you can Delete a project')
                Projects.show_projects(con)
                projid = input(
                    'Enter the id of the project you want to delete : ')
                Projects.Delete_project(con, projid)

            elif choice == "7":
                print('Here you can see all the accounts')
                gpms = Grama.List_of_gpms(con, buname)
                pd.set_option('display.width', None)
                df = pd.DataFrame(gpms)
                df.columns = [
                    'name', 'username', 'area', 'pincode', 'BdoUsername'
                ]
                print(df)

            elif choice == "8":
                print('Here you can see all the projects')
                Projects.show_projects(con)
            elif choice == "9":
                print('Here you can see all the member accounts')
                cursorObj = con.cursor()
                cursorObj.execute(
                    'SELECT Members.username,Members.Gpmapproved,Members.Bdoapproved,Members.WorkingDays,'
                    'Members.pincode,Members.wage,Members.attendance,Members.projectid from GPM INNER JOIN '
                    'Members on GPM.username=Members.Gpmid '
                    'where GPM.Bdo_id=?', (buname, ))
                member_under_bdos = cursorObj.fetchall()
                pd.set_option('display.width', None)
                df = pd.DataFrame(member_under_bdos)
                df.columns = [
                    'Username', 'Gpm_Approved', 'Bdo_Approved', 'WorkingDays',
                    'Pincode', 'Wage', 'Attendance', 'ProjectId'
                ]
                print(df)

            elif choice == "10":
                print(
                    'Here you can see all the issues raised by the member under you'
                )
                cursorObj = con.cursor()
                cursorObj.execute(
                    'SELECT Members.username from GPM INNER JOIN Members on GPM.username=Members.Gpmid '
                    'where GPM.Bdo_id=?', (buname, ))
                memberid = cursorObj.fetchall()
                for member in memberid:
                    cursorObj.execute(
                        'SELECT * from Complaints where memberid= ? ',
                        (member[0], ))
                    Complaints_received = cursorObj.fetchall()
                    pd.set_option('display.width', None)
                    df = pd.DataFrame(Complaints_received)
                    try:
                        df.columns = [
                            'Id', 'Issue', 'MemberId', 'Bdo_remarks',
                            'Gpm_remarks'
                        ]
                        print(df)
                    except:
                        print('')
                        main.BDO(buname)
            elif choice == "11":
                Projects.show_projects(con)
                cursorObj = con.cursor()
                cursorObj.execute(
                    'SELECT Members.username,Members.Gpmapproved,Members.Bdoapproved,Members.WorkingDays,'
                    'Members.pincode,Members.wage,Members.attendance,Members.projectid from GPM INNER JOIN '
                    'Members on GPM.username=Members.Gpmid '
                    'where GPM.Bdo_id=?', (buname, ))
                member_under_bdos = cursorObj.fetchall()
                pd.set_option('display.width', None)
                df = pd.DataFrame(member_under_bdos)
                df.columns = [
                    'Username', 'Gpm_Approved', 'Bdo_Approved', 'WorkingDays',
                    'Pincode', 'Wage', 'Attendance', 'ProjectId'
                ]
                print(df)
                memuname = input(
                    'Enter the member username you want to approve : ')
                Projects.Approve_Projects(con, memuname)

            elif choice == "12":
                main.Login_master(con)

            else:
                print("Invalid choice, please choose again\n")