Пример #1
0
def addmission_post():
    vm = AddMissionViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()
    mission = db_edits.create_mission(vm.missionid, vm.name, vm.start, vm.end, vm.info)

    if not mission:
        vm.error = 'The mission could not be created'
        return vm.to_dict()

    audit_message = 'Add Mission ' + str(vm.missionid) + ' ' + vm.name
    vm.message = 'Success! You have added ' '<a href="/mission' + str(vm.missionid) + '">' + "Mission " + str(
        vm.missionid) + "</a>" + ': ' + vm.name
    vm.name = ''
    vm.missionid = ''
    vm.start = ''
    vm.end = ''
    vm.info = ''
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    vm.message = vm.message + '<br> would you like to <a href="/account/add_target">add a target?</a>'
    return vm.to_dict()
Пример #2
0
def addtarget_post():
    vm = AddTargetViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    target = db_edits.create_target(vm.missionid, vm.name, vm.lat, vm.lon, vm.radius, vm.goto)

    if not target:
        vm.error = 'The target could not be created'
        return vm.to_dict()

    audit_message = 'Add Target ' + vm.name + ' to mission ' + str(vm.missionid)
    vm.message = 'Success! You have added target <b>' + vm.name + '</b> to ' + \
                 '<a href="/mission' + str(vm.missionid) + '">' + "Mission " + str(vm.missionid) + "</a>"
    vm.name = ''
    vm.missionid = ''
    vm.lat = ''
    vm.lon = ''
    vm.radius = ''
    vm.goto = ''
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()
Пример #3
0
def addpin_post():
    vm = AddPinViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    waypoint = db_edits.create_waypoint(vm.missionid, vm.name, vm.lat, vm.lon, vm.info)

    if not waypoint:
        vm.error = 'The waypoint could not be created'
        return vm.to_dict()

    audit_message = 'Add Pin ' + vm.name + ' to mission ' + str(vm.missionid)
    vm.message = 'Success! You have added pin <b>' + vm.name + '</b> to ' + \
                 '<a href="/mission' + str(vm.missionid) + '">' + "Mission " + str(vm.missionid) + "</a>"
    vm.name = ''
    vm.missionid = ''
    vm.lat = ''
    vm.lon = ''
    vm.info = ''
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()
Пример #4
0
def remove_dive_post():
    vm = RemoveDiveViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    dive = delete_dive(vm.dive_id)
    if not dive:
        vm.error = 'Mission could not be removed'
        return vm.to_dict()

    audit_message = 'Removed dive' + str(dive.DiveInfoID)
    vm.message = 'Success! Removed dive ' + str(dive.DiveInfoID)
    vm.update()
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()
Пример #5
0
def remove_mission_post():
    vm = RemoveMissionViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    mission = delete_mission(vm.mission_id)
    if not mission:
        vm.error = 'Mission could not be removed'
        return vm.to_dict()

    audit_message = 'Removed Mission ' + str(mission.Number)
    vm.message = 'Success! Removed Mission ' + str(mission.Number)
    vm.update()
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()
Пример #6
0
def remove_target_post():
    vm = RemoveTargetViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    target = delete_target(vm.target_id)
    if not target:
        vm.error = 'Target could not be removed'
        return vm.to_dict()

    audit_message = 'Removed Target ' + str(target.TargetsID) + ' from Mission ' + str(target.MissionID)
    vm.message = 'Success! Removed Target ' + str(target.TargetsID) + ' from Mission ' + str(target.MissionID)
    vm.update()
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()
Пример #7
0
def remove_pin_post():
    vm = RemovePinViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    pin = delete_pin(vm.pin_id)
    if not pin:
        vm.error = 'Pin could not be removed'
        return vm.to_dict()

    audit_message = 'Removed Pin ' + str(pin.WaypointsID) + ' from Mission ' + str(pin.MissionID)
    vm.message = 'Success! Removed Pin ' + str(pin.WaypointsID) + ' from Mission ' + str(pin.MissionID)
    vm.update()
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()
Пример #8
0
def assigntag_post():
    vm = AssignTagViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()
    tag = db_edits.assign_tag(vm.tag_num, vm.missionid, vm.gliderid)
    if not tag:
        vm.error = 'The tag could not be assigned'
        return vm.to_dict()

    audit_message = 'Add tag' + str(vm.tag_num)
    vm.message = f'Success! You have assigned tag {vm.tag_num} to SG{vm.gliderid} on mission {vm.missionid} '
    vm.tag_num = ''
    vm.missionid = ''
    vm.gliderid = ''
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()
Пример #9
0
def assignglider_post():
    vm = AssignGliderViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()
    glider = assign_glider(vm.glider_num, vm.missionid)
    if not glider:
        vm.error = 'The glider could not be assigned to the mission'
        return vm.to_dict()

    audit_message = 'Assign glider SG' + str(vm.glider_num) + ' to mission' + str(vm.missionid)
    vm.message = 'Success! You have assigned glider ' '<a href="/gliders/SG' + str(vm.glider_num) + '">' + "SG" + str(
        vm.glider_num) + "</a>"  ' to ' + '<a href="/mission' + str(vm.missionid) + '">' + "mission " + str(vm.missionid) + "</a>"
    vm.glider_num = ''
    vm.missionid = ''
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()
Пример #10
0
def addtag_post():
    vm = AddTagViewModel()
    vm.validate()
    if vm.error:
        return vm.to_dict()
    if vm.overwrite_check:
        delete_tag(vm.tag_num)
    tag = db_edits.create_tag(vm.tag_num, vm.missionid, vm.gliderid)
    if not tag:
        vm.error = 'The tag could not be created'
        return vm.to_dict()

    audit_message = 'Add tag' + str(vm.tag_num)
    vm.message = f'Success! You have added tag {vm.tag_num}'
    vm.tag_num = ''
    vm.missionid = ''
    vm.gliderid = ''
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()
Пример #11
0
def remove_multiple_dives_post():
    vm = RemoveMultipleDivesViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    dive = delete_multiple_dives(vm.glider_id)
    if not dive:
        vm.error = 'Dives could not be removed'
        return vm.to_dict()

    audit_message = 'Removed dives glider' + str(dive.GliderID)
    vm.message = 'Success! Removed dives from SG' + str(dive.GliderID) + \
                 ' in Mission 1 <br> now go and delete the matlab lock files and dive images on the basestation:'\
                 + f'<br> /home/matlab/processed/sg{str(dive.GliderID)}/processed.1-x' + \
                 '<br> /mnt/gliderstore/dives/Mission1/' + str(dive.GliderID)
    vm.update()
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '<br>This entry has been logged'
    return vm.to_dict()
Пример #12
0
def addglider_post():
    vm = AddGliderViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()
    if vm.overwrite_check:
        delete_glider(vm.glider_num)
    glider = db_edits.create_glider(vm.glider_num, vm.name, vm.info, vm.missionid, vm.ueaglider)
    if not glider:
        vm.error = 'The glider could not be created'
        return vm.to_dict()

    audit_message = 'Add glider SG' + str(vm.glider_num) + ' ' + vm.name
    vm.message = 'Success! You have added glider ' '<a href="/gliders/SG' + str(vm.glider_num) + '">' + "SG" + str(
        vm.glider_num) + "</a>" + ': ' + vm.name
    vm.glider_num = ''
    vm.name = ''
    vm.missionid = ''
    vm.info = ''
    audit_log = audit_entry(vm.user_id, audit_message)
    if audit_log:
        vm.message = vm.message + '. This entry has been logged'
    return vm.to_dict()