- Presence = apps.get_model('team', 'Presence')
- Presence.report(request.user, doc, request.GET.get('a') == 'true')
- return http.HttpResponse(str(doc.revision()))
+
+ Presence.report(
+ request.user, request.session.session_key,
+ doc,
+ request.GET.get('a') == 'true'
+ )
+
+ # Temporary compat for unreloaded clients.
+ if not request.GET.get('new'):
+ return http.HttpResponse(str(doc.revision()))
+
+ return JSONResponse({
+ 'rev': doc.revision(),
+ 'people': list([
+ {
+ 'name': (p.user.first_name + ' ' + p.user.last_name) if p.user is not None else '?',
+ 'gravatar': get_gravatar_url(p.user.email if p.user is not None else '-', size=26),
+ 'since': p.since.strftime('%H:%M'),
+ 'active': p.active,
+ }
+ for p in Presence.get_current(request.session.session_key, doc)
+ ]),
+ })