Exemple #1
0
def delete():
    #
    #
    logger.debug(('FUNC::::::: app.route.delete         {0}').format(request.method))
    if request.method == 'POST':
        logger.debug(request.form['submit'])
        sub = request.form['submit']
        cSub = ims.registeredSubscriber(sub) # For a delete any Class Type can work

        result = cSub.subscriberDelete(session)

        if result.status_code == 500: #Successful EMA connection but there is an error.
            if result.text.find('Invalid Session'):
                logger.debug('********Invalid Session')
                return redirect(url_for('auth.login', error='Invalid Session : Please login again.'))
            elif result.text.find('No such object'):
                logger.debug('******** No Such object')
                return redirect(url_for('main.searchRangeR'))
            else:
                pass
        elif result.status_code == 200:
            logger.debug('** Leaving FUNC::::::: app.route.delete')
            session['mesg'] = 'Deleted'
            return redirect(url_for('main.subscribers'))
    else: #GET Method
        logger.debug('** Leaving FUNC::::::: app.route.delete')
        return render_template('searchRangeR.html', deletemesg = "True")
    return
Exemple #2
0
def createR(sub):
    logger.debug(('FUNC:::::: app.route.createR           {0}').format(request.method))
    c_sub = ims.registeredSubscriber(sub)# Create Registered Subscriber Class instance
    result = c_sub.subscriberCreate(session)
   
    if result.status_code == 500: #Successful EMA connection but there is an error.
        if result.text.find('Invalid Session') != -1:
            logger.debug(('** Leaving FUNC:::: app.route.createR:  Invalid Session'))
            return redirect(url_for('auth.login', error='Invalid Session'))
        elif result.text.find('already exists') != -1: # -1 means does not exist, therefore if True it exists.
            logger.debug(('** Leaving FUNC:::: app.route.createR:  Subscriber Already Exists'))
            session['mesg'] = 'ExistingSubscriber'
            return redirect(url_for('main.subscribers'))
        else:
            logger.debug('Unknown Error in createR func')
            pass
    if result.status_code == 200:
        session['mesg'] = 'Created'
        session['sub'] = sub
        del c_sub # Remove Subscriber Class instance
    
    logger.debug('** Leaving FUNC::::::: app.route.createR')
    return redirect(url_for('main.subscribers'))