Esempio n. 1
0
def connect(front_end_id, user_id):
    print('Skapar connection')
    print(current_user.id)
    exhibitor = Exhibitor.get_exhibitor(session, current_user.id)
    attendant = Attendant.get_user_multi(session, front_end_id, user_id)
    if attendant:
        if exhibitor.got_connection(session, attendant.get_id(session)):
            connection = Connection.get_connection_by_users(session, exhibitor.get_id(), attendant.get_id(session))
            data = connection.get_data(session)
            labels = get_all_labels(session)
            connection_info = {'connections':data, 'labels':labels}
            session.expunge_all()
            session.close()
            return json.dumps(connection_info)
        else:
            connection = Connection(exhibitor.get_id(), attendant.get_id(session))
            session.add(connection)
            session.commit()
            connection_data = connection.get_data(session)
            session.expunge_all()
            labels = get_all_labels(session)
            session.close()
            connection_info = {'connections':connection_data, 'labels':labels}
            return json.dumps(connection_info)
    else:
        session.close()
        return json.dumps(False)
Esempio n. 2
0
def connect_by_frontend_id(front_end_id):
    attendants = Attendant.get_from_front_id(session, front_end_id)
    session.expunge_all()
    session.close()
    if len(attendants) == 0:
        return json.dumps(False)
    else:
        return json.dumps(attendants)
Esempio n. 3
0
def thanks(front_end_id, user_id):
    createSession()
    attendant = Attendant.get_user_multi(session, front_end_id, user_id)
    session.expunge_all()
    session.close()
    if attendant:
        return render_template('tack.html', name=attendant.first_name, qrUrl=attendant.qr, front_end_id=attendant.front_end_id)
    else:
        return abort(404)
Esempio n. 4
0
def check_email():
    createSession()
    email = request.form['mejl']
    email = json.loads(email)
    response = {}
    response['email'] = Attendant.is_attending(session, email)
    session.expunge_all()
    session.close()
    return json.dumps(response)
Esempio n. 5
0
def create_attendant():
    createSession()
    created, returned_data = create_new_attendant()
    session.expunge_all()
    session.close()
    if created:
        return json.dumps({'attend':'True', 'url':'/thanks/'+str(returned_data['front_end_id'])+'/'+str(returned_data['id'])})
    else:
        return json.dumps({'attend':'False','errors':returned_data})
Esempio n. 6
0
def get_exhibitor_contacts():
    connections = Connection.get_all_connections(session, current_user.id)
    connection_data = []
    for connection in connections:
        connection_data.append(connection.get_data(session))
    labels = get_all_labels(session)
    labels = {'connections':connection_data, 'labels':labels}
    session.expunge_all()
    session.close()
    return json.dumps(labels)
Esempio n. 7
0
 def wrapper(self, *args, **kwargs):
     session = self.Session()
     try:
         result = f(self, session, *args, **kwargs)
         return result
     except IntegrityError:
         session.rollback()
         raise Exception("Error")
     finally:
         session.expunge_all()
         session.close()    
Esempio n. 8
0
def session_scope():
    """Provide a transactional scope around a series of operations."""
    session = Session()
    session.expire_on_commit = False
    try:
        yield session
        session.commit()
    except:
        print('LS: Roll back.')
        session.rollback()
        raise
    finally:
        print('LS: Expunge all and close')
        session.expunge_all()
        session.close()
Esempio n. 9
0
def log_in_user():
    ''' Call log_in user and return True or False if logged in or not '''
    createSession()
    email = request.form.get('username')
    user_psw = request.form.get('password')
    hashed = User.hash_password(user_psw)
    user = User.get_user(session, email)
    if user:
        if user.get_password() == hashed:
            key = user.generate_key(session)
            user_id = user.id
            session.expunge_all()
            session.close()
            return json.dumps({'logged_in':True, 'id':user_id, 'key':key })
        else:
            session.close()
            return json.dumps({'logged_in':False})
    else:
        session.close()
        return json.dumps({'logged_in':False})
Esempio n. 10
0
def save_to_excel():
    exhibitor = Exhibitor.get_exhibitor(session, current_user.id)
    excel_file = exhibitor.create_excel(session)
    session.expunge_all()
    session.close()
    return send_file('excel/kontaktuppgifter' + str(current_user.id) + '.xlsx', as_attachment=True, attachment_filename='kontaktuppgifter.xlsx')
Esempio n. 11
0
def qr():
    exhibitor = Exhibitor.get_exhibitor(session, current_user.id)
    labels = exhibitor.get_labels(session)
    session.expunge_all()
    session.close()
    return render_template("Web QR.html", labels = labels)
Esempio n. 12
0
def admin():
    exhibitor = Exhibitor.get_exhibitor(session, current_user.id)
    labels = exhibitor.get_labels(session)
    session.expunge_all()
    session.close()
    return render_template("utstallare_inloggad.html", lables = labels)