Example #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))
Example #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))       
Example #3
0
def get_ad_data_json(ad_type, pk, anon=True):
    adobject_class = ad_class_for_type(ad_type)
    if not adobject_class:
        return json_error("Not found: %s %s" % (ad_type, pk))
    try:
        adobject = adobject_class.objects.get(pk=pk)
    except adobject_class.DoesNotExist:
        return json.dumps(
            {'type':'error', 'message':'%s not found: %s' % (ad_type, pk)})
    adobject_data = adobject.detail_data(anon=anon)
    return json.dumps(adobject_data)