Example #1
0
def home():

  sn = request.forms.get('spotNumber')
  hl = request.forms.get('headline')
  org = request.forms.get('organization')
  desc = request.forms.get('description')
  pw = request.forms.get('password')
  img_url = request.forms.get('image_url')
  #img = uploadImage(img_url)

  if isValidSpot(sn):
    snInt = int(sn)
    snInt = str(snInt)
    snDatabase = Occupant.get_by_id(snInt)
    if snDatabase == None:
      occupant = Occupant(id = snInt, headline = hl, description = desc, date_time = datetime.datetime.now(), spot_id = snInt, organization = org, spot_image = img_url, password = pw, report = 0)
      occupant.put()
     
      time.sleep(2)
      response.set_cookie("submittedForm", "yes")
      redirect('/')

    else:
      header = template('header', home="", vendor="active", edit="", about="")
      content = template('vendor', message = "*Sorry, the Spot Number entered has already been taken.*", sn = "", hl = hl, org = org, desc = desc, pw = pw)
      footer = template('footer',"")

      return header + content + footer

  else:
    header = template('header', home="", vendor="active", edit="", about="")
    content = template('vendor', message = "*Sorry, the spot number must be a valid spot number.*", sn = "", hl = hl, org = org, desc = desc, pw = pw)
    footer = template('footer',"")

    return header + content + footer
Example #2
0
def home():
  query = Occupant.query()
  tmp_vendors = convertVendors(query)
  vendors = {'vendors':tmp_vendors}

  #query = Spot.query()
  #query_spots = convertSpots(query)
  tmp_spots = []

  for v in tmp_vendors:
    spot = Spot.get_by_id(v['spot_id'])
    if spot != None:
      tmp = convertOneSpot(spot,v)
      tmp_spots.append(tmp)

  spots = {'spots':tmp_spots}

  header = template('header', home="active", vendor="", edit="", about="")
  content = template('buyer', vendors, spots)
  footer = template('footer',"")
  deleted = """
  <script>
    $(window).load(function() {
    alert("The spot entered and it's information has been deleted. \\n\\nThank you!");
    });
  </script>"""
  confirmation = """
  <script>
    $(window).load(function() {
    alert("Your reservation is complete! Please note that official reservations must be made through the Student Center and not through antTrails. Also, please note that the spots reset at 12am everyday. \\n\\nThank you!");
    });
  </script>
  """

  if request.get_cookie("submittedForm") == "yes":
    response.set_cookie("submittedForm", "no")
    content = template('buyer', vendors, spots)
    return header + content + footer + confirmation
  elif request.get_cookie("deleted") == "yes":  
    response.set_cookie("deleted", "no")
    content = template('buyer', vendors, spots)
    return header + content + footer + deleted
  else:
    return header + content + footer 
Example #3
0
from bottle import Bottle,route, run, template, static_file, get, post, request, redirect, response
from antTrailsDatabase import Occupant, Spot
from google.appengine.ext import ndb
import datetime, pyimgur, time

ndb.delete_multi(Occupant.query().fetch(keys_only=True))
return 250
Example #4
0
def home():
  o1 =  Occupant(id = "1", headline = "Selling chicken nuggets!", description = "Chicken nuggets! 5 for $1", date_time = datetime.datetime.now(), spot_id = "1", organization = "Circle K", spot_image = "", password = "", report = 0)
  o2 =  Occupant(id = "2", headline = "Free drinks!", description = "Answer a simple survey to get a free drink!", date_time = datetime.datetime.now(), spot_id = "2", organization = "Mahjong Club", spot_image = "", password = "", report = 0)
  o3 = Occupant(id = "3", headline = "Resume Critque", description = "Stop by to get your resume up in shape!", date_time = datetime.datetime.now(), spot_id = "3", organization = "Career Center", spot_image = "", password = "", report = 0)
  o4 = Occupant(id = "76", headline = "Study at our Booth!", description = "Come study with us at our booth and learn about stuff!", date_time = datetime.datetime.now(), spot_id = "76", organization = "Study Club", spot_image = "", password = "", report = 0)
  o5 = Occupant(id = "233", headline = "Boats", description = "Boats, Boats BOATS!!!", date_time = datetime.datetime.now(), spot_id = "233", organization = "Touch the Boat", spot_image = "", password = "", report = 0)
  o6 = Occupant(id = "314", headline = "Don't Smile at Strangers", description = "Have you ever wanted to see what goes on behind the Don't Smile at Strangers group meetings? Come by to find out! We're always happy to show you!", date_time = datetime.datetime.now(), spot_id = "314", organization = "INFX 151", spot_image = "", password = "", report = 0)
  o7 = Occupant(id = "106", headline = "ASUCI Elections", description = "Vote today!", date_time = datetime.datetime.now(), spot_id = "106", organization = "ASUCI", spot_image = "", password = "", report = 0)
  o1.put()
  o2.put()
  o3.put()
  o4.put()
  o5.put()
  o6.put()
  o7.put()

  return "Occupant Data successfully added!"
Example #5
0
def home():
  #if the user has not submitted the new editted form, it will enter this branch
  if request.get_cookie("edittingForm") == "no":
    sn = request.forms.get('spotNumber')
    pw = request.forms.get('password')

    if isValidSpot(sn):
      #gets rid of leading 0s
      snInt = int(sn)
      snInt = str(snInt)

      snDatabase = Occupant.get_by_id(snInt)

      if snDatabase == None:
        header = template('header', home="", vendor="", edit="active", about="")
        content = template('edit', message="*The entered Spot Number has not been reserved yet.")
        footer = template('footer',"")
        return header + content + footer
        
      else:
        if snDatabase.password == pw:
          #if the user chose to delete a spot, here they go!
          if request.forms.get("delete") == "Delete Spot":
            spot = Occupant.get_by_id(snInt)
            spot.key.delete()
            response.set_cookie("deleted", "yes")
            time.sleep(2)
            redirect('/')

          else:
            response.set_cookie("edittingForm", "yes")
            snInt = int(sn)
            snInt = str(snInt)
            response.set_cookie("originalSN", snInt)
            hl = snDatabase.headline
            org = snDatabase.organization
            desc = snDatabase.description

            header = template('header', home="", vendor="", edit="active", about="")
            content = template('vendor', message = "Spot Information has been loaded!", sn = sn, hl = hl, org = org, desc = desc, pw = pw)
            footer = template('footer',"")
            return header + content + footer

        else:
          header = template('header', home="", vendor="", edit="active", about="")
          content = template('edit', message="*Invalid Password")
          footer = template('footer',"")
          return header + content + footer

    else:
      header = template('header', home="", vendor="", edit="active", about="")
      content = template('edit', message = "*Sorry, the spot number must be a valid spot number.*")
      footer = template('footer',"")
      return header + content + footer

  #if the user has submitted a new editted spot form it will enter this branch
  #this branch is basically the check in vnedor that validates input
  else:
    sn = request.forms.get('spotNumber')
    hl = request.forms.get('headline')
    org = request.forms.get('organization')
    desc = request.forms.get('description')
    pw = request.forms.get('password')
    img_url = request.forms.get('image_url')

    if isValidSpot(sn):
      snInt = int(sn)
      snInt = str(snInt)
      snDatabase = Occupant.get_by_id(snInt)

      if snDatabase == None or snInt == str(request.get_cookie("originalSN")):
        occupant = Occupant(id = snInt, headline = hl, description = desc, date_time = datetime.datetime.now(), spot_id = snInt, organization = org, spot_image = img_url, password = pw, report = 0)
        occupant.put()

        #if the new spot number does not exist that means that changed the spot number
        #so the old can be deleted because it is being replaced
        if snDatabase == None:
          oldSpot = Occupant.get_by_id(str(request.get_cookie("originalSN")))
          oldSpot.key.delete()

        response.set_cookie("edittingForm", "no")
        response.set_cookie("originalSN", "no")

        time.sleep(2)
        response.set_cookie("submittedForm", "yes")
        redirect('/')

      else:
        header = template('header', home="", vendor="", edit="active", about="")
        content = template('vendor', message = "*Sorry, the Spot Number entered has already been taken.*", sn = "", hl = hl, org = org, desc = desc, pw = pw)
        footer = template('footer',"")

        return header + content + footer

    else:
      header = template('header', home="", vendor="", edit="active", about="")
      content = template('vendor', message = "*Sorry, the spot number must be a valid spot number.*", sn = "", hl = hl, org = org, desc = desc, pw = pw)
      footer = template('footer',"")

      return header + content + footer