Modify a founditem.

    id: founditem id
13310
def founditem_modify_view(request, item_id=None):
    
    if request.method == "POST":
        founditem = get_object_or_404(FoundItem, id=item_id)
        form = FoundItemForm(request.POST, instance=founditem)
        if form.is_valid():
            obj = form.save()
            logger.debug(form.cleaned_data)
            # SAFE HTML
            obj.description = safe_html(obj.description)
            obj.save()
            messages.success(request, "Successfully modified found item.")
            return redirect("founditem_view", obj.id)
        else:
            messages.error(request, "Error adding found item.")
    else:
        founditem = get_object_or_404(FoundItem, id=item_id)
        form = FoundItemForm(instance=founditem)

    context = {"form": form, "action": "modify", "id": item_id, "founditem": founditem}
    return render(request, "lostfound/founditem_form.html", context)
1231175
function normalizeItems(items, params) {
        var _items = [];
        for (var i = 0, l = items.length; i < l; i++) {
            _items.push({
                id: items[i],
                params: params
            });
        }

        return _items;
    }
207480
def _get_by_id(collection, id):
    '''
    
    '''
    matches = [item for item in collection if item.id == id]
    if not matches:
        raise ValueError('Could not find a matching item')
    elif len(matches) > 1:
        raise ValueError('The id matched {0} items, not 1'.format(len(matches)))
    return matches[0]
30187
def updateItem(self, instance, subKey, value):
    """"""
    instanceId = statsId(instance)

    container = _Stats.getContainerForObject(instanceId)
    self._aggregate(instanceId, container, value, subKey)
584725
def _get_id2lower(id2lower, item_id, item_obj):
    """"""
    if item_id in id2lower:
        return id2lower[item_id]
    lower_ids = set()
    for lower_obj in item_obj.get_goterms_lower():
        lower_id = lower_obj.item_id
        lower_ids.add(lower_id)
        lower_ids |= _get_id2lower(id2lower, lower_id, lower_obj)
    id2lower[item_id] = lower_ids
    return lower_ids
1336361
def modify(ctx, schema, uuid, object_filter, field, value):
    """"""
    database = ctx.obj['db']

    model = database.objectmodels[schema]
    obj = None

    if uuid:
        obj = model.find_one({'uuid': uuid})
    elif object_filter:
        obj = model.find_one(literal_eval(object_filter))
    else:
        log('No object uuid or filter specified.',
            lvl=error)

    if obj is None:
        log('No object found',
            lvl=error)
        return

    log('Object found, modifying', lvl=debug)
    try:
        new_value = literal_eval(value)
    except ValueError:
        log('Interpreting value as string')
        new_value = str(value)

    obj._fields[field] = new_value
    obj.validate()
    log('Changed object validated', lvl=debug)
    obj.save()
    log('Done')
539790
def fill_parentidid2obj_r0(self, id2obj, child_obj):
        """"""
        for parent_obj in child_obj.parents:
            if parent_obj.item_id not in id2obj:
                id2obj[parent_obj.item_id] = parent_obj
                self.fill_parentidid2obj_r0(id2obj, parent_obj)
1022912
function (items, id_path, done) {

      done = typeof id_path == 'function' ? id_path : done

      var next = function(item, cb) {
        debug('creating %s', type)

        File.create(item[file_type], function(err, items) {
          if(err)
            return cb(err)

          item[file_type] = Array.prototype.slice.call(arguments, 1)
          debug('%s %s created', item[file_type].length, file_type)

          models[type].create(item, function(err, item) {
            if(err)
              return cb(err)

            debug('item created')

            if(id_path) {
              debug('Saving item to path')
              require('./paths')
              .files.add(id_path, item, function(err, path) {
                cb(err, item)
              })
            } else
              return cb(null, item)

          })
        })

      }

      if(items instanceof Array) {
        async.map(items, next,	done)
      } else {
        next(items, done)
      }
    }
780418
def addItem(self, itemType, itemContents, itemID=None):
        

        if itemType not in self.noteDB.collection_names():
            fields = [(ii, pymongo.TEXT) for ii in itemContents]
            self.noteDB[itemType].ensure_index(fields)

        collection = self.noteDB[itemType]

        if itemID is None:
            itemContents['timestamps'] = [time.time()]
            itemID = self.getNewID()
            itemContents["ID"] = itemID
            collection.insert(itemContents)
        else:
            _id = collection.find_one({"ID": itemID})["_id"]
            timestamps = collection.find_one({"ID": itemID})["timestamps"]
            timestamps.append(time.time())
            itemContents["timestamps"] = timestamps
            itemContents["ID"] = itemID
            collection.update({"_id": _id}, itemContents)

        return itemID
398129
def deleteItem(self, itemID):
        
        collections = self.get_data_collections()

        query = {"currentMax": {"$exists": True}}
        currentMax = self.noteDB["IDs"].find_one(query)['currentMax']
        query = {"unusedIDs": {"$exists": True}}
        unusedIDs = self.noteDB['IDs'].find_one(query)['unusedIDs']

        if (itemID > currentMax) or (itemID in unusedIDs):
            raise ValueError("ID {0} does not exist".format(itemID))

        # Find document with ID
        for coll in collections:
            self.noteDB[coll].remove({"ID": itemID})

        if currentMax == itemID:
            self.noteDB['IDs'].update({"currentMax": currentMax},
                                      {"currentMax": currentMax - 1})
        else:
            unusedIDs.append(itemID)
            self.noteDB['IDs'].update({"unusedIDs": {"$exists": True}},
                                      {"unusedIDs": unusedIDs})

        return itemID
482553
async def modify(self, **kwargs):
        '''
        
        '''
        try:
            pk = self.pk_type(kwargs['pk'])
            # modify is a class method on MongoCollectionMixin
            result = await self._meta.object_class.modify(self.db, key=pk, data=self.data)
            if result is None:
                raise NotFound('Object matching the given {} was not found'.format(self.pk))
            return await result.serialize()
        except Exception as ex:
            logger.exception(ex)
            raise BadRequest(ex)
1020250
def update_without_overwrite(d, *args, **kwds):
    
    if args:
        assert len(args) == 1, \
            'At most one positional parameter is allowed: {0!r}'.format(args)

        (other,) = args
        if isinstance(other, Mapping):
            for key in other:
                setitem_without_overwrite(d, key, other[key])
        elif hasattr(other, "keys"):
            for key in other.keys():
                setitem_without_overwrite(d, key, other[key])
        else:
            for key, value in other:
                setitem_without_overwrite(d, key, value)

    for key, value in kwds.items():
        setitem_without_overwrite(d, key, value)
490258
def _fix_callback_item(self, item):
        ''
        item.component_id = self._fix_id(item.component_id)
        return item
115900
def modify(self, **params):
        """"""
        data = self.api_client.update_account(self.id, **params)
        self.update(data)
        return data
269251
def _modifyItemTag(self, item_id, action, tag):
        
        return self.httpPost(ReaderUrl.EDIT_TAG_URL,
                             {'i': item_id, action: tag, 'ac': 'edit-tags'})
18028
void updateItems(List<String> updatedItems) {

        Set<CmsUUID> ids = new HashSet<CmsUUID>();
        for (String id : updatedItems) {
            ids.add(new CmsUUID(id));
        }
        m_resultTable.update(ids, false);
    }
1012080
def set_by_Id(self, Id, is_added):
        """"""
        row = self.collection.index_from_id(Id)
        if row is None:
            return
        self._set_id(Id, is_added, self.index(row, 0))