Пример #1
0
def updateFoodTrucks():
  events = getFacebookEvents()
  if events:
    # This will not create duplicates, will update existing
    FacebookEvent.saveFromFacebookData(events)
    return True
  else:
    return False
Пример #2
0
def index(request):
  upcoming_food_truck = FacebookEvent.getUpcomingFoodtruck(datetime.date.today(), config.LOCATION)
  template = loader.get_template('index.html')
  context = Context({
      'upcoming_food_truck': upcoming_food_truck,
  })
  return HttpResponse(template.render(context))
Пример #3
0
def sendHipChatUpdate():
  token = config.HIPCHAT_TOKEN
  room_id = config.HIPCHAT_ROOMID
  location = config.LOCATION

  todays_date = datetime.date.today()
  event = FacebookEvent.getUpcomingFoodtruck(todays_date, location)

  if event:
    hipster = hipchat.HipChat(token=token)
    message = event.generateHipChatMessage(todays_date)
    res = hipster.message_room(room_id, 'NomNomNom', message)

    if res and 'status' in res and res['status'] == 'sent':
      return (True, "Sent Successfully")
    else:
      return (False, res['status'])

  return (False, "No upcoming food trucks found")