I have been asked to make a 'tab' (or portlet or whatever) for 'personal notes' for some content item (types). How could/should that be done?
I other words, after someone has added 'SomeContentItem' of type 'SomeContentType', user A can add his personal comments to it, which only he/she can edit/read. Same with user B.
Maybe I should make the content type folderish and keep the 'comments' inside it, or make the content related items ?
Anything 'special' I should keep in mind ?
UPDATE: I have dont this the following way, hopefully that is good enough (if not, tell).
- My ContentItem A is folderish and can only contain content type 'personal_notes'
- Field 'Personal Notes' of 'A' is a rich text field.
- When saving content type A, a content type type of 'personal_notes' is saved if 'Notes' field is not empty. After that, field 'notes' field is 'cleared'.
- When editing 'A', field 'notes' is populated with content of 'personal_notes'.
3 is done with a subscriber similar to this:
def save_note(object, event): """Make notes content items""" context = object user = api.user.get_current().getMemberId() item = api.content.find(context=context, id=user, portal_type='personal_notes' ) #Update personal note with content if IObjectModifiedEvent.providedBy(event): if not item: # Notes does not exist yet, create it if object.private_notes: item = api.content.create( type='personal_notes', container=context, id=user, title=user, bodytext=object.private_notes ) else: notes_item = item.getObject() notes_item.bodytext = object.private_notes object.private_notes = None
In the edit form, I will use something like this:
context = self.context user = api.user.get_current().getMemberId() item = api.content.find(context=context, id=user, portal_type='personal_notes' ) if item: notes_item = item.getObject() group.widgets['private_notes'].value = notes_item.bodytext else: self.private_notes = None