def edit_settings(request): """Edit user settings.""" user = request.user form = forms.EditSettingsForm(request.POST or None, instance=user.userprofile) if request.method == 'POST' and form.is_valid(): form.save() messages.success(request, 'Settings successfully edited.') return redirect('dashboard') return render(request, 'settings.html', { 'user': user, 'settingsform': form })
def edit_settings(request): """Edit user settings.""" user = request.user if user.groups.filter(name='Mozillians').exists(): raise Http404 form = forms.EditSettingsForm(request.POST or None, instance=user.userprofile) if request.method == 'POST' and form.is_valid(): form.save() for field in form.changed_data: statsd.incr('base.edit_setting_%s' % field) messages.success(request, 'Settings successfully edited.') return redirect('dashboard') return render(request, 'settings.html', {'user': user, 'settingsform': form})