Exemple #1
0
def le(acme):
    ds = get_ds()
    try:
        acme_challenge = ds.get(ds.key("credential", acme))
        return Response(acme_challenge['token'], mimetype = "text/plain")
    except:
        return Response("Error", mimetype = "text/plain")
Exemple #2
0
def order_page():
    bcs = OrderedDict([("Strain", "/strain/"), ("Order", "")])
    title = "Order"
    strain_listing = list(set(request.form.getlist('item')))
    if (len(strain_listing) == 0):
        return redirect(url_for("strain_listing_page"))
    items = request.form.getlist("item")
    # Retreive SKU's for prices
    items = calculate_total(items)
    total = sum(items.values())
    field_list = ['name', 'phone', 'email', 'shipping_service', 'address']
    if 'shipping_service' in request.form:
        # Check that all pieces are filled out.
        missing_fields = []
        for i in field_list:
            if i in request.form:
                if not request.form[i]:
                    missing_fields.append(i)
                    warning = "Missing Some Fields"
        if len(missing_fields) == 0:
            ds = get_ds()
            o = ds.get(ds.key("cendr-order", "count"))
            o["order-number"] += 1
            ds.put(o)
            order = {}
            for k in field_list:
                order[k] = request.form[k]
            order['items'] = '\n'.join(sorted([u"{k}:{v}".format(k=k, v=v) for k,v in items.items()]))
            order['shipping_service'] = request.form['shipping_service']
            order['total'] = total
            shipping = ""
            if order['shipping_service'] == '$65 Flat Fee':
                order['total'] += 65
                shipping = "\nShipping\n=========\n$65"
            order['date'] = datetime.now(pytz.timezone("America/Chicago"))
            order['order_number'] = o['order-number']
            order['is_donation'] = False
            order['date'] = datetime.now(pytz.timezone("America/Chicago")).date().isoformat()
            order['invoice_hash'] = hashlib.sha1(str(order)).hexdigest()[0:10]
            order["url"] = "http://elegansvariation.org/order/" + order["invoice_hash"]
            mail.send_mail(sender="CeNDR <*****@*****.**>",
               to=order["email"],
               cc=['*****@*****.**', '*****@*****.**', '*****@*****.**'],
               subject="CeNDR Order #" + str(order["order_number"]),
               body=order_submission.format(invoice_hash=order['invoice_hash'],
                                            name=order['name'],
                                            address=order['address'],
                                            items=order['items'],
                                            total=order['total'],
                                            date=order['date'],
                                            shipping=shipping))

            # Save to google sheet
            add_to_order_ws(order)

            return redirect(url_for("order_confirmation", invoice_hash=order['invoice_hash']), code=302)
        
    return render_template('order.html', **locals())
Exemple #3
0
def donate():
    # Process donation.
    if request.form:
        ds = get_ds()
        donation_amount = str(int(request.form['donation_amount']))
        o = ds.get(ds.key("cendr-order", "count"))
        o["order-number"] += 1
        ds.put(o)
        order = {}
        order["order_number"] = o["order-number"]
        order["email"] = request.form["email"]
        order["address"] = request.form["address"]
        order["name"] = request.form["name"]
        order["items"] = u"{k}:{v}".format(k = "CeNDR strain and data support", v = donation_amount)
        order["total"] = donation_amount
        order["is_donation"] = True
        order["date"] = datetime.now(pytz.timezone("America/Chicago")).date().isoformat()
        order["invoice_hash"] = hashlib.sha1(str(order)).hexdigest()[0:10]
        order["url"] = "http://elegansvariation.org/order/" + order["invoice_hash"]
        from google.appengine.api import mail
        mail.send_mail(sender="CeNDR <*****@*****.**>",
           to=order["email"],
           cc=['*****@*****.**', '*****@*****.**', '*****@*****.**'],
           subject="CeNDR Order #" + str(order["order_number"]),
           body=donate_submission.format(invoice_hash=order["invoice_hash"],
                                         donation_amount=donation_amount))

        add_to_order_ws(order)

        return redirect(url_for("order_confirmation", invoice_hash=order["invoice_hash"]), code=302)
    

    from google.appengine.api import mail
    title = "Donate"
    bcs = OrderedDict([("About", url_for("about")), ("Donate", None)])
    return render_template('donate.html', **locals())
Exemple #4
0
    def get_ds():
        return datastore.Client(project="andersen-lab")
try:
    import MySQLdb
    import _mysql
except:
    import pymysql
    pymysql.install_as_MySQLdb()

current_build = 20160408

if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
    dbname = "cegwas_v2" # don't remove, imported elsewhere.
    db = MySQLDatabase(dbname, unix_socket='/cloudsql/andersen-lab:cegwas-data', user='******')
else:
    ds = get_ds()
    credentials = dict(ds.get(ds.key("credential", "cegwas-data")))
    dbname = "cegwas_v2" # don't remove, imported elsewhere.
    db =  MySQLDatabase(
      dbname,
      **credentials
      )

db.connect()

class strain(Model):
    """
    
        C. Elegans strain information database
    """
    strain = CharField(index=True)