@handle_response_format
@treeio_login_required
def index(request, response_format='html'):
 profile = request.user.profile
 query = _get_filter_query(profile, filters=request.GET)
 updates = UpdateRecord.objects.filter(query).distinct()
 if request.POST:
  record = UpdateRecord()
  record.record_type = 'share'
  form = UpdateRecordForm(request.POST, user=profile, instance=record)
  if form.is_valid():
   record = form.save()
   record.body = record.body.replace('\n', ' <br />')
   record.save()
   record.set_user_from_request(request)
   return HttpResponseRedirect(reverse('news_index'))
 else:
  form = UpdateRecordForm(user=profile)
 if (response_format == 'rss'):
  return ObjectFeed(title=_('All Activity'), link=request.path, description=_('Updates on activity in your Tree.io'), objects=updates)(request)
 context = _get_default_context(request)
 context.update({'form': form, 'updates': updates, 'profile': profile})
 return render_to_response('news/index', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def index ( request , response_format = 'html' ) : profile = request . user . profile query = _get_filter_query ( profile , filters = request . GET ) updates = UpdateRecord . objects . filter ( query ) . distinct ( ) if request . POST : record = UpdateRecord ( ) record . record_type = 'share' form = UpdateRecordForm ( request . POST , user = profile , instance = record ) if form . is_valid ( ) : record = form . save ( ) record . body = record . body . replace ( '\n' , ' <br />' ) record . save ( ) record . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'news_index' ) ) else : form = UpdateRecordForm ( user = profile ) if ( response_format == 'rss' ) : return ObjectFeed ( title = _ ( 'All Activity' ) , link = request . path , description = _ ( 'Updates on activity in your Tree.io' ) , objects = updates ) ( request ) context = _get_default_context ( request ) context . update ( { 'form' : form , 'updates' : updates , 'profile' : profile } ) return render_to_response ( 'news/index' , context , context_instance = RequestContext ( request ) , response_format = response_format )
index -> int like find but raises valueerror when the substring is not found .