@must_be_valid_project
@must_have_permission(ADMIN)
@must_not_be_registration
def invite_contributor_post(node, **kwargs):
 fullname = request.json.get('fullname').strip()
 email = request.json.get('email')
 fullname = sanitize.strip_html(fullname)
 if email:
  email = email.lower().strip()
  try:
   validate_email(email)
  except ValidationError as e:
   return ({'status': 400, 'message': e.message}, 400)
 if (not fullname):
  return ({'status': 400, 'message': 'Full name field cannot be empty'}, 400)
 user = get_user(email=email)
 if user:
  if user.is_registered:
   msg = 'User is already in database. Please go back and try your search again.'
   return ({'status': 400, 'message': msg}, 400)
  elif node.is_contributor(user):
   msg = 'User with this email address is already a contributor to this project.'
   return ({'status': 400, 'message': msg}, 400)
  else:
   serialized = profile_utils.add_contributor_json(user)
   serialized['fullname'] = fullname
   serialized['email'] = email
 else:
  serialized = profile_utils.serialize_unregistered(fullname, email)
 return {'status': 'success', 'contributor': serialized}

@ must_be_valid_project @ must_have_permission ( ADMIN ) @ must_not_be_registration def invite_contributor_post ( node , ** kwargs ) : fullname = request . json . get ( 'fullname' ) . strip ( ) email = request . json . get ( 'email' ) fullname = sanitize . strip_html ( fullname ) if email : email = email . lower ( ) . strip ( ) try : validate_email ( email ) except ValidationError as e : return ( { 'status' : 400 , 'message' : e . message } , 400 ) if ( not fullname ) : return ( { 'status' : 400 , 'message' : 'Full name field cannot be empty' } , 400 ) user = get_user ( email = email ) if user : if user . is_registered : msg = 'User is already in database. Please go back and try your search again.' return ( { 'status' : 400 , 'message' : msg } , 400 ) elif node . is_contributor ( user ) : msg = 'User with this email address is already a contributor to this project.' return ( { 'status' : 400 , 'message' : msg } , 400 ) else : serialized = profile_utils . add_contributor_json ( user ) serialized [ 'fullname' ] = fullname serialized [ 'email' ] = email else : serialized = profile_utils . serialize_unregistered ( fullname , email ) return { 'status' : 'success' , 'contributor' : serialized }
api view for inviting an unregistered user .