Beispiel #1
0
def update_account_data():

    utils.utils().updateUserInfo(request.args.get('organization'), request.args.get('username'), \
                                 request.args.get('mail'), request.args.get('first_name'), \
                                 request.args.get('last_name'), request.args.get('city'), \
                                 request.args.get('country'))
    return redirect(url_for('show_account_info'))
Beispiel #2
0
def launch_campaign():
    print('launch campaign')
    print(request.args)
    utils.utils().writeCampaignInfo(request.args.get('organization'), request.args.get('username'), \
                                 request.args.get('mail'), request.args.get('geography'), \
                                 request.args.get('collaborators'), request.args.get('description'),request.args.get('campaign_identifier'))
    print('Message array: ' + str(request.args.getlist('message_array[0][]')))
    messaging_handler.messaging_handler().sendOutMessages(
        request.args.getlist('message_array[0][]'),
        request.args.get('campaign_identifier'))
    print('here')
    return redirect(url_for('show_success'))
Beispiel #3
0
def login():
    if flask_login.current_user.is_authenticated:
        return redirect(url_for('show_main'))
    # Here we use a class of some kind to represent and validate our
    # client-side form data. For example, WTForms is a library that will
    # handle this for us, and we use a custom LoginForm to validate.
    form = Forms.LoginForm(request.form)
    print(form)
    print(form.validate())

    if form.validate():
        # Login and validate the user.
        # user should be an instance of your `User` class
        myutils = utils.utils()
        username = str(form.username.data).split(',')[0]
        password = str(form.password.data).split(',')[0]

        if myutils.check_password(username, password):

            print('Login initiated')
            print(flask_login.login_user(User.User(username)))
            print('Login done')
            if str(request.referrer).split("=%2F").__len__() >= 2:
                next = '/' + str(request.referrer).split("=%2F")[1]
            else:
                next = None
            print('Next read')
            print(next)
            print(request)
            print('Current user: '******'identifylocalinfluencers.com'}):
            #    return abort(400)
            if next == None:
                return redirect(url_for('show_main'))
            return redirect(next)
        else:
            render_template('login.html',
                            form=form,
                            success_label="False username or password")
    return render_template('login.html', form=form)
Beispiel #4
0
def getFileFiltered():
    print('Called getFileFiltered')
    filter_keys = ['from_', 'from_city', 'campaign_identifier', 'voted_for']
    restriction_dict = {}
    for key in filter_keys:
        restriction_dict[key] = request.args.get(key)
    data_list = utils.utils().getSelectedDataIncoming(restriction_dict)
    f = open("campaign_results.csv", "w")
    f.write("a")
    f.close()
    os.chmod("campaign_results.csv", 0o777)
    with open('campaign_results.csv', 'w', newline='') as csvfile:
        csv_writer = csv.writer(csvfile,
                                delimiter=' ',
                                quotechar='|',
                                quoting=csv.QUOTE_MINIMAL)
        for row in data_list:
            csv_writer.writerow(row)
            print('current row: ' + str(row))

    f = open("campaign_results.csv", "r")
    return_string = f.read()
    return return_string
Beispiel #5
0
def load_user(user_id):
    print('User id to load: ' + str(user_id))
    myutils = utils.utils()
    user_data = myutils.readFromUserDB(user_id)
    user = User.User(user_data['username'])
    return user
Beispiel #6
0
def get_account_data():
    return utils.utils().getUserInfo(flask_login.current_user.get_id())
Beispiel #7
0
def getFilteredResultsTimeseries():
    filter_keys = ['from_', 'from_city', 'campaign_identifier', 'voted_for']
    restriction_dict = {}
    for key in filter_keys:
        restriction_dict[key] = request.args.get(key)
    return utils.utils().filteredTimeSeriesData(restriction_dict)
Beispiel #8
0
def get_filtered_incoming_message_data():
    filter_keys = ['from_', 'from_city', 'campaign_identifier', 'voted_for']
    restriction_dict = {}
    for key in filter_keys:
        restriction_dict[key] = request.args.get(key)
    return jsonify(utils.utils().getSelectedDataIncoming(restriction_dict))
Beispiel #9
0
def get_filters():
    return utils.utils().fillFilters()