def ad_details_json(user, start_time, end_time, anon=True): ad_data = ad_domain_data_for_period(user, start_time, end_time, anon=anon) if ad_data: ad_data['dates'] = {'start': date_to_timestamp(start_time), 'end': date_to_timestamp(end_time)} return json.dumps(ad_data) else: return json_error('No data for period: %s %s' % (start_time, end_time))
def ad_details_for_hour_json(user, hour, anon=True): start_time = hour end_time = hour + timedelta(hours=1) ad_data = ad_domain_data_for_period(user, start_time, end_time, anon=anon) if ad_data: ad_data['dates'] = {'start': date_to_timestamp(start_time), 'end': date_to_timestamp(end_time)} ad_data['hour'] = date_to_timestamp(hour) return json.dumps(ad_data) else: return json_error('No data for period: %s %s' % (start_time, end_time))
def basic_data(self, anon=True): data = {'id': self.id, 'date': date_to_timestamp(self.date), 'type': self.ad_type} if self.thumbfile and not anon: data['img'] = self.thumbfile return data
def detail_data(self, anon=True): return {'date': date_to_timestamp(self.date), 'type': 'fbsp', 'id': self.id, 'title': self.title, 'text': self.text, 'images': [i.thumbpath() for i in self.images.all() if i.thumbfile], }
def detail_data(self, anon=True, domain=True): data = {'id': self.id, 'date': date_to_timestamp(self.date), 'type': self.ad_type} if domain: data['domain'] = self.domain.ref_name(anon=anon) if self.ref_domain: data['ref'] = self.ref_domain.ref_name(anon=anon) if self.thumbfile and not anon: data['img'] = self.thumbfile return data
def activity_data_json(user, start_date, end_date, fbuser=None, anon=True): data = get_activity_for_period(user, start_date, end_date) jdata = {'dates': {'start': date_to_timestamp(start_date), 'end': date_to_timestamp(end_date)}, 'activity': [a.packed_data() for a in data]} return json.dumps(jdata)
def basic_data(self, anon=True): return {'date': date_to_timestamp(self.date), 'id': self.id, 'title': self.title}
def detail_data(self, anon=True): return {'date': date_to_timestamp(self.date), 'hour': self.hour, 'adtotal': self.adtotal, 'fbadtotal': self.fbadtotal, 'fbsptotal': self.fbsptotal}
def get_timestamp(self): return date_to_timestamp(datetime(self.date.year, self.date.month, self.date.day, self.hour))