コード例 #1
0
ファイル: views.py プロジェクト: MaxDumont/zamboni
def account_settings(request):
    ctx = {}

    # Don't use `request.amo_user` because it's too cached.
    user = request.user
    if user.is_authenticated():
        amo_user = user.get_profile()
        form = forms.UserEditForm(request.POST or None, instance=amo_user)
        if request.method == 'POST':
            if form.is_valid():
                form.save()
                messages.success(request, _('Settings Updated.'))
                amo.log(amo.LOG.USER_EDITED)
                response = redirect('account.settings')
                # TODO: Detect when we're changing the user's locale and region
                # and bust on '/', bust on '/settings' for everything else.
                bust_fragments(response, '/')
                return response
            else:
                messages.form_errors(request)
        ctx = {'form': form, 'amouser': amo_user}
    else:
        if request.method == 'POST':
            messages.success(request, _('Settings Updated.'))

    return jingo.render(request, 'account/settings.html', ctx)
コード例 #2
0
def account_settings(request):
    ctx = {}

    # Don't use `request.amo_user` because it's too cached.
    user = request.user
    if user.is_authenticated():
        amo_user = user.get_profile()
        form = forms.UserEditForm(request.POST or None, instance=amo_user)
        if request.method == 'POST':
            if form.is_valid():
                form.save()
                messages.success(request, _('Settings Updated.'))
                amo.log(amo.LOG.USER_EDITED)
                response = redirect('account.settings')
                # TODO: Detect when we're changing the user's locale and region
                # and bust on '/', bust on '/settings' for everything else.
                bust_fragments(response, '/')
                return response
            else:
                messages.form_errors(request)
        ctx = {'form': form, 'amouser': amo_user}
    else:
        if request.method == 'POST':
            messages.success(request, _('Settings Updated.'))

    return jingo.render(request, 'account/settings.html', ctx)
コード例 #3
0
def account_settings(request):
    ctx = {}

    # Don't use `request.amo_user` because it's too cached.
    user = request.user
    if user.is_authenticated():
        amo_user = user.get_profile()
        if request.method == 'POST':
            if 'authorized_apps' in request.POST:
                ids = request.POST.getlist('authorized_apps')
                Token.objects.filter(pk__in=ids).delete()
                form = forms.UserEditForm(None, instance=amo_user)
            else:
                form = forms.UserEditForm(request.POST, instance=amo_user)
                if form.is_valid():
                    form.save()
                    messages.success(request, _('Settings Updated.'))
                    amo.log(amo.LOG.USER_EDITED)
                    response = redirect('account.settings')
                    # TODO: Detect when we're changing the user's
                    # locale and region and bust on '/', bust on
                    # '/settings' for everything else.
                    bust_fragments(response, '/')
                    return response
                else:
                    messages.form_errors(request)
        else:
            form = forms.UserEditForm(None, instance=amo_user)
        tokens = Token.objects.filter(user=user, token_type=ACCESS_TOKEN)
        ctx = {'form': form, 'amouser': amo_user, 'tokens': tokens}
    else:
        if request.method == 'POST':
            messages.success(request, _('Settings Updated.'))

    return jingo.render(request, 'account/settings.html', ctx)
コード例 #4
0
ファイル: views.py プロジェクト: lauraxt/zamboni
def account_settings(request):
    # Don't use `request.amo_user` because it's too cached.
    amo_user = request.amo_user.user.get_profile()
    form = forms.UserEditForm(request.POST or None, instance=amo_user)
    if request.method == 'POST':
        if form.is_valid():
            form.save()
            messages.success(request, _('Profile Updated'))
            amo.log(amo.LOG.USER_EDITED)
            return redirect('account.settings')
        else:
            messages.form_errors(request)
    return jingo.render(request, 'account/settings.html',
                        {'form': form, 'amouser': amo_user})
コード例 #5
0
ファイル: views.py プロジェクト: vdt/zamboni
def account_settings(request):
    # Don't use `request.amo_user` because it's too cached.
    amo_user = request.amo_user.user.get_profile()
    form = forms.UserEditForm(request.POST or None, request.FILES or None,
                              request=request, instance=amo_user)
    if request.method == 'POST':
        if form.is_valid():
            form.save()
            messages.success(request, _('Profile Updated'))
            amo.log(amo.LOG.USER_EDITED)
            return redirect('account.settings')
        else:
            messages.form_errors(request)
    return jingo.render(request, 'account/settings.html',
                        {'form': form, 'amouser': amo_user})