def test_set_user_preferences_from_request(request_post, user): set_user_preferences_from_request( request_post('/', data={_PREF_POST_KEY: 'aaa%sqqq' % _ALIAS_SEP}, user=user)) subs = Subscription.objects.all() assert len(subs) == 0 set_user_preferences_from_request( request_post('/', data={_PREF_POST_KEY: 'test_message%stest_messenger' % _ALIAS_SEP}, user=user)) subs = Subscription.objects.all() assert len(subs) == 1
def update_context(self, context, request): if request.POST: prefs_were_set = set_user_preferences_from_request(request) if prefs_were_set: raise RedirectRequired() subscr_prefs = get_user_preferences_for_ui(request.user, new_messengers_titles={ 'twitter': '<i class="fi-social-twitter" title="Twitter"></i>', 'smtp': '<i class="fi-mail" title="Эл. почта"></i>' }) context['subscr_prefs'] = subscr_prefs
def update_context(self, context, request): if request.POST: prefs_were_set = set_user_preferences_from_request(request) if prefs_were_set: raise RedirectRequired() subscr_prefs = get_user_preferences_for_ui(request.user, new_messengers_titles={ 'twitter': '<i class="fi-social-twitter" title="Twitter"></i>', 'smtp': '<i class="fi-mail" title="Эл. почта"></i>' }) context['subscr_prefs'] = subscr_prefs