예제 #1
0
def add_venue(venue, superCategory):
    details = request_description(venue['id'])

    address, url, subCategory = None, None, None
    if 'address' in venue['location']:
        address = venue['location']['address']
    if 'url' in venue:
        url = venue['url']
    if venue['categories'] != []:
        subCategory = venue['categories'][0]['name']

    v = Venue.objects.get_or_create(name = venue['name'],
        description = details[0],
        default_image = details[1],
        coordinate = str(venue['location']['lat']) + "," + str(venue['location']['lng']),
        raw_data = str(venue),
        source = "Foursquare",
        unique_id = venue['id'],
        created_at = timezone.now(),
        updated_at = timezone.now(),
        url = url,
        address = address,
        super_category = superCategory,
        sub_category = subCategory,
        rating = details[2],
        review = str(details[3]),
        )[0]
    v.save()

    return (v.id, details[3])
예제 #2
0
def update_venue(venue):
    details = request_description(venue['id'])

    target = Venue.objects.filter(unique_id = venue['id'])[0]
    target.raw_data = str(venue)
    target.rating = details[2]
    target.review = str(details[3])
    target.updated_at = timezone.now()

    Review.objects.filter(venue_id = target.id).delete() # delete old reviews

    return (target.id, details[3])