Пример #1
0
 def update(self, params, _set, other):
     obj = models.List.objects.get(aid=params['_id'])
     if '$set' in _set:
         for key, val in _set['$set'].items():
             if key == 'userId':
                 user = get_object(User, val)
                 obj.user = user
             setattr(obj, key, val)
             obj.save()
     if '$inc' in _set:
         for key, val in _set['$inc'].items():
             cur = getattr(obj, key)
             new_val = cur + val
             setattr(obj, key, new_val)
             obj.save()
Пример #2
0
    def update(self, selector, update, options=None):
        """Update user data."""
        user = get_object(
            self.model, selector['_id'],
            pk=this.request.user.pk,
        )
        profile_update = self.deserialize_profile(
            user, update['$set'], key_prefix='profile.', pop=True,
        )
        if len(update['$set']) != 0:
            raise MeteorError(400, 'Invalid update fields: %r')

        for key, val in profile_update.items():
            setattr(user, key, val)
        user.save()
Пример #3
0
    def update(self, selector, update, options=None):
        """Update user data."""
        # we're ignoring the `options` argument at this time
        del options
        user = get_object(
            self.model, selector['_id'],
            pk=this.user_id,
        )
        profile_update = self.deserialize_profile(
            update['$set'], key_prefix='profile.', pop=True,
        )
        if len(update['$set']) != 0:
            raise MeteorError(400, 'Invalid update fields: %r')

        for key, val in profile_update.items():
            setattr(user, key, val)
        user.save()