def freeze_note(request, note_id): if request.method == 'GET': _note = Note(note_id) _entity_id = _note.get_entity_id() _entity = Entity(_entity_id) _entity.update_note(note_id=note_id, weight=-1) return HttpResponseRedirect(request.META['HTTP_REFERER'])
def run(self, user_id): _user_id = int(user_id) for _note_id in Note.find(user_id=_user_id, status=1): try: _note = Note(_note_id) _entity_id = _note.get_entity_id() _entity = Entity(_entity_id) _entity.update_note(note_id=_note_id, weight=-1) except Exception, e: pass logger.info("entity note [%d] of [%d] freezed..." % (_note_id, _user_id))
def edit_note(request, note_id): if request.method == 'GET': _note_context = Note(note_id).read() _entity_context = Entity(_note_context['entity_id']).read() return render_to_response( 'note/edit.html', { 'active_division': 'note', 'entity_context': _entity_context, 'note_context': _note_context, 'creator': User(_note_context['creator_id']).read() }, context_instance=RequestContext(request)) elif request.method == 'POST': _note_text = request.POST.get("note", None) _weight = int(request.POST.get("weight", '0')) _note = Note(note_id) _entity_id = _note.get_entity_id() _entity = Entity(_entity_id) _entity.update_note(note_id=note_id, note_text=_note_text, weight=_weight) return HttpResponseRedirect(request.META['HTTP_REFERER'])