Add a user to an organization.
517066
def update(self, request, pk=None, parent_lookup_organization=None):
        ''''''
        user = get_object_or_404(User, pk=pk)
        org = get_object_or_404(
            SeedOrganization, pk=parent_lookup_organization)
        self.check_object_permissions(request, org)
        org.users.add(user)
        return Response(status=status.HTTP_204_NO_CONTENT)
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()
1180576
def add_clients(session, verbose):
  """"""
  for ctype in ['Genuine', 'Impostor']:
    for cdid in userid_clients:
      cid = ctype + '_%d' % cdid
      if verbose>1: print("  Adding user '%s' of type '%s'..." % (cid, ctype))
      session.add(Client(cid, ctype, cdid))
25244
def create_user(ctx):
    """"""

    try:
        new_user = _create_user(ctx)

        new_user.save()
        log("Done")
    except KeyError:
        log('User already exists', lvl=warn)
87522
def add_user_to_group(iam_client, user, group, quiet = False):
    
    if not quiet:
        printInfo('Adding user to group %s...' % group)
    iam_client.add_user_to_group(GroupName = group, UserName = user)
403009
async def add_member(self, db, user):
        '''  '''

        # use model's pk as query
        query = {self.primary_key: self.pk}
        # push review
        result = await db[self.get_collection_name()].update_one(
            filter=query,
            update={'$addToSet': {'members': DBRefField(User).to_python(user)}},
        )
        return result
957860
def add_organization(self, service_desk_id, organization_id):
        
        log.warning('Adding organization...')
        url = 'rest/servicedeskapi/servicedesk/{}/organization'.format(service_desk_id)
        data = {'organizationId': organization_id}

        return self.post(url, headers=self.experimental_headers, data=data)
903051
function updateOrg() {
            var userId;
            if (req.body.hasOwnProperty('disabled') && req.body.disabled === false) {
                userId = getUserId(req);
                return gmeAuth.getUser(userId)
                    .then(function (userData) {
                        if (userData.siteAdmin === true) {
                            return gmeAuth.reEnableOrganization(req.params.orgId);
                        } else {
                            res.status(403);
                            throw new Error('re-enabling organizations requires site admin role');
                        }
                    });
            } else {
                return ensureOrgOrSiteAdmin(req, res)
                    .then(function () {
                        return gmeAuth.updateOrganizationInfo(req.params.orgId, req.body.info);
                    });
            }
        }
999405
function insertOrgAdminUser (job, next) {
    if (job.user) {
      const { id, name } = job.user
      const { id: organizationId } = job.organization

      userOps.insertUser(job.client, { id, name, organizationId }, (err, res) => {
        if (err) return next(err)
        job.user.id = res.rows[0].id

        userOps.insertPolicies(job.client, job.user.id, [{id: job.adminPolicyId, variables: {}}], utils.boomErrorWrapper(next))
      })

      return
    }

    next()
  }
796632
async def AddUser(self, users):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='UserManager',
                   request='AddUser',
                   version=2,
                   params=_params)
        _params['users'] = users
        reply = await self.rpc(msg)
        return reply
541619
def add_user(self, nick, prefixes=None):
        """"""
        if nick not in self._user_nicks:
            self._user_nicks.append(nick)

        self.prefixes[nick] = prefixes
1180785
def update_org_users(cls, module):
        
        try:
            cls.module_registry[module]["OrgUserModel"]._meta.get_field("user")
        except FieldDoesNotExist:
            cls.module_registry[module]["OrgUserModel"].add_to_class(
                "user",
                models.ForeignKey(
                    USER_MODEL,
                    related_name="%(app_label)s_%(class)s",
                    on_delete=models.CASCADE,
                ),
            )
        try:
            cls.module_registry[module]["OrgUserModel"]._meta.get_field("organization")
        except FieldDoesNotExist:
            cls.module_registry[module]["OrgUserModel"].add_to_class(
                "organization",
                models.ForeignKey(
                    cls.module_registry[module]["OrgModel"],
                    related_name="organization_users",
                    on_delete=models.CASCADE,
                ),
            )
382235
def add_user(self, name: str, email: str) -> models.User:
        """"""
        new_user = self.User(name=name, email=email)
        self.add_commit(new_user)
        return new_user
81151
function addUser(user) {
	var slElement = $(document.createElement("option"));
	slElement.attr("value", user);
	slElement.text(user);
	$("#usersList").append(slElement);
}
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
        })
644331
public function bindUserToOrganization()
    {
        $limit = 250;
        $offset = 0;
        $this->log('Add organizations to users...');
        $this->objectManager->startFlushSuite();
        $countUsers = $this->objectManager->count('ClarolineCoreBundle:User');
        $default = $this->organizationManager->getDefault();
        $i = 0;

        while ($offset < $countUsers) {
            $users = $this->userRepo->findBy([], null, $limit, $offset);

            /** @var User $user */
            foreach ($users as $user) {
                $this->log('Setting user administrated organization...');

                foreach ($user->getAdministratedOrganizations() as $organization) {
                    //I know this is weird but the setter is now in this method (it used to not exist)
                    $user->addAdministratedOrganization($organization);
                }

                if (0 === count($user->getOrganizations())) {
                    ++$i;
                    $this->log('Add default organization for user '.$user->getUsername());
                    $user->addOrganization($default);
                    $this->objectManager->persist($user);

                    if (0 === $i % 250) {
                        $this->log("Flushing... [UOW = {$this->objectManager->getUnitOfWork()->size()}]");
                        $this->objectManager->forceFlush();
                    }
                } else {
                    $this->log("Organization for user {$user->getUsername()} already exists");
                }
            }

            $this->log("Flushing... [UOW = {$this->objectManager->getUnitOfWork()->size()}]");
            $this->objectManager->forceFlush();
            $default = $this->organizationManager->getDefault();

            $offset += $limit;
        }

        $this->objectManager->endFlushSuite();
    }
198633
def _add_user_to_file(file_id, service, user_email,
                      perm_type='user', role='writer'):
    
    new_permission = {
        'value': user_email,
        'type': perm_type,
        'role': role
    }
    try:
        service.permissions()\
            .insert(fileId=file_id, body=new_permission)\
            .execute()
    except errors.HttpError as error:
        show_error('An error adding users to spreadsheet: {0}'.format(error))