@login_required
@require_POST
def add_contributor(request, document_slug):
 document = get_object_or_404(Document, locale=request.LANGUAGE_CODE, slug=document_slug)
 if (not document.allows(request.user, 'edit')):
  raise PermissionDenied
 form = AddContributorForm(request.POST)
 if form.is_valid():
  for user in form.cleaned_data['users']:
   document.contributors.add(user)
  msg = _('{users} added to the contributors successfully!').format(users=request.POST.get('users'))
  messages.add_message(request, messages.SUCCESS, msg)
  return HttpResponseRedirect(reverse('wiki.document_revisions', args=[document_slug]))
 msg = _('There were errors adding new contributors, see below.')
 messages.add_message(request, messages.ERROR, msg)
 return document_revisions(request, document_slug, contributor_form=form)

@ login_required @ require_POST def add_contributor ( request , document_slug ) : document = get_object_or_404 ( Document , locale = request . LANGUAGE_CODE , slug = document_slug ) if ( not document . allows ( request . user , 'edit' ) ) : raise PermissionDenied form = AddContributorForm ( request . POST ) if form . is_valid ( ) : for user in form . cleaned_data [ 'users' ] : document . contributors . add ( user ) msg = _ ( '{users} added to the contributors successfully!' ) . format ( users = request . POST . get ( 'users' ) ) messages . add_message ( request , messages . SUCCESS , msg ) return HttpResponseRedirect ( reverse ( 'wiki.document_revisions' , args = [ document_slug ] ) ) msg = _ ( 'There were errors adding new contributors, see below.' ) messages . add_message ( request , messages . ERROR , msg ) return document_revisions ( request , document_slug , contributor_form = form )
add a contributor to a document .