def prepare(annotation): """ Prepare the given annotation for indexing. Scan the passed annotation for any target URIs or document metadata URIs and add normalized versions of these to the document. """ # FIXME: When this becomes simply part of a search indexing operation, this # should probably not mutate its argument. _normalize_annotation_target_uris(annotation) if 'user' in annotation and nipsa.has_nipsa(annotation['user']): annotation['nipsa'] = True
def prepare(annotation): """ Prepare the given annotation for indexing. Scan the passed annotation for any target URIs or document metadata URIs and add normalized versions of these to the document. """ groups.set_group_if_reply(annotation) groups.insert_group_if_none(annotation) groups.set_permissions(annotation) # FIXME: Remove this in a month or so, when all our clients have been # updated. -N 2015-09-25 _transform_old_style_comments(annotation) # FIXME: When this becomes simply part of a search indexing operation, this # should probably not mutate its argument. _normalize_annotation_target_uris(annotation) if 'user' in annotation and nipsa.has_nipsa(annotation['user']): annotation['nipsa'] = True
def _create_annotation(fields, user): """Create and store an annotation.""" # Some fields are not to be set by the user, ignore them for field in PROTECTED_FIELDS: fields.pop(field, None) # Create Annotation instance annotation = Annotation(fields) annotation['user'] = user.id annotation['consumer'] = user.consumer.key if nipsa.has_nipsa(user.id): annotation["nipsa"] = True # Save it in the database annotation.save() log.debug('Created annotation; user: %s, consumer key: %s', annotation['user'], annotation['consumer']) return annotation