Example #1
0
    def test_check_recent_fb_json(self):
        facebookdata = [{
                 "id": "5",
                 "name": "Off the Grid: North Berkeley (Sunday Dinner)",
                 "description": "Every Sunday from 5pm to 9pm, grab bites from a rotating list of 8-10 artisanal street food vendors.\n\nLocation: Corner of Delaware and Sacramento St \u0040 North Berkeley Bart Station \n\nTime: Sundays from 5pm to 8pm - Launching this Sunday, February 9th \nDownload Off the Grid App for amenities around this market! http://offthegridsf.com/app",
                 "start_time": "2015-08-05T17:00:00-0700",
                 "location": "UC Berkeley",
                  },
                {
                 "id": "75",
                 "name": "Off the Grid: North Oakland (Friday Dinner)",
                 "description": "Every Tuesday from 5pm to 9pm, grab bites from a rotating list of 8-10 artisanal street food vendors.\n\nLocation: Corner of Delaware and Sacramento St \u0040 North Berkeley Bart Station \n\nTime: Sundays from 5pm to 8pm - Launching this Sunday, February 9th \nDownload Off the Grid App for amenities around this market! http://offthegridsf.com/app",
                 "start_time": "2015-08-04T17:00:00-0700",
                 "location": "Bart Station, 1750 Sacramento Street, Berkeley CA"
                },
                {
                 "id": "72",
                 "name": "Off the Grid: North San Franciso (Monday Dinner)",
                 "description": "Every Monday from 5pm to 9pm, grab bites from a rotating list of 8-10 artisanal street food vendors.\n\nLocation: Corner of Delaware and Sacramento St \u0040 North Berkeley Bart Station \n\nTime: Sundays from 5pm to 8pm - Launching this Sunday, February 9th \nDownload Off the Grid App for amenities around this market! http://offthegridsf.com/app",
                 "start_time": "2015-08-01T17:00:00-0700",
                 "location": " Mall, 22 Donner Street, SF CA"
                }]

        create_event_models([{
             "id": "725197847591760",
             "cover": {
                "cover_id": "1012103818809849",
                "offset_x": 0,
                "offset_y": 0,
                "source": "https://scontent.xx.fbcdn.net/hphotos-xtf1/v/t1.0-9/s720x720/11694763_1012103818809849_5115312729383944165_n.jpg?oh=a5d0b6034afaef28beffebfca765c81e&oe=5656B661",
                "id": "1012103818809849"
             },
             "name": "Off the Grid: Berkeley (Sunday Dinner)",
             "description": "Every Sunday from 5pm to 9pm, grab bites from a rotating list of 8-10 artisanal street food vendors.\n\nLocation: Corner of Delaware and Sacramento St \u0040 North Berkeley Bart Station \n\nTime: Sundays from 5pm to 8pm - Launching this Sunday, February 9th \nDownload Off the Grid App for amenities around this market! http://offthegridsf.com/app",
             "start_time": "2015-08-02T17:00:00-0700",
             "location": " North Berkeley Bart Station, 1750 Sacramento Street, Berkeley CA",
             "end_time": "2015-08-02T21:00:00-0700"
          },
          {
             "id": "725197847591760",
             "cover": {
                "cover_id": "1012103818809849",
                "offset_x": 0,
                "offset_y": 0,
                "source": "https://scontent.xx.fbcdn.net/hphotos-xtf1/v/t1.0-9/s720x720/11694763_1012103818809849_5115312729383944165_n.jpg?oh=a5d0b6034afaef28beffebfca765c81e&oe=5656B661",
                "id": "1012103818809849"
             },
             "name": "Off the Grid: Berkeley (Sunday Dinner)",
             "description": "Every Sunday from 5pm to 9pm, grab bites from a rotating list of 8-10 artisanal street food vendors.\n\nLocation: Corner of Delaware and Sacramento St \u0040 North Berkeley Bart Station \n\nTime: Sundays from 5pm to 8pm - Launching this Sunday, February 9th \nDownload Off the Grid App for amenities around this market! http://offthegridsf.com/app",
             "start_time": "2015-07-22T17:00:00-0700",
             "location": " North Berkeley Bart Station, 1750 Sacramento Street, Berkeley CA",
             "end_time": "2015-07-22T21:00:00-0700"
          }
        ]) 

        newestdata = check_recent_fb_json(facebookdata)         
        self.assertEqual(len(newestdata), 2)
Example #2
0
 def test_remove_ol(self):
     added = [{
              "id": "725197847591760",
              "cover": {
                 "cover_id": "1012103818809849",
                 "offset_x": 0,
                 "offset_y": 0,
                 "source": "https://scontent.xx.fbcdn.net/hphotos-xtf1/v/t1.0-9/s720x720/11694763_1012103818809849_5115312729383944165_n.jpg?oh=a5d0b6034afaef28beffebfca765c81e&oe=5656B661",
                 "id": "1012103818809849"
              },
              "name": "Off the Grid: North Berkeley (Sunday Dinner)",
              "description": "Every Sunday from 5pm to 9pm, grab bites from a rotating list of 8-10 artisanal street food vendors.\n\nLocation: Corner of Delaware and Sacramento St \u0040 North Berkeley Bart Station \n\nTime: Sundays from 5pm to 8pm - Launching this Sunday, February 9th \nDownload Off the Grid App for amenities around this market! http://offthegridsf.com/app",
              "start_time": "2015-08-02T17:00:00-0700",
              "location": " North Berkeley Bart Station, 1750 Sacramento Street, Berkeley CA",
              "end_time": "2015-08-02T21:00:00-0700"
           },
           {
              "id": "1474801892813940",
              "cover": {
                 "cover_id": "1012103752143189",
                 "offset_x": 0,
                 "offset_y": 0,
                 "source": "https://scontent.xx.fbcdn.net/hphotos-xpt1/v/t1.0-9/11140228_1012103752143189_5894681009158221868_n.jpg?oh=6e1de6957ee86e541adb8aea5cd70b19&oe=5615D011",
                 "id": "1012103752143189"
              },
              "name": "OtG: San Jose \u0040 Evergreen Village Square",
              "description": "Off the Grid is joining the weekend fun at Evergreen Village Square. Bringing food trucks, live music and special programming, Off the Grid is ready to fill the Saturday void between Music, Art & Wine Friday nights and the Sunday Farmer's Markets. Look out for special collaborations with \nSan Jose Made (SJMADE) as we feature local makers through live cooking demos & more!\n\nWhere: 4075 Evergreen Village Square, San Jose\n\nWhen: Saturday, 11:00 a.m. \u2013 3:00 p.m.\n\nFood Truck Lineup (Subject to Change, Alternates every other week): Los Tolucas taco truck, Hula Truck, Baby Brothers BBQ, Big Ed's Buzzard BBQ, We Sushi, 3 Brothers, Dil Se, Curry Up Now, Baba Kabob, Cluck It Up, Hongry Kong, Lobsta Truck, Drewski's, Grilled Cheese Bandits, Hela Gela, Swifty Sweets",
              "start_time": "2015-08-01T11:00:00-0700",
              "location": "4075 Evergreen Village Square, San Jose",
              "end_time": "2015-08-01T15:00:00-0700"
           },
           {
              "id": "1473614082953030",
              "cover": {
                 "cover_id": "1012103788809852",
                 "offset_x": 0,
                 "offset_y": 0,
                 "source": "https://scontent.xx.fbcdn.net/hphotos-xtf1/v/l/t1.0-9/s720x720/11742643_1012103788809852_7285968984666024747_n.jpg?oh=0a1d9b072fe440c634c36f983bb27939&oe=5619AE80",
                 "id": "1012103788809852"
              },
              "name": "Off the Grid: Novato \u0040 Vintage Oaks (Thursday Dinner)",
              "description": "Welcome to our northernmost location, OtG: Novato \u0040 Vintage Oaks! We'll be here to bring you delicious food truck dinners every Thursday from 5-9pm.\n\nLocation: 201 Vintage Way, Novato CA\nTime: Every Thursday, 5:00 p.m. to 9:00 p.m.",
              "start_time": "2015-03-30T17:00:00-0700",
              "location": "201 Vintage Way, Novato CA",
              "end_time": "2015-03-30T21:00:00-0700"
             }]
   
     create_event_models(added) 
     check_db()
     current_db_data = Event.objects.all()
     self.assertEqual(len(current_db_data), 2)
Example #3
0
def eventsview(request):
    check_db()
    if len(Vendor.objects.all()) == 0:
        content = read_data("http://offthegridsf.com/vendors#food")
        vendors = parse_HTML(content)
        create_vendor_models(vendors)
    fb_data = read_data(facebookurl)
    if len(Event.objects.all()) > 0 and fb_data != "ERROR":
        event_data_ready = check_recent_fb_json(fb_data["data"])
        create_event_models(event_data_ready)
        establish_relation()
    elif fb_data != "ERROR":
        print "WERE here"
        next_parameter = fb_data["paging"]["cursors"]["after"]
        next_set = transform_url(facebookurl, next_parameter)
        second = read_data(next_set)
        fulldata = fb_data["data"] + second["data"]
        events = check_less_thirty(fulldata)
        create_event_models(events)
        establish_relation()
    event_list = Event.objects.all().order_by("-event_time")
    context_dict = {"events": event_list}
    return render(request, "GingerBites/events.html", context_dict)