コード例 #1
0
def lender_dashboard(lender_email):
    """Lender profile to view their posted gear and upload equipment"""

    lender = Lender.query.filter_by(lender_email=lender_email).first()

    camper_email = session.get("camper_email")
    if camper_email:
        raise Exception(
            "Hey there, camper! If you want to lend gear out, please log in separately."
        )

    if request.method == 'GET':
        return render_template("lender.html", lender=lender)
    else:
        category = request.form.get('category_type')
        brand = request.form.get('brand_type')
        gear_name = request.form.get('gear_name')
        zipcode = request.form.get('zipcode')
        gear_photo = request.form.get('photo')
        filename = photos.save(request.files['photo'])
        gear_photo = str(photos.path(filename))
        gear_photo_url = photos.url(filename)

        gear = Equipment(gear_name=gear_name,
                         category=category,
                         brand=brand,
                         lender_email=lender_email,
                         zipcode=zipcode,
                         gear_photo=gear_photo,
                         gear_photo_url=gear_photo_url)
        db.session.add(gear)
        db.session.commit()
        flash('You successfully uploaded your gear!')
        return redirect("/equipment/%s" % lender.lender_email)
コード例 #2
0
def load_equipment():
    equipment_result_list = call_api('equipment')
    for result_dict in equipment_result_list:
        equipment_id = result_dict['id']
        equipment_name = result_dict['name']

        equipment = Equipment(equipment_id=equipment_id,
                              equipment_name=equipment_name)

        db.session.add(equipment)
    db.session.commit()
コード例 #3
0
ファイル: crud.py プロジェクト: SungBaek/Fridg
def add_equipment(recipe, equipment):
    """Add recipe's equipment, one by one, to database."""

    # Instantiate a recipe's equipment
    equipment = Equipment(recipe_id=recipe, equipment=equipment)

    # add to database
    db.session.add(equipment)
    db.session.commit()

    return
コード例 #4
0
def load_equips():
    """Load equipments from equip_data into database."""

    for line in open("seed_data/equip_data"):
        line = line.rstrip()
        equip_id, user_id, name, ein, eq_type = line.split(",")

        equip = Equipment(equip_id=equip_id,
                          user_id=user_id,
                          name=name,
                          ein=ein,
                          eq_type=eq_type)

        db.session.add(equip)

    db.session.commit()
コード例 #5
0
ファイル: server.py プロジェクト: jennLam/task-assign
def add_equip():
    """Add equipment to database."""

    name = request.form.get("name")
    ein = request.form.get("ein")
    eq_type = request.form.get("type")

    existing_equip = Equipment.query.filter_by(name=name).first()

    new_equip = Equipment(user_id=g.user_id,
                          name=name,
                          ein=ein,
                          eq_type=eq_type)

    check_and_add(existing_equip, new_equip)

    return redirect(request.referrer)
コード例 #6
0
def load_equipment():
    """ Load equipment into database. """

    for row in open("static/equipment.csv"):
        row = row.rstrip()

        gear_name, category, brand, lender_email, zipcode, gear_photo, gear_photo_url = row.split(
            ",")

        equipment = Equipment(gear_name=gear_name,
                              category=category,
                              brand=brand,
                              lender_email=lender_email,
                              zipcode=zipcode,
                              gear_photo=gear_photo,
                              gear_photo_url=gear_photo_url)

        db.session.add(equipment)

    db.session.commit()
コード例 #7
0
ファイル: Clement.py プロジェクト: jsexauer/ItBuildsCharacter
        self.will = 2

c = Character()
c.name = 'Clement'
c.lvl = 6
c.BAB = 6
c.rpg_class = Ranger()

# Ability Scores
c.base.str_score = 19
c.base.dex_score = 16
c.base.con_score = 14
# All the others are the default value of 10

# Armor
breastplate = Equipment("Mithral Chain Shirt +2")
breastplate.AC = 6
breastplate.ACP = 0
c.equipment.append(breastplate)

cr = Equipment("Ammulute of Natural Armor +2")
cr.natural_armor = 2
c.equipment.append(cr)

# Weapons
wep1 = Weapon("+1 Tidewater Cutless",
                        Attack(1, "1d6+1", [18,19,20]))
c.equipment.main_hand = wep1

wep2 = Weapon("+1 Keen Mwk Handaxe", Attack(1, "1d6+1", [19,20], 3))
c.equipment.off_hand = wep2
コード例 #8
0
ファイル: Henri.py プロジェクト: jsexauer/ItBuildsCharacter
c = Character()
c.name = 'Henri (Level 11)'
c.lvl = 11
c.BAB = 11
c.rpg_class = Cavalier()

# Ability Scores
c.base.str_score = 20
c.base.dex_score = 12
c.base.con_score = 13
c.base.cha_score = 16
# All the others are the default value of 10

# Armor
breastplate = Equipment("Mytheral Breastplate of Speed")
breastplate.AC = 10
breastplate.ACP = -3
c.equipment.append(breastplate)

cr = Equipment("Cloak of Resistance +3")
cr.fort = 3
cr.ref = 3
cr.will = 3
c.equipment.append(cr)

rp = Equipment("Ring of Protection +2")
rp.deflection_bonus = 2
c.equipment.append(rp)

# Weapons