@handle_response_format
@treeio_login_required
def widget_news_index(request, response_format='html'):
 profile = request.user.profile
 query = (_get_filter_query(profile) & (((~ Q(author=profile)) | Q(record_type='share')) | Q(score__gt=0)))
 updates = UpdateRecord.objects.filter(query).distinct()
 if Widget.objects.filter(user=profile, widget_name='widget_news_social').exists():
  form = None
 elif 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('core_dashboard_index'))
 else:
  form = UpdateRecordForm(user=profile)
 context = _get_default_context(request)
 context.update({'form': form, 'updates': updates, 'profile': profile})
 return render_to_response('news/widgets/index', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def widget_news_index ( request , response_format = 'html' ) : profile = request . user . profile query = ( _get_filter_query ( profile ) & ( ( ( ~ Q ( author = profile ) ) | Q ( record_type = 'share' ) ) | Q ( score__gt = 0 ) ) ) updates = UpdateRecord . objects . filter ( query ) . distinct ( ) if Widget . objects . filter ( user = profile , widget_name = 'widget_news_social' ) . exists ( ) : form = None elif 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 ( 'core_dashboard_index' ) ) else : form = UpdateRecordForm ( user = profile ) context = _get_default_context ( request ) context . update ( { 'form' : form , 'updates' : updates , 'profile' : profile } ) return render_to_response ( 'news/widgets/index' , context , context_instance = RequestContext ( request ) , response_format = response_format )
widget: all activity .