def human_relative_time(self,dt): """relative time with precision to the second""" if not dt: return '-' return shg_utils.prettydate(dt)
def recent_activity(self): ra = [] for h in HouseLog.query(ancestor=self.key).filter(HouseLog.when > datetime.now() + timedelta(days=-8)).\ order(-HouseLog.when): log_user = _user.User._get_user_from_id(h.user_id) if h.user_id else None a = {'who': log_user.get_first_name() if log_user else '' ,'when':prettydate(h.when) ,'desc':h.desc ,'points':h.points ,'link':h.link} ra.append(a) return ra
def points_log(self,days=31): pl = [] for h in self.pts_lg_obj: #if datetime.datetime.utcnow() + datetime.timedelta(days=-days) > h.when: # continue pr = points_remaining(h) if pr ==0 : continue a = {'when':prettydate(h.when) ,'desc':h.desc ,'points':pr}#points_remaining(h)} pl.append(a) return pl