Exemplo n.º 1
0
def deleteDeliveryPoint(uuid):
    entry = getDeliveryPoint(uuid)
    try:
        db.session.delete(entry)
        db.session.commit()
        deleteLog(table='deliveryPoint', uuid=unicode(uuid))
        return {'success': 'Delivery Point deleted'}
    except Exception as E:
        return {'error': unicode(E)}
Exemplo n.º 2
0
def deleteEventType(uuid):
    row = getEventType(uuid)
    try:
        db.session.delete(row)
        db.session.commit()
        deleteLog(table='eventType', uuid=unicode(uuid))
        return {'success': 'Event Type deleted'}
    except Exception as E:
        errorLog(unicode(E), table='eventType')
        return {'error': unicode(E)}
Exemplo n.º 3
0
def deleteStatus(uuid):
    row = getStatus(uuid)
    try:
        db.session.delete(row)
        db.session.commit()
        deleteLog(table='status', uuid=unicode(uuid))
        return {'success': 'Status deleted'}
    except Exception as E:
        errorLog(unicode(E), table='status')
        return {'error': unicode(E)}
Exemplo n.º 4
0
def deleteCausingFactor(uuid):
    row = getCausingFactor(uuid)
    try:
        db.session.delete(row)
        db.session.commit()
        deleteLog(table='causingFactor', uuid=unicode(uuid))
        return {'success': 'Causing Factor deleted'}
    except Exception as E:
        errorLog(unicode(E), table='causingFactor')
        return {'error': unicode(E)}
Exemplo n.º 5
0
def deleteImpact(uuid):
    entry = getImpact(uuid)
    try:
        db.session.delete(entry)
        db.session.commit()
        deleteLog(table='impact', uuid=unicode(uuid))
        return {'success': 'Impact deleted'}
    except Exception as E:
        errorLog(unicode(E), table='impact')
        return {'error': unicode(E)}
Exemplo n.º 6
0
def deleteProbability(uuid):
    entry = getProbability(uuid)
    try:
        db.session.delete(entry)
        db.session.commit()
        deleteLog(table='probability', uuid=unicode(uuid))
        return {'success': 'Probability deleted'}
    except Exception as E:
        errorLog(unicode(E), table='probability')
        return {'error': unicode(E)}
def deleteValueChainStepType(uuid):
    entry = getValueChainStepType(uuid)
    try:
        db.session.delete(entry)
        db.session.commit()
        deleteLog(table='valueChainStepType', uuid=unicode(uuid))
        return {'success': 'Value Chain Step Type deleted'}
    except Exception as E:
        errorLog(unicode(E), table='valueChainStepType')
        return {'error': unicode(E)}
Exemplo n.º 8
0
def deleteValueChain(uuid):
    row = getValueChain(uuid)
    try:
        db.session.delete(row)
        db.session.commit()
        deleteLog(table='valueChain', uuid=unicode(uuid))
        return {'success': 'Value Chain deleted'}
    except Exception as E:
        errorLog(unicode(E), table='valueChain')
        return {'error': unicode(E)}
Exemplo n.º 9
0
def deleteRiskType(uuid):
    entry = getRiskType(uuid)
    try:
        db.session.delete(entry)
        db.session.commit()
        deleteLog(table='riskType', uuid=unicode(uuid))
        return {'success': 'Risk Type deleted'}
    except Exception as E:
        errorLog(unicode(E), table='riskType')
        return {'error': unicode(E)}
Exemplo n.º 10
0
def deleteRating(uuid):
    row = getRating(uuid)
    try:
        db.session.delete(row)
        db.session.commit()
        deleteLog(table='rating', uuid=unicode(uuid))
        return {'success': 'Rating deleted'}
    except Exception as E:
        errorLog(unicode(E), table='rating')
        return {'error': unicode(E)}
Exemplo n.º 11
0
def deleteRiskResponse(uuid):
    entry = getRiskResponse(uuid)
    if entry.treatments:
        return {'error': 'Risk Response cannot be deleted as long as there are Treatments assigned this Risk Response'}
    try:
        db.session.delete(entry)
        db.session.commit()
        deleteLog(table='riskResponse', uuid=unicode(uuid))
        return {'success': 'Risk Response deleted'}
    except Exception as E:
        errorLog(unicode(E), table='riskResponse')
        return {'error': unicode(E)}
Exemplo n.º 12
0
def deleteRegion(uuid):
    row = getRegion(uuid)
    if not row.subRegions:
        try:
            db.session.delete(row)
            db.session.commit()
            deleteLog(table='region', uuid=unicode(uuid))
            return {'success': 'Region deleted'}
        except Exception as E:
            errorLog(unicode(E), table='region')
            return {'error': unicode(E)}
    else:
        errorLog('Delete attempt without removing Sub Regions', table='region')
        return {'error': 'You must first remove Sub Regions from Region'}
Exemplo n.º 13
0
def deleteCausingFactorType(uuid):
    entry = getCausingFactorType(uuid)
    if not entry.causingFactors:
        try:
            db.session.delete(entry)
            db.session.commit()
            deleteLog(table='causingFactor', uuid=unicode(uuid))
            return {'success': 'Causing Factor Type deleted'}
        except Exception as E:
            errorLog(unicode(E), table='causingFactor')
            return {'error': unicode(E)}
    else:
        return {
            'error':
            'Cannot be deleted as there are Causing Factors assigned this Type'
        }
Exemplo n.º 14
0
def deleteValueChainArea(uuid):
    entry = getValueChainArea(uuid)
    if entry.valueChains:
        errorLog('Delete attempt without removing Value Chains',
                 table='valueChainArea')
        return {
            'error':
            'Value Chain Area cannot be deleted as long as there are Value Chains assigned this Value Chain Area'
        }
    try:
        db.session.delete(entry)
        db.session.commit()
        deleteLog(table='valueChainArea', uuid=unicode(uuid))
        return {'success': 'Value Chain Area deleted'}
    except Exception as E:
        errorLog(unicode(E), table='valueChainArea')
        return {'error': unicode(E)}
Exemplo n.º 15
0
def deleteTreatment(uuid):
    row = getTreatment(uuid)
    try:
        req = deleteLog(table='treatment', uuid=unicode(uuid))
        db.session.delete(row)
        db.session.commit()
        return {'success': 'Treatment deleted'}
    except Exception as E:
        errorLog(unicode(E), table='treatment')
        return {'error': unicode(E)}
Exemplo n.º 16
0
def deleteUser(uuid):
    try:
        usr = getUser(uuid)
        req = authAPI(endpoint='user/'+unicode(uuid), method='delete', token=session['token'])
        if 'success' in req:
            try:
                db.session.delete(usr)
                db.session.commit()
                deleteLog(table='user', uuid=unicode(uuid))
                return {'success': 'User has been activated'}
            except Exception as E:
                errorLog(unicode(E), table='user')
                return {'error':unicode(E)}
        else:
            errorLog(req['error'], table='user')
            return {'error':req['error']}
    except Exception as E:
        errorLog(unicode(E), table='user')
        return {'error':unicode(E)}
Exemplo n.º 17
0
def deleteGroup(uuid):
    try:
        req = authAPI(endpoint='group/' + unicode(uuid),
                      method='delete',
                      token=session['token'])
        if 'error' in req:
            return {'error': req['error']}
        else:
            try:
                grp = getGroup(uuid)
                db.session.delete(grp)
                db.session.commit()
                deleteLog(table='group', uuid=unicode(uuid))
                return {'success': 'Group has been deleted'}
            except Exception as E:
                errorLog(unicode(E), table='group')
                return {'error': unicode(E)}

    except Exception as E:
        errorLog(unicode(E), table='group')
        return {'error': unicode(E)}