Exemplo n.º 1
0
def set_widget_columns(request):
    """Set the number of columns on the webfront"""
    if request.method == 'POST':
        form = ColumnsForm(request.POST)
        if form.is_valid():
            account = request.account
            num_columns = form.cleaned_data.get('num_columns')
            account.preferences[account.PREFERENCE_KEY_WIDGET_COLUMNS] = num_columns
            account.save()
            return HttpResponseRedirect(reverse('webfront-index'))
    return HttpResponseRedirect(reverse('webfront-preferences'))
Exemplo n.º 2
0
def _create_preference_context(request):
    """
    Creates a context used by different views for the multiform preference page
    """
    account = get_account(request)

    if account.ext_sync:
        password_form = None
    else:
        password_form = ChangePasswordForm()

    context = {
        'navpath': [('Home', '/'), ('Preferences', None)],
        'title':
        'Personal NAV preferences',
        'password_form':
        password_form,
        'columns_form':
        ColumnsForm(initial={'num_columns': get_widget_columns(account)}),
        'account':
        account,
        'tool': {
            'name': 'My account',
            'description': 'Edit my personal NAV account settings'
        },
        'navbar_formset':
        NavbarLinkFormSet(queryset=NavbarLink.objects.filter(account=account)),
    }

    return context