Commit 8c3d0a4e authored by Nicolas G.'s avatar Nicolas G.

Soumission à l'Agenda Dul Ibre En direct

Merci @aeris :)
parent bcf0f98b
This diff is collapsed.
......@@ -233,39 +233,20 @@ def adl(request, code):
jour = foo.strftime('%A %e %B %Y').capitalize() # sans (seulement sous *nix)
contact_adl = settings.ADMINS[0][1]
url = "http://" + request.META["SERVER_NAME"] + "/" + ville.code
#url = "http://" + "www.perdu.com/" + ville.code
if request.method== 'POST':
form = AgendaForm(request.POST)
if form.is_valid():
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
script = BASE_DIR + '/adl-submit.py'
import locale
encoding = locale.getpreferredencoding()
print("encoding * * * * * * * * *")
print(encoding)
with tempfile.TemporaryDirectory() as tempdir:
# Écrire le fichier XML
print("1")
fichier = tempdir + "/" + str(time.time()) + ".xml"
print("2")
f = open(fichier, "w", encoding="utf8")
#f = open(fichier, "w", encoding="ascii")
print("3")
print(request.POST['xml'])
print("4")
f.write(request.POST['xml'])
print("5")
f.close()
print("6")
#print("FICHIER :" +fichier)
print("7")
print("Le fichier ⇒ " + fichier)
time.sleep(60)
cmd = subprocess.Popen([script, '--submitter', request.POST['email'], '--file', fichier], stdout=subprocess.PIPE)
print("8")
resultat = cmd.communicate()[0]
print("9")
else:
form=AgendaForm()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment