@handle_response_format
@treeio_login_required
def weblink_add(request, response_format='html'):
 if request.POST:
  if ('cancel' not in request.POST):
   link = WebLink()
   form = WebLinkForm(request.user.profile, None, request.POST, instance=link)
   if form.is_valid():
    link = form.save()
    link.set_user_from_request(request)
    return HttpResponseRedirect(reverse('documents_weblink_view', args=[link.id]))
  else:
   return HttpResponseRedirect(reverse('document_index'))
 else:
  form = WebLinkForm(request.user.profile, None)
 context = _get_default_context(request)
 context.update({'form': form, 'file': file})
 return render_to_response('documents/weblink_add', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def weblink_add ( request , response_format = 'html' ) : if request . POST : if ( 'cancel' not in request . POST ) : link = WebLink ( ) form = WebLinkForm ( request . user . profile , None , request . POST , instance = link ) if form . is_valid ( ) : link = form . save ( ) link . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'documents_weblink_view' , args = [ link . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'document_index' ) ) else : form = WebLinkForm ( request . user . profile , None ) context = _get_default_context ( request ) context . update ( { 'form' : form , 'file' : file } ) return render_to_response ( 'documents/weblink_add' , context , context_instance = RequestContext ( request ) , response_format = response_format )
new web link form .