forked from ScoDoc/ScoDoc
fix autosuggest
This commit is contained in:
parent
dc77cdcc68
commit
4d637db3fc
@ -9,7 +9,7 @@
|
||||
v 1.2
|
||||
"""
|
||||
|
||||
from types import BooleanType, StringType
|
||||
from types import BooleanType, StringType, UnicodeType
|
||||
|
||||
|
||||
def TrivialFormulator(
|
||||
@ -746,7 +746,7 @@ def dict2js(d):
|
||||
v = "true"
|
||||
else:
|
||||
v = "false"
|
||||
elif type(v) == StringType:
|
||||
elif type(v) == StringType or type(v) == UnicodeType:
|
||||
v = '"' + v + '"'
|
||||
|
||||
r.append("%s: %s" % (k, v))
|
||||
|
@ -28,6 +28,9 @@
|
||||
"""Gestion des emails
|
||||
"""
|
||||
|
||||
from flask import request
|
||||
|
||||
|
||||
# XXX WIP: à ré-écrire pour ScoDoc 8 (étaient des méthodes de ZScoDoc)
|
||||
import os
|
||||
import time
|
||||
@ -83,7 +86,7 @@ def send_debug_alert(context, txt, REQUEST=None):
|
||||
return
|
||||
if REQUEST:
|
||||
txt = _report_request(context, REQUEST) + txt
|
||||
URL = REQUEST.get("URL", "")
|
||||
URL = REQUEST.URL
|
||||
else:
|
||||
URL = "send_debug_alert"
|
||||
msg = MIMEMultipart()
|
||||
@ -100,26 +103,26 @@ def send_debug_alert(context, txt, REQUEST=None):
|
||||
|
||||
def _report_request(context, REQUEST, fmt="txt"):
|
||||
"""string describing current request for bug reports"""
|
||||
QUERY_STRING = REQUEST.get("QUERY_STRING", "")
|
||||
QUERY_STRING = REQUEST.QUERY_STRING
|
||||
if QUERY_STRING:
|
||||
QUERY_STRING = "?" + QUERY_STRING
|
||||
if fmt == "txt":
|
||||
REFERER = REQUEST.get("HTTP_REFERER", "")
|
||||
HTTP_USER_AGENT = REQUEST.get("HTTP_USER_AGENT", "")
|
||||
REFERER = request.referrer
|
||||
HTTP_USER_AGENT = request.user_agent
|
||||
else:
|
||||
REFERER = "na"
|
||||
HTTP_USER_AGENT = "na"
|
||||
|
||||
params = dict(
|
||||
AUTHENTICATED_USER=REQUEST.get("AUTHENTICATED_USER", ""),
|
||||
AUTHENTICATED_USER=REQUEST.AUTHENTICATED_USER,
|
||||
dt=time.asctime(),
|
||||
URL=REQUEST.get("URL", ""),
|
||||
URL=REQUEST.URL,
|
||||
QUERY_STRING=QUERY_STRING,
|
||||
METHOD=REQUEST.get("REQUEST_METHOD", ""),
|
||||
METHOD=request.method,
|
||||
REFERER=REFERER,
|
||||
HTTP_USER_AGENT=HTTP_USER_AGENT,
|
||||
form=REQUEST.get("form", ""),
|
||||
HTTP_X_FORWARDED_FOR=REQUEST.get("HTTP_X_FORWARDED_FOR", ""),
|
||||
form=REQUEST.form,
|
||||
HTTP_X_FORWARDED_FOR="?",
|
||||
svn_version=scu.get_svn_version(scu.SCO_SRC_DIR),
|
||||
SCOVERSION=VERSION.SCOVERSION,
|
||||
)
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
"""Form choix modules / responsables et creation formsemestre
|
||||
"""
|
||||
from flask import url_for, g
|
||||
from app.auth.models import User
|
||||
|
||||
import app.scodoc.notesdb as ndb
|
||||
@ -102,7 +103,7 @@ def formsemestre_editwithmodules(context, REQUEST, formsemestre_id):
|
||||
)
|
||||
else:
|
||||
H.append(do_formsemestre_createwithmodules(context, REQUEST=REQUEST, edit=1))
|
||||
if not REQUEST.get("tf-submitted", False):
|
||||
if not REQUEST.form.get("tf-submitted", False):
|
||||
H.append(
|
||||
"""<p class="help">Seuls les modules cochés font partie de ce semestre. Pour les retirer, les décocher et appuyer sur le bouton "modifier".
|
||||
</p>
|
||||
@ -271,7 +272,10 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
|
||||
"allowed_values": allowed_user_names,
|
||||
"allow_null": False, # il faut au moins un responsable de semestre
|
||||
"text_suggest_options": {
|
||||
"script": "Users/get_user_list_xml?",
|
||||
"script": url_for(
|
||||
"users.get_user_list_xml", scodoc_dept=g.scodoc_dept
|
||||
)
|
||||
+ "?", # "Users/get_user_list_xml?",
|
||||
"varname": "start",
|
||||
"json": False,
|
||||
"noresults": "Valeur invalide !",
|
||||
@ -289,7 +293,10 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
|
||||
"allowed_values": allowed_user_names,
|
||||
"allow_null": True, # optionnel
|
||||
"text_suggest_options": {
|
||||
"script": "Users/get_user_list_xml?",
|
||||
"script": url_for(
|
||||
"users.get_user_list_xml", scodoc_dept=g.scodoc_dept
|
||||
)
|
||||
+ "?",
|
||||
"varname": "start",
|
||||
"json": False,
|
||||
"noresults": "Valeur invalide !",
|
||||
@ -573,7 +580,10 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
|
||||
"allowed_values": allowed_user_names,
|
||||
"template": itemtemplate,
|
||||
"text_suggest_options": {
|
||||
"script": "Users/get_user_list_xml?",
|
||||
"script": url_for(
|
||||
"users.get_user_list_xml", scodoc_dept=g.scodoc_dept
|
||||
)
|
||||
+ "?",
|
||||
"varname": "start",
|
||||
"json": False,
|
||||
"noresults": "Valeur invalide !",
|
||||
@ -728,10 +738,11 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
|
||||
"responsable_id": tf[2][module_id],
|
||||
}
|
||||
_ = sco_moduleimpl.do_moduleimpl_create(context, modargs)
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
REQUEST.RESPONSE.redirect(
|
||||
"formsemestre_status?formsemestre_id=%s&head_message=Nouveau%%20semestre%%20créé"
|
||||
% formsemestre_id
|
||||
)
|
||||
return ""
|
||||
else:
|
||||
# modification du semestre:
|
||||
# on doit creer les modules nouvellement selectionnés
|
||||
@ -934,7 +945,10 @@ def formsemestre_clone(context, formsemestre_id, REQUEST=None):
|
||||
"allowed_values": allowed_user_names,
|
||||
"allow_null": False,
|
||||
"text_suggest_options": {
|
||||
"script": "Users/get_user_list_xml?",
|
||||
"script": url_for(
|
||||
"users.get_user_list_xml", scodoc_dept=g.scodoc_dept
|
||||
)
|
||||
+ "?",
|
||||
"varname": "start",
|
||||
"json": False,
|
||||
"noresults": "Valeur invalide !",
|
||||
|
@ -36,7 +36,7 @@ import datetime
|
||||
import jaxml
|
||||
import pprint
|
||||
|
||||
from flask import g
|
||||
from flask import url_for, g
|
||||
from flask import current_app
|
||||
|
||||
from config import Config
|
||||
@ -230,6 +230,7 @@ sco_publish(
|
||||
"/formsemestre_editwithmodules",
|
||||
sco_formsemestre_edit.formsemestre_editwithmodules,
|
||||
Permission.ScoView,
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
|
||||
sco_publish(
|
||||
@ -759,7 +760,10 @@ def edit_enseignants_form(context, REQUEST, moduleimpl_id):
|
||||
"allowed_values": allowed_user_names,
|
||||
"allow_null": False,
|
||||
"text_suggest_options": {
|
||||
"script": "Users/get_user_list_xml?",
|
||||
"script": url_for(
|
||||
"users.get_user_list_xml", scodoc_dept=g.scodoc_dept
|
||||
)
|
||||
+ "?",
|
||||
"varname": "start",
|
||||
"json": False,
|
||||
"noresults": "Valeur invalide !",
|
||||
@ -849,7 +853,10 @@ def edit_moduleimpl_resp(context, REQUEST, moduleimpl_id):
|
||||
"allowed_values": allowed_user_names,
|
||||
"allow_null": False,
|
||||
"text_suggest_options": {
|
||||
"script": "Users/get_user_list_xml?",
|
||||
"script": url_for(
|
||||
"users.get_user_list_xml", scodoc_dept=g.scodoc_dept
|
||||
)
|
||||
+ "?",
|
||||
"varname": "start",
|
||||
"json": False,
|
||||
"noresults": "Valeur invalide !",
|
||||
|
@ -470,7 +470,7 @@ def get_user_list_xml(context, dept=None, start="", limit=25, REQUEST=None):
|
||||
userlist = [
|
||||
user
|
||||
for user in userlist
|
||||
if scu.suppress_accents(scu.strlower(user.nom)).startswith(start)
|
||||
if scu.suppress_accents(scu.strlower(user.nom or "")).startswith(start)
|
||||
]
|
||||
if REQUEST:
|
||||
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
|
||||
@ -478,7 +478,7 @@ def get_user_list_xml(context, dept=None, start="", limit=25, REQUEST=None):
|
||||
doc.results()
|
||||
for user in userlist[:limit]:
|
||||
doc._push()
|
||||
doc.rs(user["nomplogin"], id=user["user_id"], info="")
|
||||
doc.rs(user.get_nomplogin(), id=user.id, info="")
|
||||
doc._pop()
|
||||
return repr(doc)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user