Esempio n. 1
0
def profile(user_id):
    """ 
    Show profile page, check for likes by the user and display them.
    """

    if 'user' in session:
        login_user = users_collection.find_one({'username': session['user']})
        departments = Search(departments_collection).find_all()
        facility = Search(facilities_collection).find_all()

        try:
            id_deptlikes = users_collection.find({'username': session['user']})

            list_deptlikes = []
            likes = [i['likes'] for i in id_deptlikes]

            for like in likes[0]:
                list_deptlikes.append({"_id": ObjectId(like)})

            favourites = [
                i for i in departments_collection.find({"$or": list_deptlikes})
            ]

        except:
            flash(
                'There are no favourites in your profile yet, %s' %
                session['user'], 'alert-warning')

        else:
            return render_template('profile.html',
                                   page_title="Profile Page",
                                   login_user=login_user,
                                   user_id=login_user['_id'],
                                   favourites=favourites,
                                   facility=facility,
                                   departments=departments)

    return render_template('profile.html',
                           page_title='Profile',
                           login_user=login_user,
                           user_id=user_id,
                           facility=facility,
                           departments=departments)
Esempio n. 2
0
def add_appointment(user_id):
    if 'user' in session:
        login_user = users_collection.find_one({"username": session['user']})
        facility = Search(facilities_collection).find_all()
        departments = Search(departments_collection).find_all()

        return render_template("add_appointment.html",
                               page_title='Add Appointments',
                               facility=facility,
                               departments=departments,
                               username=session['user'],
                               user_id=login_user['_id'])
    else:
        facility = Search(facilities_collection).find_all()
        departments = Search(departments_collection).find_all()

    return render_template("add_appointment.html",
                           page_title='Add Appointments',
                           facility=facility,
                           departments=departments)
Esempio n. 3
0
def get_appointment(user_id):
    """ 
    Search for scheduled appointments - no filters.
    """

    if 'user' in session:
        login_user = users_collection.find_one({"username": session['user']})
        appointment = Search(appointments_collection).find_all()

        return render_template('appointment.html',
                               page_title='Appointments',
                               appointment=appointment,
                               username=session['user'],
                               user_id=login_user['_id'])
    else:
        appointment = Search(appointments_collection).find_all()

    return render_template('appointment.html',
                           page_title='Appointments',
                           appointment=appointment)
Esempio n. 4
0
def get_departments(user_id):
    """ 
    Lets us return the names of all the departments
    """
    if 'user' in session:
        login_user = users_collection.find_one({"username": session['user']})
        departments = Search(departments_collection).find_all()
        return render_template('get_departments.html',
                               page_title='Departments',
                               departments=departments,
                               username=session['user'],
                               user_id=login_user['_id'])

    return render_template('login.html', page_title='Log-in')