Esempio n. 1
0
def init_lists(c_list, s_list, a_list):

    course1 = Course("CSC227", 2)
    course1.add_student("1003")
    course1.add_student("1004")
    c_list.append(course1)
    course2 = Course("CTI115", 2)
    course2.add_student("1001")
    c_list.append(course2)
    course3 = Course("DBA130", 1)
    course3.add_student("1002")
    c_list.append(course3)

    student1 = Student("1001", "111")
    s_list.append(student1)
    student2 = Student("1002", "222")
    s_list.append(student2)
    student3 = Student("1003", "333")
    s_list.append(student3)
    student4 = Student("1004", "444")
    s_list.append(student4)

    admin1 = Admin("8001", "888")
    a_list.append(admin1)
    admin2 = Admin("9001", "999")
    a_list.append(admin2)
def init_lists(c_list, s_list, a_list):
    """
    This function adds elements to course_list, student_list and
    admin_list.  It makes testing and grading easier.  It has
    three parameters: c_list is the list of Course objects;
    s_list is the list of Student objects; a_list is the list of
    Admin objects.  This function has no return value.
    
    """

    course1 = Course("CSC121", 2)
    course1.add_student("1004")
    course1.add_student("1003")
    c_list.append(course1)
    course2 = Course("CSC122", 2)
    course2.add_student("1001")
    c_list.append(course2)
    course3 = Course("CSC221", 1)
    course3.add_student("1002")
    c_list.append(course3)

    student1 = Student("1001", "111")
    s_list.append(student1)
    student2 = Student("1002", "222")
    s_list.append(student2)
    student3 = Student("1003", "333")
    s_list.append(student3)
    student4 = Student("1004", "444")
    s_list.append(student4)

    admin1 = Admin("7001", "777")
    a_list.append(admin1)
    admin2 = Admin("8001", "888")
    a_list.append(admin2)
Esempio n. 3
0
    def load_bank_data(self):
        customer_1 = Customer("Adam", "1234", ["14", "Wilcot Street", "Bath", "B5 5RT"])
        account_no = 1234
        account_1 = Account(5000.00, account_no)
        customer_1.open_account(account_1)
        self.customers_list.append(customer_1)

        customer_2 = Customer("David", "password", ["60", "Holborn Viaduct", "London", "EC1A 2FD"])
        account_no+=1
        account_2 = Account(3200.00,account_no)
        customer_2.open_account(account_2)
        self.customers_list.append(customer_2)


        customer_3 = Customer("Alice", "MoonLight", ["5", "Cardigan Street", "Birmingham", "B4 7BD"])
        account_no+=1
        account_3 = Account(18000.00,account_no)
        customer_3.open_account(account_3)
        self.customers_list.append(customer_3)


        customer_4 = Customer("Ali", "150A",["44", "Churchill Way West", "Basingstoke", "RG21 6YR"])
        account_no+=1
        account_4 = Account(40.00,account_no)
        customer_4.open_account(account_4)
        self.customers_list.append(customer_4)


        admin_1 = Admin("Julian", "1441", True, ["12", "London Road", "Birmingham", "B95 7TT"])
        self.admins_list.append(admin_1)

        admin_2 = Admin("Eva", "2222", False, ["47", "Mars Street", "Newcastle", "NE12 6TZ"])
        self.admins_list.append(admin_2)
def main():
    loginPrompt = "Please select option: login | guest | register | admin: "
    val = input(loginPrompt)
    logins = readLogins("loginStore.txt")
    adminLogins = readLogins("adminLoginStore.txt")

    global isGuest
    isGuest = True

    if val == "login" or val == "register":
        # register accounts
        if val == "register":
            logins = register(logins)

        # login time
        login(logins, False)

        isGuest = False

    elif val == "admin":
        isSuccess = login(adminLogins, True)

        if (not isSuccess):
            exit()

        admin = Admin()
        admin.modify()

        print("Exiting admin session")

        exit()

    cart = ShoppingCart(isGuest)
    cart.startShopping()
Esempio n. 5
0
 def get_admin(self, key):
     with dbapi2.connect(self.app.config['dsn']) as connection:
         cursor = connection.cursor()
         query = "SELECT NAME, SURNAME, USERNAME, EMAIL, PASSWORD, YEAR FROM ADMIN WHERE (ID = %s)"
         cursor.execute(query, (key,))
         name, surname, username, email, password, year = cursor.fetchone()
     return Admin(name, surname, username, email, password, year,"admin")
Esempio n. 6
0
    def __init__(self):
        cpy.tools.buffet = BuffetTool(config("template_engine"))
        #set the output encoding
        self._cp_config["cpy.tools.encode.encoding"] = "utf-8"

        #make our stylesheet {divname: (top, left, size)}
        self.discs = {
            "top": (50, 650, 146),
            "topright": (230, 560, 146),
            "right": (345, 370, 146),
            "botright": (381, 140, 146),
            "botleft": (230, 0, 146),
            "left": (260, 25, 146),
            "topleft": (80, 75, 146)
        }
        styletemp = mako.template.Template(filename="templates/styles.mak")
        fout = file("static/styles.css", "w")\
                .write(styletemp.render(discs=self.discs))

        #load the admin page. We have to import Admin after the config has
        #loaded or else it borks
        from admin import Admin
        self.admin = Admin()

        from team import TeamAdmin
        self.team_admin = TeamAdmin()

        from cherryblossom import BlogRoot
        self.blog = BlogRoot('/blog')
Esempio n. 7
0
def run():
    # 将判断用户登录处理 和显示界面的admin类 实例化
    admin = Admin()
    #调用显示 登录的界面
    admin.welcomeView()
    #判断 如果 为假 也就是 登录失败的情况下  下面的代码 不在执行
    # if not admin.adminLogin():
    #     return
    #调用显示功能界面
    while True:
        admin.showFunc()
        choose = input("请输入 你要 操作的功能")
        atm = Func()  #实例化 银行各种操作的类
        if choose == '1':
            atm.createUser()
        elif choose == '2':
            atm.checkBalance()
        elif choose == '3':
            print("你选择了存款的操作")
        elif choose == '4':
            print("你选择了取款的操作")

        #用户的信息(更改或者没有更改的数据信息)
        userData = atm.allUserData
        f = open("mysql.txt", "wb")
        pickle.dump(userData, f)
        f.close()
Esempio n. 8
0
def register():
    name = Admin()
    search = SearchForm()
    if current_user.is_authenticated:
        redirect(url_for('index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        city = form.city.data
        otdel = form.otdel.data
        phone = form.phone.data
        user = User(username=form.username.data,
                    name=form.name.data,
                    lastname=form.lastname.data,
                    email=form.email.data,
                    password=hashed_password,
                    city=city,
                    otdel=otdel,
                    phone=phone)

        db.session.add(user)
        db.session.commit()
        flash('Спасибо за регистрацию', 'success')
        return redirect('/login')

    return render_template('register.html',
                           title='Регистрация',
                           form=form,
                           search=search,
                           admin=name)
def list_public_projects(project_type):
    '''
    
    '''
    admin = Admin()
    list_of_projects = admin.list_projects(project_type, project_access='public')
    return jsonify(list_of_projects)
Esempio n. 10
0
def main():

    admin = Admin()  #管理员对象
    admin.printAdminView()  #管理员开机
    if admin.adminOperation():
        return -1

    atm = ATM()

    while True:
        #等待用户操作
        admin.sysFunctionView()
        option = input("请输入你的操作:")
        if option == '0':
            atm.createUser()
        if option == '1':
            pass
        elif option == '2':
            pass
        elif option == '3':
            pass
        elif option == '4':
            pass
        elif option == '5':
            pass
        elif option == '6':
            pass
        elif option == '7':
            pass
        elif option == '8':
            pass
        elif option == '9':
            if admin.adminOperation():
                return -1
Esempio n. 11
0
def delivery():
    search = SearchForm()
    name = Admin()
    return render_template('delivery.html',
                           search=search,
                           admin=name,
                           title='Доставка')
Esempio n. 12
0
def adminLogin():
    # get the log in state and redirect to the index page if true
    if session.get('adminLogin'):
        return redirect(url_for('admin_page'))

    messages = ""
    # get the parameters if the request method is GET
    if request.method == "GET":
        if request.args.get('loggedout'):
            messages = "You have been logged out!"
        elif request.args.get('loginerror'):
            messages = "Username & Password combination is incorrect, try again!"
    # get the POST data if request method is POST
    elif request.method == "POST":
        admin_username = request.form['username']
        admin_password = request.form['password']
        admin_password = hashlib.sha256(admin_password.encode()).hexdigest()

        # call the login_admin method for the Admin class right after creating the admin object
        admin = Admin()
        response = admin.login_admin(username=admin_username, password=admin_password)
        if response:
            # set session parameters and timeout to 5mins and redirect to the index page
            session.permanent = True
            app.permanent_session_lifetime = datetime.timedelta(minutes=5)
            session['adminLogin'] = True
            session['adminUsername'] = admin_username
            return redirect(url_for('admin_page', username=admin_username))
        else:
            return redirect(url_for("adminLogin", loginerror=True))

    return render_template('admin_login.html', data = messages), 200
Esempio n. 13
0
    def login_menu(self):
        """ Display Login options for users to choose.
        :return: True
        """
        print("\n**** LOGIN MENU ****")
        print("Enter '#' for exiting.\n")
        email = input("Email: ").lower()
        if email == '#':
            print("\nExiting...")
            self.conn.close()
        else:
            pswd = input("Password: "******"\nWrong Credentials!  Try again.")

            self.login_menu()

        return True
Esempio n. 14
0
    def test_show_cabs_failure_no_data(self, mocksql):
        sqlite_execute_mock = mock.Mock()
        mocksql.cursor.return_value = sqlite_execute_mock
        sqlite_execute_mock.execute.return_value = sqlite_execute_mock
        sqlite_execute_mock.fetchall.return_value = []

        assert Admin(mocksql).show_cabs() is False
Esempio n. 15
0
    def test_show_cabs_success(self, mocksql):
        sqlite_execute_mock = mock.Mock()
        mocksql.cursor.return_value = sqlite_execute_mock
        sqlite_execute_mock.execute.return_value = sqlite_execute_mock
        sqlite_execute_mock.fetchall.return_value = cabs_data

        assert Admin(mocksql).show_cabs() is True
Esempio n. 16
0
    def test_show_employees_success(self, mocksql):
        sqlite_execute_mock = mock.Mock()
        mocksql.cursor.return_value = sqlite_execute_mock
        sqlite_execute_mock.execute.return_value = sqlite_execute_mock
        sqlite_execute_mock.fetchall.return_value = members

        assert Admin(mocksql).show_employees() is True
Esempio n. 17
0
    def test_update_member_validation_failure_invalid_email(self, mocksql):
        sqlite_execute_mock = mock.Mock()
        mocksql.cursor.return_value = sqlite_execute_mock

        assert Admin(mocksql).update_member_validation(
            'fname', 'lanme', '*****@*****.**', 'emai%[email protected]', '9898989898',
            34) is False
Esempio n. 18
0
    def login_user(self, username):
        connection = self.database_connect()

        sql = "SELECT * FROM gebruiker where gebruikersnaam like (%s)"

        data = (username, )
        cursor = connection.cursor()
        cursor.execute(sql, data)
        result = cursor.fetchall()

        if result != []:

            print("Welkom, " + username.title())
            self.database_disconnect(connection)

            if result[0][2] == 'admin' or result[0][2] == 'Admin':
                self.user = Admin(result[0][0], result[0][1], result[0][2])
            elif result[0][2] == 'employee' or result[0][2] == 'Employee':
                self.user = Employee(result[0][0], result[0][1], result[0][2])

            self.database_disconnect(connection)
            return self.user

        # Als een user niet in de database voorkomt, wordt een errormessage gegevens en kan de gebruiker nogmaals
        # proberen in te loggen
        else:
            print(
                "Deze user bestaat niet, of je hebt een typfout gemaakt. Probeer het nog een keer."
            )
            self.database_disconnect(connection)
            return False
Esempio n. 19
0
def aboutus():
    search = SearchForm()
    name = Admin()
    return render_template('aboutUs.html',
                           search=search,
                           admin=name,
                           title='О магазине')
Esempio n. 20
0
def main():
    global database
    global markov
    global updater
    global chat_states
    # This is safe as long as we only access the db within the dispatcher
    # callbacks. If not then we need locks.
    database = Database(sqlite3.connect(config.DBFILE,
                                        check_same_thread=False))
    database.initialize()
    markov = Markov(database)
    chat_states = ChatStates(database)
    updater = Updater(config.TOKEN)

    updater.last_update_id = database.get_parameter('last_update', -1) + 1

    admin = Admin(database, markov, updater, chat_states, config.ADMIN_LIST)

    dp = updater.dispatcher

    admin.register_handlers(dp)
    dp.add_handler(MessageHandler(Filters.sticker, on_sticker), 0)
    dp.add_handler(MessageHandler(Filters.all, on_message), 0)

    # Commit updates after being handled. This avoids messages being handled
    # twice or updates being missed
    dp.add_handler(MessageHandler(Filters.all, on_post_message), 1)
    dp.add_handler(AllUpdateHandler(on_post_update), 1)

    dp.add_error_handler(on_error)

    updater.start_polling()
    updater.idle()
    os._exit(0)
Esempio n. 21
0
def contacts():
    search = SearchForm()
    name = Admin()
    return render_template('contacts.html',
                           search=search,
                           admin=name,
                           title='Контакты')
Esempio n. 22
0
def start_bot():
    client.add_cog(InGame(client))
    client.add_cog(OutOfGame(client))
    client.add_cog(Admin(client))
    client.add_cog(JustForFun(client))
    client.loop.create_task(check_for_new_logs())
    client.run(os.environ['80DAYS_TOKEN'])
Esempio n. 23
0
def edit_profile():
    search = SearchForm()
    name = Admin()
    form = EditProfileForm()
    iduser = current_user.get_id()
    profile = User.query.filter_by(id=iduser).first()
    if profile:
        form.name.data = profile.name
        form.lastname.data = profile.lastname
        form.email.data = profile.email
        form.city.data = profile.city
        form.otdel.data = profile.otdel
        form.phone.data = profile.phone
        if form.validate_on_submit():
            profile.username = request.form.get('user')
            profile.name = request.form.get('name')
            profile.lastname = request.form.get('lastname')
            profile.email = request.form.get('email')
            profile.city = request.form.get('city')
            profile.otdel = request.form.get('otdel')
            profile.phone = request.form.get('phone')
            db.session.commit()
            flash('Ваши изменения были сохранены', 'success')
            return redirect(url_for('profile'))

    return render_template('edit-profile.html',
                           form=form,
                           search=search,
                           admin=name,
                           title='Редактирвание профиля')
Esempio n. 24
0
 def load_bank_data(self):
     account_no = 1234
     with open('accounts.csv') as csvfile:
         readCSV = csv.reader(csvfile, delimiter=',')
         customers = []
         accounts = []
         currentIndex = 0
         for row in readCSV:
             if row[0] == "Customer":
                 customers.append(
                     Customer(row[1], row[2],
                              [row[3], row[4], row[5], row[6]]))
                 currentCustomer = customers[currentIndex]
                 currentAcc = Account(row[7], account_no, row[8], row[9])
                 accounts.append(currentCustomer.open_account(currentAcc))
                 customers_list.append(currentCustomer)
                 currentIndex = currentIndex + 1
             elif row[0] == "Admin":
                 # Combine accounts and customer/admin or open accounts with for loop after readcsv
                 customers.append(
                     Admin(row[1], row[2], True,
                           [row[3], row[4], row[5], row[6]]))
                 currentAdmin = customers[currentIndex]
                 currentAcc = Account(row[7], account_no, row[8], row[9])
                 admins_list.append(currentAdmin)
                 currentIndex = currentIndex + 1
             # Applying fee if its past loan return date
             if currentAcc.getLoanAmount(
             ) != 0 and currentAcc.getReturnDate() > datetime.now():
                 balance = currentAcc.get_balance()
                 currentAcc.set_balance(balance - 50)
Esempio n. 25
0
def authentication():
    conn = sqlite3.connect('school.db')
    c = conn.cursor()
    print('Hola, por favor ingresa tus credenciales')
    username = input('Usuario: ')
    password = getpass('Contraseña: ')

    c.execute(
        'SELECT id, username, password, first_name, last_name FROM teachers WHERE username = "******" AND password  = "******"'
        .format(username, password))
    data_readed = c.fetchall()
    if len(data_readed) > 0:
        user_data = data_readed[0]
        current_user = Teacher(user_data[0], user_data[1], user_data[2],
                               user_data[3], user_data[4])
        c.close()
        conn.close()
        return current_user
    else:
        c.execute(
            'SELECT id, username, password, first_name, last_name FROM admin_users WHERE username = "******" AND password  = "******"'
            .format(username, password))
        data_readed = c.fetchall()
        if len(data_readed) > 0:
            user_data = data_readed[0]
            current_user = Admin(user_data[0], user_data[1], user_data[2],
                                 user_data[3], user_data[4])
            c.close()
            conn.close()
            return current_user
        else:
            c.close()
            conn.close()
            return print('No user found')
Esempio n. 26
0
    def login(self):

        #Instâncias:
        self.adm = Admin()
        self.janela = Tk()

        # Propriedades da janela:
        self.janela.title("Sistema de estacionamento UNIESP 1.0")
        self.janela.configure(bg="black")
        self.janela.geometry("1000x600")
        self.janela.resizable(False, False)

        #   BACKGROUNDS:

        self.image1 = PhotoImage(file="images/login.png")
        self.image1 = self.image1.subsample(1, 1)
        self.labelimage = Label(self.janela, bg='black', image=self.image1)

        #   FRAMES:
        self.framelogin = Frame(self.janela, bg='#6d0d10')


        #   FUNÇÕES:

        def tela_login():
            self.labelimage.place(x=5, y=5, relwidth=1.0, relheight=1.0)
            self.framelogin.pack(side=BOTTOM, pady='93', padx='1')
            self.text_login.grid(row=0, column=0, padx='2')
            self.text_senha.grid(row=1, column=0, padx='2')
            self.entry_login.grid(row=0, column=1)
            self.entry_senha.grid(row=1, column=1)
            self.button_enter.grid(row=2, column=1, pady='8')


        def enter_login():
            self.login = self.entry_login.get()
            self.senha = self.entry_senha.get()
            for i in range(0, 1):
                if (self.login) in self.adm.gestor:
                    if (self.login == self.adm.gestor[i][0]) and self.senha == self.adm.gestor[i][1]:
                        self.gestor()
                    else:
                        print("erro")
                else:
                    print("erro")

            #   WIDJETS:

        # login:

        self.text_login = Label(self.framelogin, text='Login:'******'#6d0d10', fg='white')
        self.text_senha = Label(self.framelogin, text='Senha:', bg='#6d0d10', fg='white')
        self.entry_login = Entry(self.framelogin, width=35)
        self.entry_senha = Entry(self.framelogin, width=35)
        self.button_enter = Button(self.framelogin, text='Entrar', bg='#C02', fg='white', command=enter_login)

        # página 1:

        tela_login()
        self.janela.mainloop()
Esempio n. 27
0
def main():
    # 1.创建管理员对象
    ad = Admin("admin", "123")
    # 2. 管理员登录
    ad.landUI()
    # 3.创建atm对象
    atm = Atm()
    # 4.显示操作界面
    while True:
        atm.printOptionUI()  # 5.用户输入对应的编号,调用对应的函数
        bh = input("请输入编号")
        if bh == "1":
            atm.creatUser()
        elif bh == "2":
            atm.serach()
        elif bh == "3":
            atm.save()
        elif bh == "4":
            atm.take()
        elif bh == "5":
            atm.transfer()
        elif bh == "6":
            atm.change()
        elif bh == "7":
            atm.lock()
        elif bh == "8":
            atm.unlock()
        elif bh == "9":
            atm.clear()
        elif bh == "T":
            atm.exit()
Esempio n. 28
0
def newAdmin():
    if not database.check_admin_token(request.cookies.get("tovel_token_admin")):
        resp = make_response(redirect("/admin?sessionexpired"))
        resp.set_cookie('tovel_token_admin', '', expires=0)
        return resp
    admin = database.get_admin(database.get_userid_from_token(request.cookies.get("tovel_token_admin"), True))

    response = ''
    if request.method == "POST":
        print(dumps(request.form))
        name = request.form["name"]
        surname = request.form["surname"]
        password = request.form["password"]
        username = request.form["username"]
        if not database.check_admin(username):
            admin = Admin(username=username, name=name, surname=surname, pw=password)
            database.register_admin(admin)
            resp = make_response(redirect("/get-totp-key"))  # Redirect to the homepage
            resp.set_cookie("admin_id", admin.id)  # Set the cookie
            return resp
        else:
            response = '''<div class="alert alert-danger"
                                    role="alert">Admin with the same username already exists</div>'''
            pass

    replace_list = {
        "#Name": admin.name + " " + admin.surname,
        "{{outcome}}": response
    }

    with open("static-assets/new_admin.html") as f:
        html = f.read()
        for search, replace in replace_list.items():
            html = html.replace(search, replace)
    return html
Esempio n. 29
0
def main(argv):
    loop = True
    floors = []
    if len(sys.argv) < 3:
        printWarning(
            "usage:\nMVP\t -n = Number of floors\n\t -m= Number of Elevators")
        return 0
    m, n = int(sys.argv[1]), int(sys.argv[2])
    printInfo("received values:" + str(n) + " " + str(m))
    admin = Admin(n, m)
    for i in range(m):
        floors.append(Floor(i, admin))

    while loop:  ## While loop which will keep going until loop = False
        admin.printStatusElevators()
        print_menu()  ## Displays menu
        choice = input("Enter your choice [1-3]: ")
        if choice == 1:
            floor, destination = map(
                int,
                raw_input(" <floor> <destination floor>\n").split(" "))
            if floor <= m and destination <= m and destination != floor:
                up_down = 1 if destination > floor else 2
                closer_elevator = floors[floor].askResources(up_down)
                print "The elevator " + str(
                    closer_elevator) + " will attend this request"
                threading.Timer(
                    1, set_floor,
                    [admin.elevators[closer_elevator], floor, destination
                     ]).start()
            #routine to ask elevator
        elif choice == 2:
            admin.printStatusElevators()
        elif choice == 3:
            loop = False
Esempio n. 30
0
def main():
    try:
        f = open(filePath, "rb")
        allUsers = pickle.load(f)
    except EOFError:
        allUsers = {}

    # 初始化实例
    admin = Admin()
    atm = ATM(allUsers)

    # 登录界面
    admin.printLoginView()
    # 验证信息
    if admin.logCheck():
        return -1
    # 进入操作界面
    else:
        admin.printFuncView()

    while 1:
        option = input("$ Please input your choice: ")
        if option == 'q':
            print("Thanks for support! Bye~")
            # 将用户信息保存在本地
            f = open(filePath, "wb")
            pickle.dump(atm.allUsers, f)
            f.close()

            return 0
        # 验证身份

        # 进行操作
        optionSel(atm, option)