@login_required
@require_POST
def add_to_locale(request, locale_code, role):
 locale = get_object_or_404(Locale, locale=locale_code)
 if (not _user_can_edit(request.user, locale)):
  raise PermissionDenied
 form = AddUserForm(request.POST)
 if form.is_valid():
  for user in form.cleaned_data['users']:
   getattr(locale, ROLE_ATTRS[role]).add(user)
  msg = _('{users} added successfully!').format(users=request.POST.get('users'))
  messages.add_message(request, messages.SUCCESS, msg)
  return HttpResponseRedirect(locale.get_absolute_url())
 msg = _('There were errors adding users, see below.')
 messages.add_message(request, messages.ERROR, msg)
 return locale_details(request, locale_code, **{(role + '_form'): form})

@ login_required @ require_POST def add_to_locale ( request , locale_code , role ) : locale = get_object_or_404 ( Locale , locale = locale_code ) if ( not _user_can_edit ( request . user , locale ) ) : raise PermissionDenied form = AddUserForm ( request . POST ) if form . is_valid ( ) : for user in form . cleaned_data [ 'users' ] : getattr ( locale , ROLE_ATTRS [ role ] ) . add ( user ) msg = _ ( '{users} added successfully!' ) . format ( users = request . POST . get ( 'users' ) ) messages . add_message ( request , messages . SUCCESS , msg ) return HttpResponseRedirect ( locale . get_absolute_url ( ) ) msg = _ ( 'There were errors adding users, see below.' ) messages . add_message ( request , messages . ERROR , msg ) return locale_details ( request , locale_code , ** { ( role + '_form' ) : form } )
add a user to the locale role .