示例#1
0
def plan(account_id, plan_id):
    try:
        dao = PlanDao(content, account_id)
        plan = dao.retrieve(plan_id)
        return dao.get_schema().dumps(plan, indent=2), 200
    except Exception as e:
        raise InvalidUsage(str(e))
示例#2
0
def update_plan_cdl(account_id, plan_id):
    try:
        dao = PlanDao(content, account_id)
        plan = dao.retrieve(plan_id)
        plan.cdl = request.data
        dao.save(plan)
        return plan.cdl, 200
    except Exception as e:
        raise InvalidUsage(str(e))
示例#3
0
def plan_kml(account_id, plan_id):
    dao = PlanDao(content, account_id)
    plan = dao.retrieve(plan_id)
    fin = preprocess(StringIO(plan.cdl))
    analyser = CdlFileAnalyser()
    cdl_file = analyser.analyse(fin)
    kml = cdlfile_to_KML(cdl_file, plan_id)
    return kml, 200, {
        'Content-Type': 'application/vnd.google-earth.kml+xml; charset=utf-8'
    }
示例#4
0
def plan_update(account_id, plan_id):
    try:
        dao = PlanDao(content, account_id)
        plan = dao.retrieve(plan_id)
        plan = dao.from_json(request.data)
        if plan_id != plan.plan_id:
            raise Exception("Cannot change the plan ID")
        dao.save(plan)
    except Exception as e:
        raise InvalidUsage(str(e))

    return dao.get_schema().dumps(plan, indent=2), 200
示例#5
0
 def setUp(self):
     os.system("rm -rf ./test_content/*")
     self.account_dao = AccountDao(Path("./test_content"))
     account = self.account_dao.load({
         'identifier': 1,
         'name': 'Trilogy Partners',
         'email': '*****@*****.**'
     })
     self.account_dao.create(account)
     self.vessel_dao = VesselDao(Path("./test_content"), account.identifier)
     trilogy = self.vessel_dao.load({
         'account_id': 1,
         'identifier': 'trilogy',
         'name': 'SV Trilogy',
         'flag': 'Australian',
         'rego': '806176',
         'speed_kts': 7.6,
     })
     self.vessel_dao.create(trilogy)
     x = self.vessel_dao.retrieve('trilogy')
     self.plan_dao = PlanDao(Path("./test_content"), account.identifier)
示例#6
0
def get_plan_cdl(account_id, plan_id):
    dao = PlanDao(content, account_id)
    plan = dao.retrieve(plan_id)
    return plan.cdl, 200
示例#7
0
def plan_add(account_id):
    dao = PlanDao(content, account_id)
    plan = dao.from_json(request.data)
    dao.create(plan)
    plan = dao.retrieve(plan.plan_id)
    return dao.get_schema().dumps(plan, indent=2), 200
示例#8
0
def plan_list(account_id):
    dao = PlanDao(content, account_id)
    plans = dao.find_all()
    return dao.get_schema().dumps(plans, many=True, indent=2), 200