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