Exemple #1
0
def decide_offer():
  #Display the property which the user owns and existing offer on the property via inner join
  #Selecting the property that has an offer that is owned by current customer
  myQ = "SELECT a.address, b.decision, b.amtsold from properties a inner join offers b on a.property_id=b.property_id where b.cust_id =" + current_user.user_id()
  myD = db.get_from_db(myQ)
  decision = myD[0][1] #Get the decision of property from offers table

  if (decision >= 1):
    eg.msgbox(msg="No current offers.")

  elif (decision == 0):
    query = "SELECT a.property_type, a.address, a.MINprice, b.bid, b.amtsold, a.property_id FROM properties a inner join offers b on a.user="******"Property Type: " + str(property_type) + "\n" + "Address: " + str(address) + "\n" + "Minimum Price: " + str(minprice) + "\n" + "Bid: " + str(bid) + "\n" + "Maximum Bid: " + str(amtsold) + "\n"

    text = "Accept or Reject Existing Offer?"
    choices = ["Accept", "Reject"]
    reply=eg.boolbox(msg, title=text, choices=choices) #Boolbox returns 1 if the first button is chosen. Otherwise returns 0.

    #If offer is accepted
    if (reply == 1):
      eg.msgbox(msg="Offer Accepted")
      acceptoffer = "UPDATE offers set decision=1 where cust_id=" + current_user.user_id()
      db.add_to_db(acceptoffer)
    #If offer is rejected
    if (reply == 0):
      eg.msgbox(msg="Offer Rejected")
      rejectoffer = "UPDATE offers set decision=3 where cust_id=" + current_user.user_id()
      db.add_to_db(rejectoffer)
Exemple #2
0
def update_news():
    news = get_news()
    rows = s.query(News).all()
    for n in news:
        flag = True
        for row in rows:
            if n['title'] == row.title:
                flag = False
                break
        if flag:
            add_to_db(n)

    redirect("/news")
Exemple #3
0
def make_offer(prop_id):
  query = "SELECT address, MINprice, MAXprice FROM properties WHERE property_id =" + str(prop_id)
  minprice = query[1]
  address = query[0]
  msg = "How much would like to offer? (Minimum offer is: $ " + minprice +")"
  form = eg.enterbox(msg=msg, title="Make An Offer For" + str(address), default='', strip=True)

  insert_offer = ''

  if (form):
    insert_offer = "INSERT INTO offers (property_id, cust_id, bid) VALUES (" + wrap(prop_id) + wrap(current_user.user_id()) + wrap(form)

  insert_offer = insert_offer[:-2] + ")"

  db.add_to_db(insert_offer)
Exemple #4
0
def add_property():
    global current_user
    msg = "Please enter the following details to add a listing:"
    error_msg = ""
    title = "Add a listing"
    fieldNames = [
        "Address",
        "City",
        "Zip",
        "Type",
        "Bedrooms",
        "Bathrooms",
        "Area (sqft)",
        "Lotsize (sqft)",
        "Min. Price",
        "Max Price",
    ]
    fieldValues = []
    form = eg.multenterbox(msg, title, fieldNames, values=fieldValues)

    entries = {}
    for i in range(len(form)):
        if form[i]:
            entries[str(fieldNames[i])] = form[i].strip()

    address = form[0]
    city = form[1]
    zipcode = form[2]
    property_type = form[3]
    bedrooms = form[4]
    bathrooms = form[5]
    sqft = form[6]
    lotsize = form[7]
    minprice = form[8]
    maxprice = form[9]
    fieldList = [address, city, zipcode, property_type, bedrooms, bathrooms, sqft, minprice, maxprice]
    fields = "(address, city, zipcode, property_type, bedrooms, bathrooms, sqft, MINprice, MAXprice, user)"
    query = "INSERT INTO properties" + fields + " VALUES ("
    values = ""

    for field in fieldList:
        values += wrap(field)

    values = values[:-2]
    values = values + ", " + current_user.user_id()
    query += values + ")"

    db.add_to_db(str(query))
Exemple #5
0
def add_or_update():
    try:
        userid, serverid, img_url = request.json["userId"], request.json[
            "serverId"], request.json["image"]
        img = reco.get_image_from_url(img_url)
        if img is None:
            return jsonify({
                "status":
                "fail",
                "message":
                "Error in parsing the image from request."
            })
        encodings = reco.get_encoding(img)
        if len(encodings) != 1:
            return jsonify({
                "status":
                "fail",
                "message":
                "Zero or more than one face found in image."
            })
        encoding = encodings[0]
        reco.save_encoding(userid, serverid, encoding)
        msg = db.add_to_db(userid, serverid, encoding)
        return jsonify({
            "status": "success",
            "userid": userid,
            "serverid": serverid,
            "message": msg
        })
    except:
        return jsonify({
            "status": "fail",
            "message": "Error in saving image encoding."
        })
Exemple #6
0
def submit_notification(event):
    body = json.loads(event["body"])
    data = get_classutil()

    captcha = body["captcha"]
    ip = event["requestContext"]["identity"]["sourceIp"]
    if not recaptcha.verify(captcha, ip):
        return send_error("CaptchaFailed", 400)

    if len(body["sections"]) > MAX_COURSES:
        return send_error("TooManySections", 400)
    for i in body["sections"]:
        if not validate_section(data, i):
            return send_error("InvalidSection", 400)

    # commit to dynamodb
    add_to_db(body["email"], body["sections"])
    return send_response(True)
Exemple #7
0
def make_offer(prop_id):
  #Get the details of property
  query = "SELECT address, MINprice, MAXprice FROM properties WHERE property_id =" + str(prop_id)
  prop = db.get_from_db(query)
  address = prop[0][0]
  minprice = prop[0][1]

  msg = "How much would like to offer? (Minimum offer is: $ " + str(minprice) +")" #Add min price to message
  form = eg.enterbox(msg=msg, title="Make An Offer For" + str(address), default='', strip=True) #Add address to title

  insert_offer = ''

  if (form): #If anything is entered to form
    #Add offer to database
    insert_offer = "INSERT INTO offers (property_id, cust_id, bid) VALUES (" + wrap(prop_id) + wrap(current_user.user_id()) + wrap(form)

  insert_offer = insert_offer[:-2] + ")" #-2 to remove excess )'; add ) to end query

  db.add_to_db(insert_offer)
Exemple #8
0
def make_offer(prop_id):
    query = "SELECT address, MINprice, MAXprice FROM properties WHERE property_id =" + str(prop_id)
    minprice = query[1]
    address = query[0]
    msg = "How much would like to offer? (Minimum offer is: $ " + minprice + ")"
    form = eg.enterbox(msg=msg, title="Make An Offer For" + str(address), default="", strip=True)

    insert_offer = ""

    if form:
        insert_offer = (
            "INSERT INTO offers (property_id, cust_id, bid) VALUES ("
            + wrap(prop_id)
            + wrap(current_user.user_id())
            + wrap(form)
        )

    insert_offer = insert_offer[:-2] + ")"

    db.add_to_db(insert_offer)
Exemple #9
0
def create_user():
  global current_user
  msg = "Please enter the new account details:"
  error_msg= ''
  title = "Create New User"
  fieldNames = ["First Name:", "Last Name:", "Phone Number:", "Email:", "Password:"******"(fname, lname, phone_number, password, cust_email)"

  #Prepare a query to be sent to SQL
  query = "INSERT INTO customer" + fields + "VALUES ("
  values = ''   #Set up blank string that will be appended to query
  for field in fieldList: #Loop through each field and add to values
    values += wrap(field)  #Helper function to format string

  values = values[:-2] #-2 to remove excess )' from string
  query += values + ")" #End query

  db.add_to_db(str(query)) #Send query to database

  #Go back to database once user created to get the new user id
  query = "SELECT cust_id FROM customer where cust_email =" + "'"+str(cust_email)+"'"
  row = db.get_from_db(query)
  user_id = int(row[0][0])  #Selecting first row from list of rows

  current_user = User(user_id,fname,lname) #After the user registers, we instantiate the user object

  #After sign up is completed, we let them know via message:
  msg = "Thank you for logging in, " + current_user.name() + " \n Press ok to get started."
  eg.msgbox(msg)
Exemple #10
0
def create_user():
    global current_user
    msg = "Please enter the new account details:"
    error_msg = ""
    title = "Create New User"
    fieldNames = ["First Name:", "Last Name:", "Phone Number:", "Email:", "Password:"******"(fname, lname, phone_number, password, cust_email)"
    query = "INSERT INTO customer" + fields + "VALUES ("
    values = ""

    for field in fieldList:
        values += wrap(field)

    values = values[:-2]
    query += values + ")"

    db.add_to_db(str(query))

    query = "SELECT cust_id FROM customer where cust_email =" + "'" + str(cust_email) + "'"
    row = db.get_from_db(query)
    user_id = row[0]
    current_user = User(user_id, fname, lname)

    msg = "Thank you for logging in, " + current_user.name() + " \n Press ok to get started."
    eg.msgbox(msg)
Exemple #11
0
def create_user():
  global current_user
  msg = "Please enter the new account details:"
  error_msg= ''
  title = "Create New User"
  fieldNames = ["First Name:", "Last Name:", "Phone Number:", "Email:", "Password:"******"(fname, lname, phone_number, password, cust_email)"
  query = "INSERT INTO customer" + fields + "VALUES ("
  values = ''

  for field in fieldList:
    values += wrap(field)

  values = values[:-2]
  query += values + ")"

  db.add_to_db(str(query))

  query = "SELECT cust_id FROM customer where cust_email =" + "'"+str(cust_email)+"'"
  row = db.get_from_db(query)
  user_id = row[0]
  current_user = User(user_id,fname,lname)

  msg = "Thank you for logging in, " + current_user.name() + " \n Press ok to get started."
  eg.msgbox(msg)
Exemple #12
0
def add_property():
  global current_user
  msg = "Please enter the following details to add a listing:"
  error_msg = ''
  title = "Add a listing"
  fieldNames = ["Address", "City", "Zip", "Type", "Bedrooms", "Bathrooms", "Area (sqft)", "Lotsize (sqft)", "Min. Price", "Max Price" ]
  fieldValues = []
  form = eg.multenterbox(msg,title, fieldNames, values= fieldValues)

  entries = {}
  for i in range(len(form)):
    if form[i]:
      entries[str(fieldNames[i])] = form[i].strip()

  address = form[0]
  city = form[1]
  zipcode = form[2]
  property_type = form[3]
  bedrooms = form[4]
  bathrooms = form[5]
  sqft = form[6]
  lotsize = form[7]
  minprice = form[8]
  maxprice = form[9]
  fieldList = [address,city,zipcode,property_type,bedrooms,bathrooms,sqft, minprice, maxprice]
  fields = "(address, city, zipcode, property_type, bedrooms, bathrooms, sqft, MINprice, MAXprice, user)"
  query = "INSERT INTO properties" + fields + " VALUES ("
  values = ''

  for field in fieldList:
    values += wrap(field)

  values = values[:-2]
  values = values + ", " + current_user.user_id()
  query += values + ")"

  db.add_to_db(str(query))
Exemple #13
0
def add_property():
  global current_user
  msg = "Please enter the following details to add a listing:"
  error_msg = ''
  title = "Add a listing"
  fieldNames = ["Address", "City", "Zip", "Type", "Bedrooms", "Bathrooms", "Area (sqft)", "Lotsize (sqft)", "Min. Price", "Max Price" ]
  fieldValues = []
  form = eg.multenterbox(msg,title, fieldNames, values= fieldValues) #Easy_gui's form

  #Assign form elements to correct fields
  address = form[0]
  city = form[1]
  zipcode = form[2]
  property_type = form[3]
  bedrooms = form[4]
  bathrooms = form[5]
  sqft = form[6]
  lotsize = form[7]
  minprice = form[8]
  maxprice = form[9]
  fieldList = [address,city,zipcode,property_type,bedrooms,bathrooms,sqft, minprice, maxprice]
  fields = "(address, city, zipcode, property_type, bedrooms, bathrooms, sqft, MINprice, MAXprice, user)"

  #Prepare a query to be sent to SQL
  query = "INSERT INTO properties" + fields + " VALUES ("
  values = '' #Set up blank string that will be appended to query

  for field in fieldList:  #Loop through each field and add to values
    values += wrap(field)  #Helper function to format string

  values = values[:-2]  #-2 to remove excess )' from string
  values += ", " + current_user.user_id() +")"

  query += values

  db.add_to_db(str(query))
Exemple #14
0
# -*- coding: utf-8 -*-
import os

import requests

import db
from post import Post

baseUrl = os.environ['base_url']


def get_post_list():
    post_list = []
    for i in range(1, 5):
        new = baseUrl + f"page/{i}/limit/10/orderby/date/desc/0"
        page = requests.get(new)
        if page.status_code == 200:
            apps = page.json()['response']
            for post in apps:
                new_post = Post(post['id'], post)
                post_list.append(new_post)
    return post_list


if __name__ == '__main__':
    fetched = get_post_list()
    db.add_to_db(fetched)
Exemple #15
0
log = log.Log()

newest_scraped = scraping.scrape_latest_data()
newest_from_db = db.get_last_stat()

if newest_scraped != newest_from_db:
    content = f"""\
    Here are the newest statistics:
    Date: {newest_scraped.date}
    Healthy: {newest_scraped.healthy}
    Delta: {newest_scraped.delta}
    Cases: {newest_scraped.cases}
    """
    for recipient in recipients:
        mail.send_email(
            to_addr=recipient,
            subject="New COVID data received!",
            content=content,
            debug=config["DEBUG"].getboolean("DEBUG_MODE"),
        )
    db.add_to_db(
        newest_scraped.date,
        newest_scraped.cases,
        newest_scraped.healthy,
        newest_scraped.delta,
    )
    log.add("Changes found, emails sent")
else:
    log.add("Checked, no changes found")
Exemple #16
0
def handle_youtube(video_id):
    video.youtube_download(video_id)
    curr_video = video.get_youtube_video(video_id)
    hash_list = hashTest.get_hash_list(video_id)
    db.add_to_db(hash_list, "https://www.youtube.com/watch?v=" + video_id)
    return True