def Pin(): if 'username' in session: system = System() pins = system.pins() login_user = system.getUser(session.get('username')) error = None if request.method == "POST": email = session.get('username') response = User(email).createPins() if type(response) is int: error = 'Error ' + str(response) pins = system.pins() return render_template('pin.html', login_user=login_user, error=error, pins=pins) else: error = response pins = system.pins() return render_template('pin.html', login_user=login_user, error=error, pins=pins) return render_template('pin.html', login_user=login_user, error=error, pins=pins) return redirect(url_for("Index"))
def Pin(): if session.get('username'): system = System() pins = system.pins() login_user = system.getUser(session.get('username')) error = None if request.method == "POST": email = session.get('username') response = User(email).createPins() if type(response) is int: error = 'Error ' + str(response) return render_template('pin.html', login_user=login_user, error=error, pins=pins) else: error = response return render_template('pin.html', login_user=login_user, error=error, pins=pins) return render_template('pin.html', login_user=login_user, error=error, pins=pins) return redirect(url_for("Index"))
def Did(): if session.get('username'): system = System() login_user = system.getUser(session.get('username')) pins = system.pins() countries = system.countries() dids = system.dids() error = None if request.method == 'POST': file = request.files['did_file'] if not file: phone = request.form['phone'] cost = request.form['cost'] country = request.form['country'] capacity = request.form['capacity'] provider = request.form['provider'] mode = request.form['mode'] pin = request.form['pin'] if len(phone) < 1: abort(400, 'The phone number is invalid') elif len(cost) < 1: abort(400,'Invalid cost specified') elif len(country) < 1: abort(400, 'Invalid country code') elif len(capacity) < 1: abort(400, 'Please select capacity') elif len(provider) < 1: abort(400, 'Please select provider') elif len(mode) < 1: abort(400, 'Please select mode') elif len(pin) < 1: abort(400, 'Please select pin') email = session.get('username') response = User(email).createDid(phone,provider,cost,country,capacity,mode,pin) if response == 0: flash('DID Successfully created') error = 'DID Successfully created with pin '+pin return render_template('did.html', login_user=login_user, error=error, dids=dids, pins=pins, countries=countries) elif response == 1: abort(400, 'DID %s already exist'%(phone)) else: abort(400, 'DID is not created') if System().allowed_file(file.filename): filename = secure_filename(file.filename) try: file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) fileUrl = os.path.abspath(app.config['UPLOAD_FOLDER']+filename) #fileUrl = path(app.config['UPLOAD_FOLDER']+filename).abspath() error = 'File uploaded : Path -> ' + fileUrl data_list_dids = System().readCSV(fileUrl) insert_dids = System().insertDids(data_list_dids) error = str(insert_dids) + ' DIDs has been uploaded and saved' except: error = 'File not uploaded Successfully' else: error = 'File format is not allowed' return render_template('did.html', login_user=login_user, error=error, did_file=file, dids=dids,pins=pins,countries=countries) return render_template('did.html', login_user=login_user, error=error, pins=pins, dids=dids,countries=countries) return redirect(url_for("Index"))
def Did(): if session.get('username'): system = System() login_user = system.getUser(session.get('username')) pins = system.pins() countries = system.countries() dids = system.dids() error = None if request.method == 'POST': file = request.files['did_file'] if not file: phone = request.form['phone'] cost = request.form['cost'] country = request.form['country'] capacity = request.form['capacity'] provider = request.form['provider'] mode = request.form['mode'] pin = request.form['pin'] if len(phone) < 1: abort(400, 'The phone number is invalid') elif len(cost) < 1: abort(400, 'Invalid cost specified') elif len(country) < 1: abort(400, 'Invalid country code') elif len(capacity) < 1: abort(400, 'Please select capacity') elif len(provider) < 1: abort(400, 'Please select provider') elif len(mode) < 1: abort(400, 'Please select mode') elif len(pin) < 1: abort(400, 'Please select pin') email = session.get('username') response = User(email).createDid(phone, provider, cost, country, capacity, mode, pin) if response == 0: flash('DID Successfully created') error = 'DID Successfully created with pin ' + pin return render_template('did.html', login_user=login_user, error=error, dids=dids, pins=pins, countries=countries) elif response == 1: abort(400, 'DID %s already exist' % (phone)) else: abort(400, 'DID is not created') if System().allowed_file(file.filename): filename = secure_filename(file.filename) try: file.save( os.path.join(app.config['UPLOAD_FOLDER'], filename)) fileUrl = os.path.abspath(app.config['UPLOAD_FOLDER'] + filename) #fileUrl = path(app.config['UPLOAD_FOLDER']+filename).abspath() error = 'File uploaded : Path -> ' + fileUrl data_list_dids = System().readCSV(fileUrl) insert_dids = System().insertDids(data_list_dids) error = str( insert_dids) + ' DIDs has been uploaded and saved' except: error = 'File not uploaded Successfully' else: error = 'File format is not allowed' return render_template('did.html', login_user=login_user, error=error, did_file=file, dids=dids, pins=pins, countries=countries) return render_template('did.html', login_user=login_user, error=error, pins=pins, dids=dids, countries=countries) return redirect(url_for("Index"))