@handle_response_format
@treeio_login_required
def item_edit(request, knowledgeItem_id, response_format='html'):
 item = get_object_or_404(KnowledgeItem, pk=knowledgeItem_id)
 items = Object.filter_permitted(manager=KnowledgeItem.objects, user=request.user.profile, mode='r')
 if (not request.user.profile.has_permission(item, mode='w')):
  return user_denied(request, message="You don't have access to this Knowledge Item")
 if request.POST:
  if ('cancel' not in request.POST):
   form = KnowledgeItemForm(request.user.profile, None, request.POST, instance=item)
   if form.is_valid():
    item = form.save()
    return HttpResponseRedirect(reverse('knowledge_item_view', args=[item.folder.treepath, item.treepath]))
  else:
   return HttpResponseRedirect(reverse('knowledge_item_view', args=[item.folder.treepath, item.treepath]))
 else:
  form = KnowledgeItemForm(request.user.profile, None, instance=item)
 context = _get_default_context(request)
 context.update({'form': form, 'item': item, 'items': items})
 return render_to_response('knowledge/item_edit', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def item_edit ( request , knowledgeItem_id , response_format = 'html' ) : item = get_object_or_404 ( KnowledgeItem , pk = knowledgeItem_id ) items = Object . filter_permitted ( manager = KnowledgeItem . objects , user = request . user . profile , mode = 'r' ) if ( not request . user . profile . has_permission ( item , mode = 'w' ) ) : return user_denied ( request , message = "You don't have access to this Knowledge Item" ) if request . POST : if ( 'cancel' not in request . POST ) : form = KnowledgeItemForm ( request . user . profile , None , request . POST , instance = item ) if form . is_valid ( ) : item = form . save ( ) return HttpResponseRedirect ( reverse ( 'knowledge_item_view' , args = [ item . folder . treepath , item . treepath ] ) ) else : return HttpResponseRedirect ( reverse ( 'knowledge_item_view' , args = [ item . folder . treepath , item . treepath ] ) ) else : form = KnowledgeItemForm ( request . user . profile , None , instance = item ) context = _get_default_context ( request ) context . update ( { 'form' : form , 'item' : item , 'items' : items } ) return render_to_response ( 'knowledge/item_edit' , context , context_instance = RequestContext ( request ) , response_format = response_format )
item edit page .