The logged in project leader OR administrator wants to invite somebody.
165196
def _send_invitation(request, project):
    
    form = forms.InviteUserApplicationForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():

            email = form.cleaned_data['email']
            applicant, existing_person = get_applicant_from_email(email)

            # If applicant is None then there were multiple persons found.
            if applicant is None:
                return render(
                    template_name='kgapplications/'
                                  'project_common_invite_multiple.html',
                    context={'form': form, 'email': email},
                    request=request)

            if existing_person and 'existing' not in request.POST:
                return render(
                    template_name='kgapplications/'
                                  'project_common_invite_existing.html',
                    context={'form': form, 'person': applicant},
                    request=request)

            application = form.save(commit=False)
            application.applicant = applicant
            application.project = project
            application.save()
            state_machine = get_application_state_machine()
            response = state_machine.start(request, application)
            return response

    return render(
        template_name='kgapplications/project_common_invite_other.html',
        context={'form': form, 'project': project, },
        request=request)
695248
def _parse_invited_member(self, values):
        
        name, date = values
        if date != "Invitation Date":
            self.invites.append(GuildInvite(name, date))
916112
def invite(self, email, roles=None):
        
        if roles is None:
            role_ids = [self.roles['Guest'].roleId]
        elif roles == "ALL":
            role_ids = list([i.id for i in self.roles])
        else:
            if "Guest" not in roles:
                roles.append('Guest')
            role_ids = list([i.id for i in self.roles if i.name in roles])

        self._router.invite_user(data=json.dumps({
            "organizationId": self.organizationId,
            "email": email,
            "roles": role_ids}))
347436
def invite(name, emails, perm):
    
    with Session() as session:
        try:
            assert perm in ['rw', 'ro'], \
                   'Invalid permission: {}'.format(perm)
            result = session.VFolder(name).invite(perm, emails)
            invited_ids = result.get('invited_ids', [])
            if len(invited_ids) > 0:
                print('Invitation sent to:')
                for invitee in invited_ids:
                    print('\t- ' + invitee)
            else:
                print('No users found. Invitation was not sent.')
        except Exception as e:
            print_error(e)
            sys.exit(1)
639260
def welcome(self, user):
        
        self.send_message(create_message('RoomServer', 'Please welcome {name} to the server!\nThere are currently {i} users online -\n {r}\n'.format(name=user.id, 
                          i=self.amount_of_users_connected, 
                          r=' '.join(self.user_names))))
        logging.debug('Welcoming user {user} to {room}'.format(user=user.id.name, room=self.name))
1353278
def invite(user, reason='')
      response = self.class.post(@api.invite_config[:url]+"/#{user}",
        :query => { :auth_token => @token },
        :body => {
          :reason => reason
        }.to_json,
        :headers => @api.headers)

      ErrorHandler.response_code_to_exception_for :room, room_id, response
      true
    end
1172298
def addprojectmember(self, project_id, user_id, access_level):
        
        # if isinstance(access_level, basestring):
        if access_level.lower() == 'master':
            access_level = 40
        elif access_level.lower() == 'developer':
            access_level = 30
        elif access_level.lower() == 'reporter':
            access_level = 20
        else:
            access_level = 10

        data = {'id': project_id, 'user_id': user_id, 'access_level': access_level}

        request = requests.post(
            '{0}/{1}/members'.format(self.projects_url, project_id),
            headers=self.headers, data=data, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout)

        if request.status_code == 201:
            return True
        else:
            return False
1006642
def on_presence(self, session, presence):
        """"""
        from_jid = presence.getFrom()
        is_member = self.is_member(from_jid.getStripped())
        if is_member:
            member = self.get_member(from_jid.getStripped())
        else:
            member = None

        logger.info('presence: from=%s is_member=%s type=%s' % (from_jid, is_member, presence.getType()))

        if presence.getType() == 'subscribed':
            if is_member:
                logger.info('[%s] accepted their invitation' % (from_jid,))
                member['STATUS'] = 'ACTIVE'
            else:
                #TODO: user accepted, but is no longer be on the roster, unsubscribe?
                pass
        elif presence.getType() == 'subscribe':
            if is_member:
                logger.info('Acknowledging subscription request from [%s]' % (from_jid,))
                self.client.sendPresence(jid=from_jid, typ='subscribed')
                member['STATUS'] = 'ACTIVE'
                self.broadcast('%s has accepted their invitation!' % (from_jid,))
            else:
                #TODO: show that a user has requested membership?
                pass
        elif presence.getType() == None:
            if is_member:
                member['ONLINE'] += 1
        elif presence.getType() == 'unavailable':
            if is_member:
                member['ONLINE'] -= 1
        else:
            logger.info('Unhandled presence stanza of type [%s] from [%s]' % (presence.getType(), from_jid))
667230
def invite_user(self, email, role):
        
        parameters = {
            'email': email,
            'role': role
        }

        connection = Connection(self.token)
        connection.set_url(self.production, self.TEAM_USERS_URL)
        connection.add_params(parameters)

        return connection.post_request()
922515
def add_user(self, user, is_admin=False):
        
        users_count = self.users.all().count()
        if users_count == 0:
            is_admin = True
        # TODO get specific org user?
        org_user = self._org_user_model.objects.create(
            user=user, organization=self, is_admin=is_admin
        )
        if users_count == 0:
            # TODO get specific org user?
            self._org_owner_model.objects.create(
                organization=self, organization_user=org_user
            )

        # User added signal
        user_added.send(sender=self, user=user)
        return org_user
641454
def prepend_global_admin_user(other_users, server):
    
    cred0 = get_global_login_user(server, "admin")
    if cred0 and cred0["username"] and cred0["password"]:
        log_verbose("Seeding : CRED0 to the front of the line!")
        return [cred0] + other_users if other_users else [cred0]
    else:
        return other_users
1312991
def make_admin(user):
    '''
    
    '''
    tutor_group, owner_group = _get_user_groups()
    user.is_staff = True
    user.is_superuser = True
    user.save()
    owner_group.user_set.add(user)
    owner_group.save()
    tutor_group.user_set.add(user)
    tutor_group.save()
5320
def run(self, args):
        
        email = args.email                  # email of person to give permissions, will be None if username is specified
        username = args.username            # username of person to give permissions, will be None if email is specified
        auth_role = args.auth_role          # type of permission(project_admin)
        project = self.fetch_project(args, must_exist=True, include_children=False)
        user = self.remote_store.lookup_or_register_user_by_email_or_username(email, username)
        self.remote_store.set_user_project_permission(project, user, auth_role)
        print(u'Gave user {} {} permissions for project {}.'.format(user.full_name, auth_role, project.name))
509105
def _parse_invite(client, command, actor, args):
    """"""
    target, _, channel = args.rpartition(" ")
    client.dispatch_event("INVITE", actor, target, channel.lower())
1363072
public boolean addAdministrator(String projectId, String name, String email){
        ResponseWrapper wrapper = service.addProjectMember(Action.ADD_CONTRIBUTOR, apiKey, projectId, name, email, null, 1);
        return "200".equals(wrapper.response.code);
    }
491991
def addUser(self, username, password,
                firstname, lastname,
                email, role):
        """"""
        self._invites.append({
            "username":username,
            "password":password,
            "firstname":firstname,
            "lastname":lastname,
            "fullname":"%s %s" % (firstname, lastname),
            "email":email,
            "role":role
        })
744008
private static void ensureProjectMember(ProjectMetadata project, User user) {
        requireNonNull(project, "project");
        requireNonNull(user, "user");

        checkArgument(project.members().values().stream().anyMatch(member -> member.login().equals(user.id())),
                      user.id() + " is not a member of the project " + project.name());
    }