From 173135d089ee9949b41eeed8070664963d80e311 Mon Sep 17 00:00:00 2001 From: Bryce Boe Date: Tue, 15 Jan 2013 18:51:03 -0800 Subject: [PATCH] Provide developer-friendly attributes in the modaction json. --- r2/r2/lib/jsontemplates.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index 01005bfee4..7c78978bc0 100755 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -720,10 +720,20 @@ def thing_attr(self, thing, attr): class ModActionTemplate(ThingJsonTemplate): _data_attrs_ = dict(sr_id36='sr_id36', mod_id36='mod_id36', + id='_fullname', + subreddit='sr_name', + mod='author', + created_utc='date', action='action', details='details', description='description', target_fullname='target_fullname') + def thing_attr(self, thing, attr): + if attr == 'date': + return (time.mktime(thing.date.astimezone(pytz.UTC).timetuple()) + - time.timezone) + return ThingJsonTemplate.thing_attr(self, thing, attr) + def kind(self, wrapped): return 'modaction'