Add related primary keys to a User instance.
347406
def user_default_add_related_pks(self, obj):
        """"""
        if not hasattr(obj, '_votes_pks'):
            obj._votes_pks = list(obj.votes.values_list('pk', flat=True))
785759
public function addReference( PgAttribute $primaryKey, $includeChildTables = true )
    {

        $this->references->add( $primaryKey );
        $primaryKey->isReferencedBy->add( $this );

        if( $includeChildTables || true ) {
            foreach( $primaryKey->getRelation()->getChildren() as $child ) {
                $this->addReference($child->getAttributeByName($primaryKey->name), true);
            }
        }

        return;

        // TODO. Add support for inheritance
        $query = new Query(
            "SELECT oid::text || '.' || %attnum:int%::text FROM dev.relationDescendants( %oid:int%::oid ) as _ ( oid );",
            array(
                'attnum' => $pk->get('attnum'),
                'oid' => $pk->get('relation')->get('oid')
            )
        );

    }
736987
def keys():
    """"""
    for admin in current_app.config['ADMIN_USERS']:
        try:
            db.get_db()  # init db on global app context
            keys = ApiKey.find_by_user(admin)
        except Exception as e:
            click.echo('ERROR: {}'.format(e))
        else:
            for key in keys:
                click.echo('{:40} {}'.format(key.key, key.user))
132386
def add(user_id, resource_policy, admin, inactive,  rate_limit):
    '''
    
    '''
    try:
        user_id = int(user_id)
    except ValueError:
        pass  # string-based user ID for Backend.AI v1.4+
    with Session() as session:
        try:
            data = session.KeyPair.create(
                user_id,
                is_active=not inactive,
                is_admin=admin,
                resource_policy=resource_policy,
                rate_limit=rate_limit)
        except Exception as e:
            print_error(e)
            sys.exit(1)
        if not data['ok']:
            print_fail('KeyPair creation has failed: {0}'.format(data['msg']))
            sys.exit(1)
        item = data['keypair']
        print('Access Key: {0}'.format(item['access_key']))
        print('Secret Key: {0}'.format(item['secret_key']))
971880
def user_identity_make_primary(self, user_id, id, data, **kwargs):
        ""
        api_path = "/api/v2/users/{user_id}/identities/{id}/make_primary"
        api_path = api_path.format(user_id=user_id, id=id)
        return self.call(api_path, method="PUT", data=data, **kwargs)
873027
def move_user_data(primary, secondary):
    '''
        
    '''
    # Update all submission authorships of the secondary to the primary
    submissions = Submission.objects.filter(authors__id=secondary.pk)
    for subm in submissions:
        if subm.submitter == secondary:
            subm.submitter = primary
        subm.authors.remove(secondary)
        subm.authors.add(primary)
        subm.save()
    # Transfer course registrations
    try:
        for course in secondary.profile.courses.all():
            primary.profile.courses.add(course)
            primary.profile.save()
    except UserProfile.DoesNotExist:
        # That's a database consistency problem, but he will go away anyway
        pass
1165665
def _add_goterms(self, go2obj_user, goid):
        """"""
        goterm = self.go2obj_orig[goid]
        if goid != goterm.id and goterm.id in go2obj_user and goid not in go2obj_user:
            go2obj_user[goid] = goterm
494716
def upgrade():
    """"""
    op.create_table(
        'userprofiles_userprofile',
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=255), nullable=True),
        sa.Column('displayname', sa.String(length=255), nullable=True),
        sa.Column('full_name', sa.String(length=255), nullable=False),
        sa.ForeignKeyConstraint(['user_id'], [u'accounts_user.id'], ),
        sa.PrimaryKeyConstraint('user_id'),
        sa.UniqueConstraint('username')
    )
400229
def key_add(self):
        """"""
        from .main import add_api_key
        add_api_key(self.key_name.get(), self.key_val.get())

        # Clear the text fields
        self.key_name.set("")
        self.key_val.set("")
88869
def add_user(self, attrs):
        
        username = attrs[self.key]
        if username in self.users:
            raise UserAlreadyExists(username, self.backend_name)
        self.users[username] = attrs
        self.users[username]['groups'] = set([])
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
506746
def question_default_add_related_pks(self, obj):
        """"""
        if not hasattr(obj, '_choice_pks'):
            obj._choice_pks = list(obj.choices.values_list('pk', flat=True))
898302
def contribute_to_related_class(self, cls, related):
        
        # Internal FK's - i.e., those with a related name ending with '+' -
        # and swapped models don't get a related descriptor.
        super(VersionedForeignKey, self).contribute_to_related_class(cls,
                                                                     related)
        accessor_name = related.get_accessor_name()
        if hasattr(cls, accessor_name):
            setattr(cls, accessor_name,
                    VersionedReverseManyToOneDescriptor(related))
804671
def add_user(self, user, **kwargs):
        """"""
        if isinstance(user, User):
            user = user['id']

        assert isinstance(user, six.string_types)

        endpoint = '{0}/{1}/users/{2}'.format(
            self.endpoint,
            self['id'],
            user,
        )
        result = self.request('PUT', endpoint=endpoint, query_params=kwargs)
        return result
828541
protected function addForeignKeys()
    {
        $this->addForeignKey(
            $this->db->getForeignKeyName(
                TransformerRecord::tableName(),
                'siteId'
            ),
            TransformerRecord::tableName(),
            'siteId',
            SiteRecord::tableName(),
            'id',
            'CASCADE',
            'CASCADE'
        );
    }
1096590
def add(self, private_key):
        
        if not isinstance(private_key, PaillierPrivateKey):
            raise TypeError("private_key should be of type PaillierPrivateKey, "
                            "not %s" % type(private_key))
        self.__keyring[private_key.public_key] = private_key
926884
protected function addForeignKeys()
    {
        $this->addForeignKey(
            null,
            static::tableName(),
            'elementId',
            ElementRecord::tableName(),
            'id',
            'CASCADE',
            null
        );
        $this->addForeignKey(
            null,
            static::tableName(),
            'siteId',
            SiteRecord::tableName(),
            'id',
            'CASCADE',
            'CASCADE'
        );
        $this->addForeignKey(
            null,
            static::tableName(),
            'fieldId',
            FieldRecord::tableName(),
            'id',
            'CASCADE',
            'CASCADE'
        );
    }