Пример #1
0
def login():
    # fetch user information from database
    user = db.child('users').child(g.user['localId']).get().val()
    # fetch user points from database
    userPoints = db.child('points').child(g.user['localId']).get().val()
    # load the dashboard with the user information
    return render_template('/dashboard.html', user=user, points=userPoints)
Пример #2
0
 def admin():
     users = get_all_users()
     user = db.child('users').child(g.user['localId']).get().val()
     budget = db.child('budget').get().val()
     return render_template('admin.html',
                            users=users,
                            uid=g.user['localId'],
                            user=user,
                            budget=budget)
Пример #3
0
def editPoints():
    if request.method == 'POST':
        # create new points object with the new values
        points = {
            'fall': request.form['fallPoints'],
            'winter': request.form['winterPoints'],
            'spring': request.form['springPoints']
        }
        #  get the current user
        user = session.get("user")
        # set the current user's points in the database
        db.child("points").child(user["localId"]).set(points)
        return redirect(url_for('dashboard'))  # return to dashboard
    return redirect(url_for('points'))
Пример #4
0
def settings():
    if request.method == 'POST':
        data = {
            "first_name": request.form['first_name'],
            "last_name": request.form['last_name'],
            "email": request.form['email'],
            "major": request.form['major'],
            "year": request.form['year']
        }
        db.child("users").child(g.user['localId']).update(data)

    user_data = db.child("users").child(g.user['localId']).get().val()
    data = requests.get(
        'https://us-central1-shpe-uci-tech.cloudfunctions.net/majors').text
    return render_template('/settings.html', user=user_data, data=data)
Пример #5
0
def login():
    if request.method == 'POST':
        email = request.form['email']
        password = request.form['password']

        error = None

        try:
            user = auth.sign_in_with_email_and_password(email, password)
        except requests.exceptions.HTTPError as e:
            error = json.loads(e.args[1])['error']['message']
            print(error)
            flash("Invalid Credentials")

        if error is None:
            session.clear()
            session['user'] = user
            session['name'] = db.child('users').child(
                user['localId']).get().val()
            return redirect(url_for('dashboard'))
    if request.method == 'GET':
        if g.user is not None:
            return redirect(url_for('dashboard'))

    return render_template('/auth/login.html')
Пример #6
0
 def search():
     users = get_all_users()
     user = db.child('users').child(g.user['localId']).get().val()
     #for user in users:
     #     print(user)
     print(user)
     return render_template('search.html', users=users, user=user)
Пример #7
0
 def portfolio(ucinet):
     #print(f"Retrieving Data for {ucinet}")
     userInfo = get_user(ucinet)
     user = db.child('users').child(g.user['localId']).get().val()
     #print(userInfo)
     if userInfo == None:
         return page_not_found("User not found")
     return render_template('portfolio.html', userdata=userInfo, user=user)
Пример #8
0
def get_user(username: str) -> FBUser:
    users_dict = db.child('users').get().val()
    fb_user = None
    for uid in users_dict:
        if (users_dict[uid]['email'] == username + "@uci.edu"):
            user_info = users_dict[uid]
            fb_user = FBUser(uid, user_info)
    return fb_user
Пример #9
0
def get_all_users() -> [dict]:
    users_dict = db.child('users').get().val()
    users = []

    for uid in users_dict:
        user_info = users_dict[uid]
        fb_user = FBUser(uid, user_info)
        user_dict = fb_user.get_dict()
        users.append(user_dict)
        # users.append(fb_user)

    return users
def get_file_in_google_drive(google_api_call, file_to_upload):
    # puts a file in google drive only not specific folder
    print("made it to get_file_in_google_drive function")
    user_data = db.child("users").child(g.user['localId']).get().val()
    print(user_data)
    if user_data[
            'resume_id'] != '':  #checks to see if a user has a resume already in database
        print("file being updated")
        update_file(google_api_call, file_to_upload, user_data['resume_id'])
    else:
        print("new file created")
        use_as_filename = user_data['last_name'] + '_' + user_data['first_name']
        file_metadata = {
            'name': use_as_filename,  #this name appears on google drive
            'parents':
            ""  #put google folder ID inside of quotes to get file in that folder
        }
        media = MediaFileUpload(file_to_upload)
        file_to_google_drive = google_api_call.files().create(
            body=file_metadata, media_body=media, fields="id").execute()
        print(file_to_google_drive['id'])
        db.child("users").child(g.user["localId"]).update(
            {"resume_id": file_to_google_drive['id']})
Пример #11
0
    def dashboard():
        user = db.child('users').child(g.user['localId']).get().val()
        print(user)
        if request.method == "POST":
            user_file = request.files['pdf_uploader']
            if not allowed_file(user_file):  #checks if file is pdf
                return redirect(request.url)
            else:
                secure_file = secure_filename(
                    user_file.filename)  # holds pdf file from form
                user_file.save(os.path.join(
                    PATH_TO_UPLOAD,
                    secure_file))  # create variable here path to new pdf
                myfilepath = os.path.join(
                    PATH_TO_UPLOAD,
                    secure_file)  #hold file path for google drive
                google_drive_auth(myfilepath)
                delete_file(myfilepath)

            return redirect(
                request.url)  #returns url and looks for request object
        # if method is GET then render template
        return render_template("dashboard.html", user=user)
Пример #12
0
 def points():
     userPoints = userPoints = db.child(
         'points').child(g.user['localId']).get().val()
     return render_template('points.html', points=userPoints)
Пример #13
0
def register():
    data = requests.get(
        'https://us-central1-shpe-uci-tech.cloudfunctions.net/majors').text
    #print(data)
    if request.method == 'POST':
        email = request.form['email']
        password = request.form['password']
        recaptcha_response = request.form['g-recaptcha-response']

        error = None

        if verify_recaptcha_token(recaptcha_response):
            print("valid recaptcha")
        else:
            error = "Invalid Recaptcha"
            print("invalid recaptcha")

        if not email:
            error = 'Email is required.'
        elif not password:
            error = 'Password is required.'

        if error is None:
            try:
                user = auth.create_user_with_email_and_password(
                    email, password)
            except requests.exceptions.HTTPError as e:
                error = json.loads(e.args[1])['error']['message']
                if error == "EMAIL_EXISTS":
                    flash("Email already in use. Please Sign In.")
                else:
                    flash(error)

        if error is None:
            points = {"fall": 0, "winter": 0, "spring": 0}

            data = {
                "first_name": request.form['first_name'],
                "last_name": request.form['last_name'],
                "email": email,
                "major": request.form['major'],
                "year": request.form['year'],
                "resume_id": ""
            }

            user = auth.sign_in_with_email_and_password(email, password)

            db.child("users").child(user["localId"]).set(data)

            db.child("points").child(user["localId"]).set(points)

            session.clear()
            session['user'] = user
            session['name'] = db.child('users').child(
                user['localId']).get().val()
            return redirect(url_for('dashboard'))
        else:
            flash(error)

    if g.user is not None:
        return redirect(url_for('dashboard'))
    return render_template('/auth/register.html', data=data)
Пример #14
0
def getAllQuestions():
    if request.method == 'GET':
        return db.child('questions').get().val()
Пример #15
0
def faq():
    user = db.child('users').child(g.user['localId']).get().val()
    if request.method == 'GET':
        questions = getAllQuestions()
        return render_template('faq/faq.html', questions=questions, user=user)
Пример #16
0
 def settings():
     user = db.child('users').child(g.user['localId']).get().val()
     return render_template('settings.html', user=user)