@secure_required
@permission_required_or_403('change_user', (get_user_model(), 'username', 'username'))
def email_change(request, username, email_form=ChangeEmailForm, template_name='userena/email_form.html', success_url=None, extra_context=None):
 user = get_object_or_404(get_user_model(), username__iexact=username)
 prev_email = user.email
 form = email_form(user)
 if (request.method == 'POST'):
  form = email_form(user, request.POST, request.FILES)
  if form.is_valid():
   form.save()
   if success_url:
    userena_signals.email_change.send(sender=None, user=user, prev_email=prev_email, new_email=user.email)
    redirect_to = success_url
   else:
    redirect_to = reverse('userena_email_change_complete', kwargs={'username': user.username})
   return redirect(redirect_to)
 if (not extra_context):
  extra_context = dict()
 extra_context['form'] = form
 extra_context['profile'] = get_user_profile(user=user)
 return ExtraContextTemplateView.as_view(template_name=template_name, extra_context=extra_context)(request)

@ secure_required @ permission_required_or_403 ( 'change_user' , ( get_user_model ( ) , 'username' , 'username' ) ) def email_change ( request , username , email_form = ChangeEmailForm , template_name = 'userena/email_form.html' , success_url = None , extra_context = None ) : user = get_object_or_404 ( get_user_model ( ) , username__iexact = username ) prev_email = user . email form = email_form ( user ) if ( request . method == 'POST' ) : form = email_form ( user , request . POST , request . FILES ) if form . is_valid ( ) : form . save ( ) if success_url : userena_signals . email_change . send ( sender = None , user = user , prev_email = prev_email , new_email = user . email ) redirect_to = success_url else : redirect_to = reverse ( 'userena_email_change_complete' , kwargs = { 'username' : user . username } ) return redirect ( redirect_to ) if ( not extra_context ) : extra_context = dict ( ) extra_context [ 'form' ] = form extra_context [ 'profile' ] = get_user_profile ( user = user ) return ExtraContextTemplateView . as_view ( template_name = template_name , extra_context = extra_context ) ( request )
change email address .