def edit_note(self, note_id=None, visiting_group_id=None): tmpl_context.form = create_edit_note_form if note_id == '': note_o = DataContainer(text='', target_id=target_id, _id='') else: note_o = common_couch.getNote(holly_couch, note_id) return dict(note=note_o)
def save_note(self, target_id, _id, text): timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M') if _id == '': note_o = dict(type='note', _id=genUID(type='note'), target_id=target_id, note_state=0, tags=list(), history=list(), text='') note_change='new' note_o['timestamp'] = timestamp else: note_o = common_couch.getNote(holly_couch, _id) history = note_o['history'] if history == None: history = list() else: history.append([timestamp, note_o['text']]) note_o['history'] = history note_change = 'changed' note_o['last_changed_by'] = getLoggedInUserId(request) note_o['text'] = text holly_couch[note_o['_id']] = note_o remember_note_change(holly_couch, target_id=target_id, note_id=note_o['_id'], changed_by=getLoggedInUserId(request), note_change=note_change) # TODO: where do we go from here? redirect_to = '/' if 'visiting_group' in note_o['target_id']: redirect_to = '/visiting_group/show_visiting_group?visiting_group_id='+note_o['target_id'] raise redirect(redirect_to)