Ejemplo n.º 1
0
def create_equipment():
    request_data = request.get_json()
    for sensor in request_data['sensors']:
        sensor['_id'] = ObjectId(sensor['$oid'])
        del sensor['$oid']
    equipment = Equipment(**request_data).save()
    return jsonify(equipment)
Ejemplo n.º 2
0
 def get(self):
     equip_type = request.args.get("equip_type")
     try:
         response = hdb.get_list(Equipment(), equip_type, "equip_type")
         return {"equipment": response}
     except Exception as error:
         gunicorn_logger.error(error)
         return "Could not retrieve equipment", 400
Ejemplo n.º 3
0
 def get(self):
     _id = request.args.get("id")
     equip = Equipment()
     try:
         equip.payload = hdb.get(equip, _id)
         return equip.payload
     except Exception as error:
         gunicorn_logger.error(error)
         return "Could not retrieve equipment", 400
Ejemplo n.º 4
0
def create_vessel():
    """
        
    """''

    record = json.loads(request.data)
    name, code, location, status, vessel = (record['name'] if "name" in record.keys() else None), (record['code'] if "code" in record.keys() else None), (record['location'] if "location" in record.keys() else None),(record['status'] if "status" in record.keys() else None), (record['vessel'] if "vessel" in record.keys() else None)
    equipment = Equipment(name=name, code=code,location=location,status= vessel, vessel= vessel)
    equipment.save()
    return jsonify(equipment.to_json()), 201
Ejemplo n.º 5
0
 def post(self):
     new_equipment = Equipment()
     valid = new_equipment.create(request.json)
     if valid:
         response = hdb.insert(new_equipment)
         return {
             "id": new_equipment._id,
             "status": response,
             "equipment": new_equipment.payload,
         }
     else:
         return "Could not create equipment", 400
Ejemplo n.º 6
0
from models.camera import Camera
from models.equipment import Equipment
from models.event import Event
from models.floor import Floor
from models.person import Person
from models.room import Room
from models.section import Section
from models.typeofequipments import Type_Of_Equipments

type1 = Type_Of_Equipments("Tables")
print(type1)
print("\n")

q1 = Equipment(34, type1)
print(q1)
print("\n")

f1 = Floor(1)

p1 = Person("Иванов Иван Иванович", 1234)
print(p1)
print("\n")

r1 = Room(101)
r1.add_equipment(q1)

f1.add_room_on_floor(r1)
print(f1)
print("\n")

s1 = Section(11)
Ejemplo n.º 7
0
    weapons = csv.DictReader(weapons_csv)
    print(weapons.fieldnames)
    # This should be the general format:
    # {
    # 	"name":"Padded Armor",
    # 	"equip_type":"light-armor",
    # 	"base_cost":5,
    # 	"weight":8,
    # 	"base_attributes":{
    # 		"armor_class":11,
    # 		"stealth":"disadvantage"
    # 	}
    # }

    for row in weapons:
        new_equip = Equipment()
        payload = {
            "name": row["name"],
            "equip_type": row["equip_type"],
            "base_cost": float(row["base_cost"]),
            "weight": int(row["weight"]),
            "base_attributes": {
                "damage": row["damage"],
                "damage_type": row["damage_type"],
                "properties": row["properties"],
                "range": row["range"],
                "hands": row["hands"],
            },
        }

        is_valid = new_equip.create(payload)
Ejemplo n.º 8
0
    armor = csv.DictReader(armor_csv)
    print(armor.fieldnames)
    # This should be the general format:
    # {
    # 	"name":"Padded Armor",
    # 	"equip_type":"light-armor",
    # 	"base_cost":5,
    # 	"weight":8,
    # 	"base_attributes":{
    # 		"armor_class":11,
    # 		"stealth":"disadvantage"
    # 	}
    # }

    for row in armor:
        new_armor = Equipment()
        payload = {
            "name": row["name"],
            "equip_type": row["equip_type"],
            "base_cost": float(row["base_cost"]),
            "weight": int(row["weight"]),
            "base_attributes": {
                "armor_class": row["armor_class"],
                "stealth": row["stealth"],
            },
        }

        is_valid = new_armor.create(payload)
        if is_valid:
            response = database.insert(new_armor)
            print(response)