summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2012-02-09 22:20:20 +0100
committerLeif Johansson <leifj@sunet.se>2012-02-09 22:20:20 +0100
commit1b769af104c1d1c8d41cb6b0482c7eb67b7b8517 (patch)
tree3bb43208c27fc13989eb6ed85ace841b669b89bc /src
parent2b096fa2dd3d0c3f36ba94ead4a0b854c8e831a6 (diff)
new with-style api allocation for auth view
Diffstat (limited to 'src')
-rw-r--r--src/meetingtools/apps/auth/views.py1
-rw-r--r--src/meetingtools/apps/room/tasks.py46
2 files changed, 45 insertions, 2 deletions
diff --git a/src/meetingtools/apps/auth/views.py b/src/meetingtools/apps/auth/views.py
index 42c94bc..4ce8162 100644
--- a/src/meetingtools/apps/auth/views.py
+++ b/src/meetingtools/apps/auth/views.py
@@ -66,7 +66,6 @@ def join_group(group,**kwargs):
if gp:
api.add_member(principal.get('principal-id'),gp.get('principal-id'))
-
def leave_group(group,**kwargs):
user = kwargs['user']
acc = acc_for_user(user)
diff --git a/src/meetingtools/apps/room/tasks.py b/src/meetingtools/apps/room/tasks.py
index aea6b3b..aff5332 100644
--- a/src/meetingtools/apps/room/tasks.py
+++ b/src/meetingtools/apps/room/tasks.py
@@ -153,4 +153,48 @@ def import_recent_user_counts():
with ac_api_client(acc) as api:
then = datetime.now()-timedelta(seconds=600)
for room in Room.objects.filter((Q(lastupdated__gt=then) | Q(lastvisited__gt=then)) & Q(acc=acc)):
- api.poll_user_counts(room) \ No newline at end of file
+ api.poll_user_counts(room)
+
+# look for sessions that are newer than the one we know about for a room
+@periodic_task(run_every=crontab(hour="*", minute="*", day_of_week="*"))
+def import_sessions():
+ for room in Room.objects.all():
+ with ac_api_client(room.acc) as api:
+ p = {'sco-id': room.sco_id,'sort-date-created': 'asc'}
+ if room.lastvisited != None:
+ last = room.lastvisited
+ last.replace(microsecond=0)
+ p['filter-gt-date-created'] = last.isoformat()
+ r = api.request('report-meeting-sessions',p)
+ for row in r.et.xpath("//row"):
+ date_created = iso8601.parse_date(row.findtext("date-created"))
+ logging.debug("sco_id=%d lastvisited: %s" % (room.sco_id,date_created))
+ room.lastvisited = date_created
+ room.save()
+ break
+
+#@periodic_task(run_every=crontab(hour="*", minutes="*/5", day_of_week="*"))
+def import_transactions():
+ for acc in ACCluster.objects.all():
+ then = datetime.now() - timedelta(seconds=600)
+ then = then.replace(microsecond=0)
+ with ac_api_client(acc) as api:
+ seen = {}
+ r = api.request('report-bulk-consolidated-transactions',{'filter-type':'meeting','sort-date-created': 'asc','filter-gt-date-created': then.isformat()})
+ for row in r.et.xpath("//row"):
+ sco_id = row.get('sco-id')
+ logging.debug("last session for sco_id=%d" % sco_id)
+ if not seen.get(sco_id,False): #pick the first session for each room - ie the one last created
+ seen[sco_id] = True
+ try:
+ room = Room.objects.get(acc=acc,sco_id=sco_id)
+ date_created = iso8601.parse_date(row.findtext("date-created"))
+ room.lastvisited = date_created
+ room.save()
+ except ObjectDoesNotExist:
+ pass # we only care about rooms we know about here
+
+def clean_old_rooms():
+ for acc in ACCluster.objects.all():
+ then = datetime.now() - timedelta(days=365)
+ then = then.replace(microsecond=0) \ No newline at end of file