From 7c1263060e3afbaf569e9b57e48960e0a731c8f9 Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet
Date: Mon, 21 Jun 2021 23:13:57 +0200
Subject: [PATCH] enhance request compat
---
app/decorators.py | 1 +
app/scodoc/debug.py | 1 -
app/scodoc/sco_evaluations.py | 3 ++-
app/scodoc/scolog.py | 7 +++----
app/views/absences.py | 3 +--
5 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/app/decorators.py b/app/decorators.py
index f7bd46d4f..c62e98acc 100644
--- a/app/decorators.py
+++ b/app/decorators.py
@@ -48,6 +48,7 @@ class ZRequest(object):
self.QUERY_STRING = request.query_string.encode("utf-8")
self.REQUEST_METHOD = request.method.encode("utf-8")
self.AUTHENTICATED_USER = current_user
+ self.REMOTE_ADDR = request.remote_addr
if request.method == "POST":
self.form = request.form # xxx encode en utf-8 !
# Encode en utf-8 pour ScoDoc8 #sco8
diff --git a/app/scodoc/debug.py b/app/scodoc/debug.py
index 4685dccaf..12aa300e0 100644
--- a/app/scodoc/debug.py
+++ b/app/scodoc/debug.py
@@ -129,7 +129,6 @@ class DummyRequest:
self.URL = "http://scodoc/"
self.URL0 = self.URL
self.BASE0 = "localhost"
- self.REMOTE_HOST = "localhost"
self.REMOTE_ADDR = "127.0.0.1"
self.HTTP_REFERER = ""
self.REQUEST_METHOD = "get"
diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py
index 2383e3d60..00b07971a 100644
--- a/app/scodoc/sco_evaluations.py
+++ b/app/scodoc/sco_evaluations.py
@@ -1148,7 +1148,8 @@ def evaluation_create_form(
+ "Modification évaluation impossible pour %s"
% scu.get_current_user_name(REQUEST)
+ "
"
- + 'Revenir
' % (str(REQUEST.HTTP_REFERER),)
+ + 'Revenir
'
+ % (moduleimpl_id,)
+ html_sco_header.sco_footer(context, REQUEST)
)
if readonly:
diff --git a/app/scodoc/scolog.py b/app/scodoc/scolog.py
index 1b097135b..76cadd277 100644
--- a/app/scodoc/scolog.py
+++ b/app/scodoc/scolog.py
@@ -42,18 +42,17 @@ def logdb(REQUEST=None, cnx=None, method=None, etudid=None, msg=None, commit=Tru
args = {
"authenticated_user": str(REQUEST.AUTHENTICATED_USER),
"remote_addr": REQUEST.REMOTE_ADDR,
- "remote_host": REQUEST.REMOTE_HOST,
}
else:
- args = {"authenticated_user": None, "remote_addr": None, "remote_host": None}
+ args = {"authenticated_user": None, "remote_addr": None}
args.update({"method": method, "etudid": etudid, "msg": msg})
ndb.quote_dict(args)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""INSERT INTO scolog
- (authenticated_user,remote_addr,remote_host,method,etudid,msg)
+ (authenticated_user,remote_addr,method,etudid,msg)
VALUES
- (%(authenticated_user)s,%(remote_addr)s,%(remote_host)s,%(method)s,%(etudid)s,%(msg)s)""",
+ (%(authenticated_user)s,%(remote_addr)s,%(method)s,%(etudid)s,%(msg)s)""",
args,
)
if commit:
diff --git a/app/views/absences.py b/app/views/absences.py
index 5afdab0f3..9bb165cf1 100644
--- a/app/views/absences.py
+++ b/app/views/absences.py
@@ -959,8 +959,7 @@ def EtatAbsencesDate(
else:
H.append(
"""Erreur: vous n'avez pas choisi de date !
- Continuer"""
- % REQUEST.HTTP_REFERER
+ """
)
return "\n".join(H) + html_sco_header.sco_footer(REQUEST)