diff options
| author | Clyhtsuriva Synck <clyhtsuriva> | 2020-03-01 15:14:15 +0100 |
|---|---|---|
| committer | Clyhtsuriva Synck <clyhtsuriva> | 2020-03-01 15:14:15 +0100 |
| commit | 703c1c623892d69d8e24af68b31d84495301ca02 (patch) | |
| tree | 743b32ed4cc4a5d597b4fbc5726e0c3e52bf7c7b /ajout.py | |
| parent | f33d24f47fa9d39e687d55cff1de9b4cc4ceb033 (diff) | |
| download | dynamicWebsite-Project-703c1c623892d69d8e24af68b31d84495301ca02.tar.gz dynamicWebsite-Project-703c1c623892d69d8e24af68b31d84495301ca02.tar.bz2 dynamicWebsite-Project-703c1c623892d69d8e24af68b31d84495301ca02.zip | |
initial files
Diffstat (limited to '')
| -rw-r--r-- | ajout.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ajout.py b/ajout.py new file mode 100644 index 0000000..952ca9b --- /dev/null +++ b/ajout.py @@ -0,0 +1,40 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from mod_python import Session +import fonctions +import psycopg2 +import geocodage + +def index(req): + req.content_type="text/html" + sess = Session.Session(req) + fonctions.redirectionSiNonConnecte(req,sess) + + nom=req.form['nom'] + adresse=req.form['adresse'] + email=req.form['email'] + telephone=req.form['telephone'] + id_util=sess["id_util"] + + conn=fonctions.connexionBD() + cur = conn.cursor() +#debut geocodage +# geo=geocodage.geocodageIUTV(adresse) #decommentez pour utilisation IUT + geo=geocodage.geocodage(adresse) #decommentez pour utilisation home + if not geo: + lat=None + lon=None + else : + lat=geo[0] + lon=geo[1] +#fin geocodage + sql="insert into contact (nom,email,tel,adresse,latitude,longitude,id_util) values (%s,%s,%s,%s,%s,%s,%s);" + cur.execute(sql, (nom, email, telephone, adresse, lat, lon, id_util, )) + conn.commit() + conn.close() + + req.write(fonctions.codeHTML("Nouveau contact",""" +<p><b>Nouveau contact</b></p> +<p>""" + nom + """ a bien été ajouté à vos contacts</p> +""" + fonctions.lien('menu.py',"Retour au menu principal"))) |
