Пример #1
0
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))
Пример #2
0
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))       
Пример #3
0
 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
Пример #4
0
 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],
             }
Пример #5
0
 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
Пример #6
0
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)
Пример #7
0
 def basic_data(self, anon=True):
     return {'date': date_to_timestamp(self.date),
             'id': self.id,
             'title': self.title}
Пример #8
0
 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}
Пример #9
0
 def get_timestamp(self):
     return date_to_timestamp(datetime(self.date.year, 
                                         self.date.month, 
                                         self.date.day, 
                                         self.hour))