示例#1
0
def manager_signup(request):
    if request.method == 'GET':
        return render(request, 'manager_register.html')

    if request.method == 'POST':
        username = request.POST.get('username')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')
        context = {}
        context.update(csrf(request))
        if username == '' or password1 == '' or password2 == '':
            context['error'] = '必填项不能为空'
            return render(request, 'manager_register.html', context=context)
        if not password1 == password2:
            context['error'] = '两次输入密码不一致'
            return render(request, 'manager_register.html', context=context)
        try:
            u = Manager.objects.get(name=username)
        except:
            try:
                manager = Manager(name=username, password=password1)
                manager.save()
                context['success'] = "注册成功"
                response = render(request, 'manager_register.html', context)
                #设置cookie
                response.set_cookie('manager_username', username, 3600)
                return response
            except Exception, e:
                print e
                context['error'] = "长度不符合要求"
                return render(request, 'manager_register.html', context)
        else:
            context['error'] = "用户名已存在"
            return render(request, 'manager_register.html', context)
示例#2
0
    def register_manager_customer(first_name, last_name, username, password, company,
                                  street_address, city, state, zipcode, credit_cards, database):
        # Generate Manager row
        new_manager = Manager(username=username, password=None, firstname=first_name,
                              lastname=last_name, state=state, city=city, zipcode=zipcode,
                              street=street_address, companyname=company)
        new_manager.password = hash_password(password, new_manager)
        database.add(new_manager)
        database.commit()

        # Execute an insert onto Customer manually to avoid duplicate User creation
        database.execute(Customer.__table__.insert(), {
            "username": username,
            "password": new_manager.password,
            "firstname": first_name,
            "lastname": last_name})

        # Insert credit cards
        new_credit_cards = [Creditcard(
            creditcardnum=cc, owner=username) for cc in credit_cards]
        database.add_all(new_credit_cards)
        database.commit()
        token = provision_jwt(new_manager, is_manager=True, is_customer=True,
                              cc_count=len(credit_cards)).get_token().decode()
        return jsonify({"token": token})
示例#3
0
def solve_tsumego(tsumego_path: str,
                  first_page: int,
                  out_dir: str,
                  h: int,
                  w: int,
                  r: int,
                  show_fairy_lights: bool = False):
    # Setup.
    current_page = first_page
    print_instructions()

    # Initialize window.
    manager = Manager(tsumego=np.zeros([10, 10, 3]),
                      show_height=h,
                      show_width=w,
                      stone_size=r)
    cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_GUI_NORMAL + cv2.WINDOW_AUTOSIZE)
    set_mouse_callbacks(manager=manager)

    while True:
        # Read pdf and get corresponding page from it.
        pages = convert_from_path(tsumego_path,
                                  first_page=current_page,
                                  last_page=current_page)
        if len(pages) == 0:
            print('Last pdf page has been reached.')
            break

        tsumego_page = np.array(pages[0])
        manager.reset(tsumego=tsumego_page)

        # Get path to where solutions will be stored.
        all_solved_tsumegos = glob(os.path.join(out_dir, '*'))
        variation_number = 0
        out_path = get_out_image_name(out_dir, current_page, variation_number)
        while out_path in all_solved_tsumegos:
            variation_number += 1
            out_path = get_out_image_name(out_dir, current_page,
                                          variation_number)

        # Solve tsumego page and store results.
        exit_editor, save_tsumego = start_loop(
            manager=manager, show_fairy_lights=show_fairy_lights)
        if save_tsumego:
            store_results(tsumego=tsumego_page,
                          path=out_path,
                          solutions=manager.solutions,
                          stone_size=r)

        # Go to the next page or exit program.
        if exit_editor:
            print('Goodbye. See you soon.')
            break

        current_page += 1

    cv2.destroyWindow(WINDOW_NAME)
    return current_page
示例#4
0
def register():
    if request.method == 'GET':
        return render_template("register.html")
    else:
        work_id = request.form.get('work_id')
        password = request.form.get('password')
        manager = Manager(work_id,password)
        manager.save()
        return render_template("login.html")
示例#5
0
 def register_manager(first_name, last_name, username, password, company,
                      street_address, city, state, zipcode, database):
     # Add new manager to the database
     new_manager = Manager(username=username, password=None, firstname=first_name,
                           lastname=last_name, state=state, city=city, zipcode=zipcode,
                           street=street_address, companyname=company)
     new_manager.password = hash_password(password, new_manager)
     database.add(new_manager)
     database.commit()
     token = provision_jwt(new_manager, is_manager=True, cc_count=0).get_token().decode()
     return jsonify({"token": token})
示例#6
0
def load_values():
    conn = mysql.connect()
    cursor = conn.cursor()
    print('\n\nINITIALIZING DB\n\n')

    query1 = """
        INSERT INTO department_lookup (token, department)
        VALUES (%s,%s)"""
    for i, dept in enumerate(client.departments):
        cursor.execute(query1, (dept.token, client.DEPARTMENT_LIST[i]))
        print(dept.token + client.DEPARTMENT_LIST[i] + ' has been inserted.',
              file=stderr)

    emp = Employee(cursor, conn, immediate_commit=False)
    for e in client.employees:
        emp.insert(e.token, e.first_name, e.last_name, e.parent_token)
        print(e.token + 'h has been inserted.', file=stderr)

    desc = "My primary role is managing different banking sectors involved in asset management, sanctioning loans, " \
           "mortgages, investments, and account operations. I oversee the efficient day to day processes as well as " \
           "preparing forecasts and reports to drive the overall success of our clients and the department. "

    man = Manager(cursor, conn, immediate_commit=False)
    for dept in client.DEPARTMENT_LIST:
        man.insert(client.MANAGERS[dept]['email'],
                   client.MANAGERS[dept]['pass'],
                   client.MANAGERS[dept]['first_name'],
                   client.MANAGERS[dept]['last_name'], 'Sr. Division Manager',
                   desc, client.MANAGERS[dept]['manager_dept_FK'],
                   client.MANAGERS[dept]['gender'])

    trans = Transaction(cursor, conn, immediate_commit=False)
    for t in client.transactions:
        if t.recipient_user_token is None:
            trans.insert(
                t.sender_business_token,
                t.recipient_business_token,
                Transaction.current_time(t.created_time),
                t.amount,
            )
        else:
            trans.insert(
                t.sender_business_token,
                t.recipient_user_token,
                Transaction.current_time(t.created_time),
                t.amount,
            )
    conn.commit()
    conn.close()
    simulate_startup()
    session['db_init'] = True

    create_background_scheduler()
示例#7
0
def start_loop(manager: Manager,
               show_fairy_lights: bool = False,
               fairy_lights_semi_period: int = 3,
               intensity: int = 0,
               direction: int = 1) -> Tuple[bool, bool]:
    # Initialize images.
    image = manager.get_showed_image()

    # Start fairy lights
    if show_fairy_lights:
        fairy_lights_positions = get_fairy_lights_positions(image)
    else:
        fairy_lights_positions = ()

    # Show images in a loop.
    while True:
        # Refresh video image if needed.
        if manager.refresh:
            image = manager.get_showed_image()
            manager.refresh = False

        # Show images and process key-board callbacks.
        if show_fairy_lights:
            cv2.imshow(
                WINDOW_NAME,
                put_fairy_lights(image.copy(),
                                 positions=fairy_lights_positions,
                                 intensity=intensity,
                                 color=(20, 99, 156)))
        else:
            cv2.imshow(WINDOW_NAME, image)
        key = cv2.waitKey(500) & 0xFF

        # Process pressed key.
        break_loop, exit_editor, save_tsumego = process_key(key=key,
                                                            manager=manager)

        if break_loop:
            break

        # Change fairy light intensity.
        if show_fairy_lights:
            intensity += direction / fairy_lights_semi_period

            if intensity >= 1:
                intensity = 1
                direction = -1
            elif intensity <= 0:
                intensity = 0
                direction = 1

    return exit_editor, save_tsumego
示例#8
0
def loadCsv():

    i = 0

    try:

        with open('user_manager.csv') as csv_userManager:

            csv_read = csv.reader(csv_userManager)

            for manager in csv_read:

                i += 1
                insertManager(manager[0], manager[1], manager[2], manager[3])
                manager_db = Manager(manager[0], manager[1], manager[2],
                                     manager[3])
                managers_db_list.addManager(manager_db)
                name_manager = separateEmail(manager[3])

            messagebox.showinfo(
                "CSV", "Se han importado correctamente %s Managers." % str(i))

    except sqlite3.OperationalError:

        messagebox.showerror("Error", "Debe conectar la Base de datos primero")

    except Exception as e:

        messagebox.showerror("ERROR", "Los registros ya fueron cargados")
示例#9
0
 def get(self):
     from models import Manager, BoardDirector, Auditor, SeniorManagement
     managers = Manager.get_all()
     board_directors = BoardDirector.get_all()
     auditors = Auditor.get_all()
     senior_managers = SeniorManagement.get_all()
     self.render('management.html', managers=managers, board_directors=board_directors,auditors=auditors, senior_managers=senior_managers)
    def add_manager(self, db_session: Session, community_id: int,
                    manager_to_add: ManagerCreate):
        community = (db_session.query(Community).options(
            lazyload("managers")).get(community_id))
        manager = Manager(
            phone=manager_to_add.phone,
            name=manager_to_add.name,
            is_blocked=manager_to_add.is_blocked,
        )

        community.managers.append(manager)
        db_session.add(community)
        db_session.commit()
        db_session.refresh(community)
        return community
示例#11
0
def admin_login():
    error = None
    if request.method == 'POST':
        try:
            manager = Manager.get(request.form['username'])
        except Exception, e:
            return render_template('admin_login.html', error=e)
        print manager, request.form['password']
        if not manager:
            error = 'username or password is wrong'
        elif request.form['password'] != manager.password:
            error = 'username or password is wrong'
        else:
            session['username'] = request.form['username']
            flash('You have logged in')
            return redirect(url_for('show_entries'))
示例#12
0
def login():
    if request.method == 'GET':
        return render_template("login.html")
    else:
        work_id = request.form.get('work_id')
        password = request.form.get('password')
        try:
            manager = Manager.search(work_id)
            if manager.password == password:
                session['manager'] = work_id
                projects = getpro(work_id)
                return render_template("manager.html", allrec = "", work_id = work_id, projects = projects)
            else:
                return render_template("login.html")
        except:
            return render_template("login.html")
示例#13
0
    def process_team(self,
                     tree,
                     league,
                     add_to_roster=True,
                     week=None,
                     manager_only=False):
        if manager_only:
            for manager in tree.findall('./yh:managers', self._ns):
                id = manager.find('.//yh:guid', self._ns).text
                manager, created = Manager.update_or_create(
                    _id=id,
                    defaults={
                        'nickname': manager.find('.//yh:nickname',
                                                 self._ns).text
                    })
            return None, None

        id = tree.find('./yh:team_id', self._ns).text
        key = tree.find('./yh:team_key', self._ns).text
        team, created = Team.update_or_create(
            _id=id,
            key=key,
            defaults={
                'name':
                tree.find('./yh:name', self._ns).text,
                'logo': [
                    logo.text
                    for logo in tree.find('./yh:team_logos', self._ns).findall(
                        './/yh:url', self._ns)
                ][0],
                'league':
                league
            })

        if created:
            for manager in tree.findall('./yh:managers', self._ns):
                id = manager.find('.//yh:guid', self._ns).text
                manager, created = Manager.get_or_create(
                    _id=id,
                    defaults={
                        'nickname': manager.find('.//yh:nickname',
                                                 self._ns).text
                    })
                team.managers.add(manager)

        for player in tree.findall(".//yh:player", self._ns):
            player, points, selected_position = self.process_player(player)
            if add_to_roster:
                team.roster.add(player)
            if week and selected_position:
                print(player.name, team.name, week, selected_position)
                slot = MatchupRosterSlot.select().where(
                    MatchupRosterSlot.week == week,
                    MatchupRosterSlot.team == team,
                    MatchupRosterSlot.player == player).get()
                slot.position = selected_position
                slot.save()

        projected_points = None
        points = None
        if tree.find('./yh:team_projected_points', self._ns):
            projected_points = float(
                tree.find('./yh:team_projected_points',
                          self._ns).find('./yh:total', self._ns).text)
        if tree.find('./yh:team_points', self._ns):
            points = float(
                tree.find('./yh:team_points',
                          self._ns).find('./yh:total', self._ns).text)
        return team, projected_points, points
示例#14
0
def process_key(key: int, manager: Manager) -> Tuple[bool, bool, bool]:
    break_loop = False
    exit_editor = False
    save_tsumego = True
    if key == ord('c'):
        manager.change_color()
        manager.refresh = True
    elif key == ord('p'):
        manager.reset_numbering()
        manager.refresh = True
    elif key == ord('b'):
        manager.remove_stone()
        manager.refresh = True
    elif key == ord('v'):
        manager.toggle_stone_visibility()
    elif key == ord('n'):
        break_loop = True
    elif key == ord('s'):
        break_loop = True
        save_tsumego = False
    elif key == ord('q'):
        break_loop = True
        exit_editor = True
    elif key == ord('e'):
        break_loop = True
        exit_editor = True
        save_tsumego = False

    return break_loop, exit_editor, save_tsumego
示例#15
0
Steve = Employee('Steve')

# Add to DB

db.session.add_all([Bob, Steve])

db.session.commit()

# Check DB Commit

print(Employee.query.all())

Bob = Employee.query.filter_by(
    name='Bob').first()  # Return the first value from the query

Jim = Manager('Jim', Bob.id)

# Assign roles

role_primary = Role('Custodian', Bob.id)
role_secondary = Role('Security Guard', Bob.Id)

db.session.add_all([Jim, role, primary_role, role_secondary])

db.session.commit()

# Query to confirm
Bob = Employee.query.filter_by(name='Bob').first()

print(Bob)
示例#16
0
def save_managerdata():
    emp_code1 = request.form.get('emp_code1')
    reviewer_name1 = request.form.get('reviewer_name1')
    reviewer_code1 = request.form.get('reviewer_code1')

    manager_assessment1 = request.form.get('manager_assessment1')
    manager_assessment1_comment1 = request.form.get(
        'manager_assessment1_comment1')

    achieved_score1 = request.form.get('achieved_score1')

    manager_assessment2 = request.form.get('manager_assessment2')
    manager_assessment2_comment2 = request.form.get(
        'manager_assessment2_comment2')

    achieved_score2 = request.form.get('achieved_score2')

    manager_assessment3 = request.form.get('manager_assessment3')
    manager_assessment3_comment3 = request.form.get(
        'manager_assessment3_comment3')

    achieved_score3 = request.form.get('achieved_score3')

    manager_assessment4 = request.form.get('manager_assessment4')
    manager_assessment4_comment4 = request.form.get(
        'manager_assessment4_comment4')

    achieved_score4 = request.form.get('achieved_score4')

    manager_assessment5 = request.form.get('manager_assessment5')
    manager_assessment5_comment5 = request.form.get(
        'manager_assessment5_comment5')

    achieved_score5 = request.form.get('achieved_score5')

    manager_assessment6 = request.form.get('manager_assessment6')
    manager_assessment6_comment6 = request.form.get(
        'manager_assessment6_comment6')

    achieved_score6 = request.form.get('achieved_score6')

    total_achieved_score = request.form.get('total_achieved_score')

    manager_final_comment = request.form.get('manager_final_comment')
    manager_final_rating = request.form.get('manager_final_rating')

    rev_email1 = request.form.get('rev_email1')

    signature = utils.save_signature(request.form.get('signature'),
                                     'reviewer_name1', 'signature')

    manager_form = Manager(
        emp_code1=emp_code1,
        reviewer_name1=reviewer_name1,
        reviewer_code1=reviewer_code1,
        manager_assessment1=manager_assessment1,
        manager_assessment1_comment1=manager_assessment1_comment1,
        achieved_score1=achieved_score1,
        manager_assessment2=manager_assessment2,
        manager_assessment2_comment2=manager_assessment2_comment2,
        achieved_score2=achieved_score2,
        manager_assessment3=manager_assessment3,
        manager_assessment3_comment3=manager_assessment3_comment3,
        achieved_score3=achieved_score3,
        manager_assessment4=manager_assessment4,
        manager_assessment4_comment4=manager_assessment4_comment4,
        achieved_score4=achieved_score4,
        manager_assessment5=manager_assessment5,
        manager_assessment5_comment5=manager_assessment5_comment5,
        achieved_score5=achieved_score5,
        manager_assessment6=manager_assessment6,
        manager_assessment6_comment6=manager_assessment6_comment6,
        achieved_score6=achieved_score6,
        total_achieved_score=total_achieved_score,
        manager_final_comment=manager_final_comment,
        manager_final_rating=manager_final_rating,
        signaturepath=signature,
        IP_addr=request.remote_addr,
        Location=request.form.get('location'),
        UserAgent=request.user_agent.browser,
        OperatingSystem=request.user_agent.platform,
        Time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
    )

    db.session.add(manager_form)
    db.session.commit()
    utils.send_manager_link_as_mail(
        rev_email1=rev_email1,
        reviewer_code1=reviewer_code1,
        emp_code1=emp_code1,
    )
    return redirect('/success')
示例#17
0
def create(email, raw_password):
    manager = Manager(email, raw_password)
    g.db.add(manager)
    g.db.flush()