def gimme_json_for_portfolio(request):
 "JSON includes:\n        * The person's data.\n        * other stuff"
 if (not request.user.is_authenticated()):
  return HttpResponseServerError("Oops, you're not logged in.")
 person = request.user.get_profile()
 citations = list(Citation.untrashed.filter(portfolio_entry__person=person))
 portfolio_entries_unserialized = PortfolioEntry.objects.filter(person=person, is_deleted=False)
 projects_unserialized = [p.project for p in portfolio_entries_unserialized]
 summaries = {}
 for c in citations:
  summaries[c.pk] = render_to_string('profile/portfolio/citation_summary.html', {'citation': c})
 five_minutes_ago = (datetime.datetime.utcnow() - datetime.timedelta(minutes=5))
 portfolio_entries = json.loads(serializers.serialize('json', portfolio_entries_unserialized))
 projects = json.loads(serializers.serialize('json', projects_unserialized))
 citations = json.loads(serializers.serialize('json', citations))
 portfolio_json = json.dumps({'citations': citations, 'portfolio_entries': portfolio_entries, 'projects': projects, 'summaries': summaries})
 return HttpResponse(portfolio_json, mimetype='application/json')

def gimme_json_for_portfolio ( request ) : if ( not request . user . is_authenticated ( ) ) : return HttpResponseServerError ( "Oops, you're not logged in." ) person = request . user . get_profile ( ) citations = list ( Citation . untrashed . filter ( portfolio_entry__person = person ) ) portfolio_entries_unserialized = PortfolioEntry . objects . filter ( person = person , is_deleted = False ) projects_unserialized = [ p . project for p in portfolio_entries_unserialized ] summaries = { } for c in citations : summaries [ c . pk ] = render_to_string ( 'profile/portfolio/citation_summary.html' , { 'citation' : c } ) five_minutes_ago = ( datetime . datetime . utcnow ( ) - datetime . timedelta ( minutes = 5 ) ) portfolio_entries = json . loads ( serializers . serialize ( 'json' , portfolio_entries_unserialized ) ) projects = json . loads ( serializers . serialize ( 'json' , projects_unserialized ) ) citations = json . loads ( serializers . serialize ( 'json' , citations ) ) portfolio_json = json . dumps ( { 'citations' : citations , 'portfolio_entries' : portfolio_entries , 'projects' : projects , 'summaries' : summaries } ) return HttpResponse ( portfolio_json , mimetype = 'application/json' )
get json used to live-update the portfolio editor .