Example #1
0
    def test_update_user_preference(self):
        """ Can we add a new UserPreference to database? """

        with self.client as c:
            with c.session_transaction() as session:
                session['username'] = '******'
        print session.get("username")
        preference = 'pa-stranded'
        include = 1
        update_user_preference(preference, include)
        new_pref = UserPreference.query.filter(
            UserPreference.user_id == 1, UserPreference.pref_id == 26).one()
        self.assertIsNotNone(new_pref)
    def test_update_user_preference(self):
        """ Can we add a new UserPreference to database? """

        with self.client as c:
            with c.session_transaction() as session:
                session['username'] = '******'
        print session.get("username")
        preference = 'pa-stranded'
        include = 1
        update_user_preference(preference, include)
        new_pref = UserPreference.query.filter(
            UserPreference.user_id == 1,
            UserPreference.pref_id == 26).one()
        self.assertIsNotNone(new_pref)
Example #3
0
def update_preference_in_db():
    """Process form field in user profile to update preferences.

    calls update_user_preference to update database based on checkbox clicked.
    Include is 0 if checkbox empty, and 1 if checked.
    Preference sent to function is html ID, which is in format
    'pref_category-pref_value'. """

    preference = request.form.get("preference")
    include = int(request.form.get("include"))

    # update the db to reflect the change in user preference
    update_user_preference(preference, include)

    display_id = preference + "-display"

    return display_id