コード例 #1
0
def alteritem(item_id):
    form = request.form
    itemname = form.get('itemname')
    itemprice = form.get('itemprice')
    itemimage = form.get('itemimage')
    discount = form.get('discount')
    threshold = form.get('threshold')
    percentage = form.get('percentage')
    Item.alteritem(item_id, itemname, itemprice, itemimage, discount,
                   threshold, percentage)
    session['item_data'] = Item.query(order=None)
    return redirect(url_for('seller_index'))
コード例 #2
0
 def item_world_drop():
     #arrange
     expected = Item()
     expected.id = '13102'
     expected.name = 'Cassandra\'s Grace'
     expected.type = TypeEnum.BY_KILLING
     expected.location = TypeEnum.TYPE_BY_WORLD_EVENT
     expected.slot = SlotEnum(1)
     expected.method = TypeEnum.EMPTY
     expected.dropRate = TypeEnum.EMPTY
     expected.url = 'https://classic.wowhead.com/item=13102/gr%C3%A2ce-de-cassandre'
     return expected
コード例 #3
0
 def item_several_boss():
     #arrange
     expected = Item()
     expected.id = '19147'
     expected.type = TypeEnum.BY_KILLING
     expected.method = TypeEnum.METHOD_SEVERAL_BOSSESS
     expected.name = 'Ring of Spell Power'
     expected.location = 'Molten Core'
     expected.slot = SlotEnum(11)
     expected.dropRate = TypeEnum.EMPTY
     expected.url = 'https://classic.wowhead.com/item=19147/ring-of-spell-power'
     return expected
コード例 #4
0
 def item_test_boss():
     #arrange
     expected = Item()
     expected.id = '16921'
     expected.name = 'Halo of Transcendence'
     expected.location = 'Onyxia\'s Lair'
     expected.type = TypeEnum.BY_KILLING
     expected.method = TypeEnum.METHOD_KILL.replace('{targetName}',
                                                    'Onyxia')
     expected.dropRate = '18.19%'
     expected.slot = SlotEnum(1)
     expected.url = 'https://classic.wowhead.com/item=16921/halo-of-transcendence'
     return expected
コード例 #5
0
 def item_by_craft_with_sublocation():
     #arrange
     expected = Item()
     expected.id = '18405'
     expected.name = 'Belt of the Archmage'
     expected.type = TypeEnum.TYPE_BY_PROFESSION.replace(
         '{professionName}', 'Tailoring')
     expected.location = 'Knot Thimblejack\'s Cache'
     expected.slot = SlotEnum(6)
     expected.dropRate = TypeEnum.EMPTY
     expected.method = TypeEnum.EMPTY
     expected.url = 'https://classic.wowhead.com/item=18405/belt-of-the-archmage'
     return expected
コード例 #6
0
 def item_by_craft_one_location():
     #arrange
     expected = Item()
     expected.id = '14154'
     expected.name = 'Truefaith Vestments'
     expected.type = TypeEnum.TYPE_BY_PROFESSION.replace(
         '{professionName}', 'Tailoring')
     expected.location = 'Stratholme'
     expected.slot = SlotEnum(5)
     expected.dropRate = TypeEnum.EMPTY
     expected.method = TypeEnum.EMPTY
     expected.url = 'https://classic.wowhead.com/item=14154/truefaith-vestments'
     return expected
コード例 #7
0
 def item_by_quest_several_same_location():
     #arrange
     expected = Item()
     expected.id = '19383'
     expected.name = 'Master Dragonslayer\'s Medallion'
     expected.location = 'Stormwind City, Orgrimmar'
     expected.type = TypeEnum.TYPE_BY_QUEST
     expected.method = "The Lord of Blackrock"
     expected.slot = SlotEnum(2)
     expected.url = 'https://classic.wowhead.com/item=19383/master-dragonslayers-medallion'
     return expected
コード例 #8
0
 def item_by_treasure():
     #arrange
     expected = Item()
     expected.id = '11927'
     expected.name = 'Legplates of the Eternal Guardian'
     expected.type = TypeEnum.TYPE_BY_TREASURE
     expected.method = 'Chest of The Seven'
     expected.location = 'Blackrock Depths'
     expected.slot = SlotEnum(7)
     expected.url = 'https://classic.wowhead.com/item=11927/legplates-of-the-eternal-guardian#contained-in-object'
     return expected
コード例 #9
0
 def item_by_quest():
     #arrange
     expected = Item()
     expected.id = '18469'
     expected.name = 'Royal Seal of Eldre\'Thalas'
     expected.type = TypeEnum.TYPE_BY_QUEST
     expected.method = 'Holy Bologna: What the Light Won\'t Tell You'
     expected.location = 'Dire Maul'
     expected.slot = SlotEnum(12)
     expected.url = 'https://classic.wowhead.com/item=18469/royal-seal-of-eldrethalas'
     return expected
コード例 #10
0
def delete_item(order_id, lineitem_id, username):
    Orders.delete_from_basket(order_id, lineitem_id)
    session['basket_data'] = Item.basket_item_data(
        Customer.get_id_by_name(username))
    session['order_data'] = Lineitem.get_singleorder_list(
        Customer.get_id_by_name(username))
    session['total'] = Sale.get_total(username)
    session['discount_total'] = Sale.get_discount_total(username)
    session['overthreshold_total'] = Sale.get_overthreshold_total(username)
    return redirect(url_for('basket'))
コード例 #11
0
def checkout(username):
    sale = Sale(username)
    sale.checkout()
    session['basket_data'] = Item.basket_item_data(
        Customer.get_id_by_name(username))
    session['order_data'] = Lineitem.get_singleorder_list(
        Customer.get_id_by_name(username))
    session['total'] = 0
    session['discount_total'] = Sale.get_discount_total(username)
    session['overthreshold_total'] = Sale.get_overthreshold_total(username)
    return redirect(url_for('payment'))
コード例 #12
0
def add_to_basket():
    form = request.form
    username = form.get('username')
    item_id = form.get('item_id')
    if not username:
        return redirect(url_for('index_to_login'))
    sale = Sale(username)
    sale.add_item(item_id)
    session['basket_data'] = Item.basket_item_data(
        Customer.get_id_by_name(username))
    session['order_data'] = Lineitem.get_singleorder_list(
        Customer.get_id_by_name(username))
    session['total'] = Sale.get_total(username)
    session['discount_total'] = Sale.get_discount_total(username)
    session['overthreshold_total'] = Sale.get_overthreshold_total(username)
    return redirect(url_for('customer_index'))
コード例 #13
0
def alteruser(user_id):
    form = request.form
    username = form.get('username')
    password = form.get('password')
    nname = form.get('nickname')
    telephone = form.get('phone')
    address = form.get('address')
    print(user_id)
    if not Customer.is_repeated(username):
        Customer.alterusers(user_id, username, password, nname, telephone,
                            address)
        session['name'] = username
        session['basket_data'] = Item.basket_item_data(
            Customer.get_id_by_name(username))
        session['order_data'] = Lineitem.get_singleorder_list(
            Customer.get_id_by_name(username))
        session['customer_data'] = Customer.query()
        return redirect(url_for('customer_index'))
    else:
        flash('用户名重复')
        return redirect(url_for('customer_index'))
コード例 #14
0
def login():
    form = request.form
    username = form.get('name')
    password = form.get('pwd')
    role = form.get('select')
    if Customer.is_valid(username, password):
        session['name'] = username
        session['userId'] = Customer.get_id_by_name(username)
        if role == u'顾客':
            session['minute'] = Sale.getMinute(username)
            session['id'] = Customer.get_id_by_name(username)
            session['basket_data'] = Item.basket_item_data(
                Customer.get_id_by_name(username))
            session['order_data'] = Lineitem.get_singleorder_list(
                Customer.get_id_by_name(username))
            session['total'] = Sale.get_total(username)
            session['discount_total'] = Sale.get_discount_total(username)
            session['overthreshold_total'] = Sale.get_overthreshold_total(
                username)
            return redirect(url_for('customer_index'))
        else:
            flash('账号或密码错误')
            return render_template('login.html')
    elif Seller.is_valid(username, password):
        session['name'] = username
        if role == u'卖家':
            return redirect(url_for('seller_index'))
        else:
            flash('账号或密码错误')
            return render_template('payment.html')
    elif Admin.is_valid(username, password):
        session['name'] = username
        if role == u'管理员':
            return redirect(url_for('admin_index'))
        else:
            flash('账号或密码错误')
            return render_template('orders.html')
    else:
        flash('该用户不存在,请重新输入')
        return render_template('login.html')
コード例 #15
0
def seller_index():
    session['item_data'] = Item.query(order=None)
    session['allorder_data'] = Lineitem.get_allorder_list()
    return render_template('sellerindex.html')
コード例 #16
0
def index():
    booklist = Item.query()
    session['booklist'] = booklist
    return render_template('index.html')
コード例 #17
0
def delete_item1(item_id):
    Item.delete_item_from_DB(item_id)
    session['item_data'] = Item.query(order=None)
    return redirect(url_for('seller_index'))
コード例 #18
0
ファイル: hello.py プロジェクト: Myrene-DEV/ExportWowBIS
def extractItems(pages):
    lenPages = len(pages)
    for i in range(lenPages):
        page = pages[i]

        log("pages: " + str(i + 1) + '/' + str(lenPages))

        page.metadata['items'] = []
        with FetchHtmls(page.metadata['itemUrls']) as responses:
            for response in responses:
                html = response['content']

                # item global information
                item = Item()
                item.id = extractSingle(RegexEnum.REGEX_ITEM_ID, html)
                item.name = extractSingle(
                    RegexEnum.REGEX_ITEM_NAME.replace('{itemId}', item.id),
                    html)
                item.url = response['origin']
                item.slot = WowHeadEnum[extractSingle(RegexEnum.REGEX_SLOT_ID,
                                                      html)]
                item.phase = page.metadata.get('phase', '')
                item.classe = page.metadata.get('classe', '')
                item.spe = page.metadata.get('spe', '')

                # extract drop rate
                dropRate = extractSingle(RegexEnum.REGEX_DROP_CHANGE, html)

                # extract item on boss
                if (bool(dropRate)):
                    item.dropRate = dropRate
                    locationId = extractSingle(RegexEnum.REGEX_LOCATION_ID,
                                               html)
                    item.location = extractSingle(
                        RegexEnum.REGEX_LOCATION_NAME.replace(
                            '{locationId}', locationId), html)
                    item.method = TypeEnum.METHOD_KILL.replace(
                        '{targetName}',
                        extractSingle(RegexEnum.REGEX_LOOT_PNJ_NAME, html))
                    item.type = TypeEnum.BY_KILLING

                # No drop rate, the item could be loot in several boss in the instance or in quest or world drop or craft by the player or in treasur
                else:
                    # extract maybe several location
                    locationIds = extractAll(RegexEnum.REGEX_LOCATION_ID, html)

                    # item is contain in a treasure
                    if (bool(extractSingle(RegexEnum.REGEX_IS_CONTAINED,
                                           html))):
                        item.type = TypeEnum.TYPE_BY_TREASURE
                        item.location = extractSingle(
                            RegexEnum.REGEX_LOCATION_NAME.replace(
                                '{locationId}', locationIds[0]), html)
                        item.method = extractSingle(
                            RegexEnum.REGEX_TREASURE_LOCATION.replace(
                                '{locationId}', locationIds[0]), html)
                        item.dropRate = TypeEnum.EMPTY

                    # item have a location
                    elif (bool(locationIds)):
                        locationIds = distinct(locationIds)

                        # item on several boss in the same instance
                        if (len(locationIds) == 1):
                            item.location = extractSingle(
                                RegexEnum.REGEX_LOCATION_NAME.replace(
                                    '{locationId}', locationIds[0]), html)
                            item.type = TypeEnum.BY_KILLING
                            item.method = TypeEnum.METHOD_SEVERAL_BOSSESS
                            item.dropRate = TypeEnum.EMPTY

                        # world drop
                        else:
                            item.location = TypeEnum.TYPE_BY_WORLD_EVENT
                            item.type = TypeEnum.BY_KILLING
                            item.method = TypeEnum.EMPTY
                            item.dropRate = TypeEnum.EMPTY
                    else:
                        profession = extractSingle(RegexEnum.REGEX_PROFESSION,
                                                   html)

                        # item by craft
                        if (bool(profession)):
                            item.type = TypeEnum.TYPE_BY_PROFESSION.replace(
                                '{professionName}', profession.capitalize())
                            item.dropRate = TypeEnum.EMPTY
                            item.method = TypeEnum.EMPTY

                            craftLocation = extractAll(
                                RegexEnum.REGEX_CRAFT_LOCATION.replace(
                                    '{itemName}', str(item.name)), html)
                            if (craftLocation):
                                # item have a sub locationz
                                if (craftLocation
                                        and bool(craftLocation[0][4])):
                                    item.location = craftLocation[0][4]
                                else:
                                    item.location = extractSingle(
                                        RegexEnum.REGEX_LOCATION_NAME.replace(
                                            '{locationId}',
                                            str(craftLocation[0][7])), html)

                        # item by quest
                        else:

                            item.type = TypeEnum.TYPE_BY_QUEST
                            item.dropRate = TypeEnum.EMPTY

                            # extract quest location id  id by group (2 group)
                            locationIds = []
                            extractLocations = extractAll(
                                RegexEnum.REGEX_QUEST_LOCATION_ID, html)
                            if (bool(extractLocations)):
                                for locationId in extractLocations:
                                    if (locationId[0] == ''):
                                        locationIds.append(locationId[1])
                                    else:
                                        locationIds.append(locationId[0])

                                # extract quest location name
                                locations = []
                                for locationId in locationIds:
                                    location = extractSingle(
                                        RegexEnum.REGEX_LOCATION_NAME.replace(
                                            '{locationId}', str(locationId)),
                                        html)
                                    if (bool(location)):
                                        locations.append(location)

                                if (len(locations) > 1):
                                    item.location = ', '.join(locations)
                                else:
                                    item.location = locations[0]

                            # extract method (quest name)
                            extractMethods = extractAll(
                                RegexEnum.REGEX_QUEST_NAME, html)
                            if (bool(extractMethods)):
                                methods = distinct(extractMethods)
                                if (len(methods) > 1):
                                    item.method = ', '.join(methods)
                                else:
                                    item.method = methods[0]

                page.metadata['items'].append(item)
    return pages
コード例 #19
0
def customer_index():
    booklist = Item.query()
    session['booklist'] = booklist
    session['customer_data'] = Customer.query()
    return render_template('customerindex.html')