Exemplo n.º 1
0
def add_spot(request):
  if request.method != "POST":
    raise Http404

  print request.FILES['fileField'].name
  img_url = s3_upload(request.FILES['fileField'], request.FILES['fileField'].name)
  print img_url

  message = Message(
    msg_type = request.POST['msg_type'],
    title = request.POST['title'],
    doc = request.POST['doc'],
    url = request.POST['url'],
    img_url = img_url,
    # start_time = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%dT%H:%M:%S'),
    # end_time = datetime.datetime.fromtimestamp(time.time() + 100000000).strftime('%Y-%m-%dT%H:%M:%S'),
    # category = request.POST['category'],
    # lock = bool(request.POST['lock']),
    # unlock_type = request.POST['unlock_type'],
    lat = float(request.POST['lat']),
    lng = float(request.POST['lng'])
  )
  message.save()

  return redirect(reverse('map'))
Exemplo n.º 2
0
def generate_mock_message(request):
  mock_objects = get_all()

  for obj in mock_objects:
    message = Message(
      msg_type = obj['msg_type'],
      title = obj['title'],
      doc = obj['doc'],
      url = obj['url'],
      img_url = obj['img_url'],
      start_time = datetime.datetime.fromtimestamp(obj['start_time']).strftime('%Y-%m-%dT%H:%M:%S'),
      end_time = datetime.datetime.fromtimestamp(obj['end_time']).strftime('%Y-%m-%dT%H:%M:%S'),
      category = obj['category'],
      lock = obj['lock'],
      unlock_type = obj['unlock_type'],
      lat = obj['lat'],
      lng = obj['lng']
    )
    message.save()

  return HttpResponse("mocking succeeded")
Exemplo n.º 3
0
def message_upload(request):
  if request.method != 'POST':
    raise Http404

  message = Message(
    msg_type = request.POST['msg_type'],
    title = request.POST['title'],
    doc = request.POST['doc'],
    url = request.POST['url'],
    img_url = request.POST['img_url'],
    start_time = datetime.datetime.fromtimestamp(long(request.POST['start_time'])/1000).strftime('%Y-%m-%dT%H:%M:%S'),
    end_time = datetime.datetime.fromtimestamp(long(request.POST['end_time'])/1000).strftime('%Y-%m-%dT%H:%M:%S'),
    category = request.POST['category'],
    lock = bool(request.POST['lock']),
    unlock_type = request.POST['unlock_type'],
    lat = float(request.POST['lat']),
    lng = float(request.POST['lng'])
  )
  message.save()

  return HttpResponse("message upload succeeded")