def get_all(self, proj, annotable_id): """Return a html fragment with a list of notes for this object.""" annotable = annotable_get(annotable_id) t_notes.value = annotable.notes t_notes.update_filter = annotable.id t_notes.extra_data = dict(proj=tmpl_context.project.id) tmpl_context.t_notes = t_notes return dict()
def new(self, proj, annotable_id, **kwargs): """Display a NEW form.""" project = tmpl_context.project session = session_get() annotable = annotable_get(annotable_id) f_new.value = dict(proj=project.id, annotable_id=annotable.id) tmpl_context.form = f_new return dict(title='%s %s' % (_('Add a note to:'), annotable.annotated.path))
def post(self, proj, annotable_id, text): """Add notes to a ``annotable`` obect.""" session = session_get() user = tmpl_context.user annotable = annotable_get(annotable_id) ob = annotable.annotated note = Note(user, text) annotable.notes.append(note) session.refresh(annotable) msg = '%s %s' % (_('Added note to:'), annotable.annotated.path) updates = [dict(item=note, type='added', topic=TOPIC_NOTES, filter=ob.annotable.id)] if isinstance(ob, AssetVersion): updates.append(dict(item=ob.asset, topic=TOPIC_ASSETS)) else: updates.append(dict(item=ob, topic=TOPICS[ob.__class__])) notify.send(updates) return dict(msg=msg, status='ok', updates=updates)