forked from ScoDoc/ScoDoc
WIP: fix http redirects, fix some JS urls
This commit is contained in:
parent
ede5aa680d
commit
64615036ec
@ -7,6 +7,8 @@ import inspect
|
|||||||
import types
|
import types
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import werkzeug
|
||||||
|
from werkzeug.exceptions import BadRequest
|
||||||
import flask
|
import flask
|
||||||
from flask import g
|
from flask import g
|
||||||
from flask import abort, current_app
|
from flask import abort, current_app
|
||||||
@ -14,7 +16,6 @@ from flask import request
|
|||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from werkzeug.exceptions import BadRequest
|
|
||||||
from app.auth.models import Permission
|
from app.auth.models import Permission
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +81,8 @@ class ZResponse(object):
|
|||||||
self.headers = {}
|
self.headers = {}
|
||||||
|
|
||||||
def redirect(self, url):
|
def redirect(self, url):
|
||||||
return flask.redirect(url) # http 302
|
current_app.logger.debug("ZResponse redirect to:" + str(url))
|
||||||
|
return flask.redirect(url.decode("utf-8")) # http 302 # #sco8 unicode
|
||||||
|
|
||||||
def setHeader(self, header, value):
|
def setHeader(self, header, value):
|
||||||
self.headers[header.lower()] = value
|
self.headers[header.lower()] = value
|
||||||
@ -188,6 +190,8 @@ def scodoc7func(context):
|
|||||||
if not top_level:
|
if not top_level:
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
|
if isinstance(value, werkzeug.wrappers.response.Response):
|
||||||
|
return value # redirected
|
||||||
# Build response, adding collected http headers:
|
# Build response, adding collected http headers:
|
||||||
headers = []
|
headers = []
|
||||||
kw = {"response": value, "status": 200}
|
kw = {"response": value, "status": 200}
|
||||||
|
@ -231,6 +231,8 @@ def sco_header(
|
|||||||
<script language="javascript" type="text/javascript" src="/ScoDoc/static/libjs/bubble.js"></script>
|
<script language="javascript" type="text/javascript" src="/ScoDoc/static/libjs/bubble.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.onload=function(){enableTooltips("gtrcontent")};
|
window.onload=function(){enableTooltips("gtrcontent")};
|
||||||
|
|
||||||
|
var SCO_URL="%(ScoURL)s";
|
||||||
</script>"""
|
</script>"""
|
||||||
% params
|
% params
|
||||||
)
|
)
|
||||||
|
@ -248,6 +248,7 @@ def do_evaluation_create(
|
|||||||
evaluation_type=None,
|
evaluation_type=None,
|
||||||
numero=None,
|
numero=None,
|
||||||
REQUEST=None,
|
REQUEST=None,
|
||||||
|
**kw # ceci pour absorber les arguments excedentaires de tf #sco8
|
||||||
):
|
):
|
||||||
"""Create an evaluation"""
|
"""Create an evaluation"""
|
||||||
if not sco_permissions_check.can_edit_evaluation(
|
if not sco_permissions_check.can_edit_evaluation(
|
||||||
|
@ -53,15 +53,17 @@ from PIL import Image as PILImage
|
|||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
|
from flask import request
|
||||||
|
|
||||||
from config import Config
|
from config import Config
|
||||||
|
|
||||||
import app.scodoc.sco_utils as scu
|
from app.scodoc import sco_etud
|
||||||
import app.scodoc.notesdb as ndb
|
|
||||||
from app.scodoc.notes_log import log
|
|
||||||
from app.scodoc.scolog import logdb
|
|
||||||
from app.scodoc import sco_portal_apogee
|
from app.scodoc import sco_portal_apogee
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc import sco_etud
|
from app.scodoc.notes_log import log
|
||||||
|
from app.scodoc.scolog import logdb
|
||||||
|
import app.scodoc.notesdb as ndb
|
||||||
|
import app.scodoc.sco_utils as scu
|
||||||
|
|
||||||
# Full paths on server's filesystem. Something like "/opt/scodoc/var/scodoc/photos"
|
# Full paths on server's filesystem. Something like "/opt/scodoc/var/scodoc/photos"
|
||||||
PHOTO_DIR = os.path.join(Config.INSTANCE_HOME, "var", "scodoc", "photos")
|
PHOTO_DIR = os.path.join(Config.INSTANCE_HOME, "var", "scodoc", "photos")
|
||||||
@ -89,7 +91,10 @@ def etud_photo_url(context, etud, size="small", fast=False, REQUEST=None):
|
|||||||
"""url to the image of the student, in "small" size or "orig" size.
|
"""url to the image of the student, in "small" size or "orig" size.
|
||||||
If ScoDoc doesn't have an image and a portal is configured, link to it.
|
If ScoDoc doesn't have an image and a portal is configured, link to it.
|
||||||
"""
|
"""
|
||||||
photo_url = "get_photo_image?etudid=%s&size=%s" % (etud["etudid"], size)
|
photo_url = scu.ScoURL() + "/get_photo_image?etudid=%s&size=%s" % (
|
||||||
|
etud["etudid"],
|
||||||
|
size,
|
||||||
|
)
|
||||||
if fast:
|
if fast:
|
||||||
return photo_url
|
return photo_url
|
||||||
path = photo_pathname(context, etud, size=size)
|
path = photo_pathname(context, etud, size=size)
|
||||||
@ -98,7 +103,7 @@ def etud_photo_url(context, etud, size="small", fast=False, REQUEST=None):
|
|||||||
ext_url = photo_portal_url(context, etud)
|
ext_url = photo_portal_url(context, etud)
|
||||||
if not ext_url:
|
if not ext_url:
|
||||||
# fallback: Photo "unknown"
|
# fallback: Photo "unknown"
|
||||||
photo_url = UNKNOWN_IMAGE_URL
|
photo_url = scu.ScoURL() + "/" + UNKNOWN_IMAGE_URL
|
||||||
else:
|
else:
|
||||||
# essaie de copier la photo du portail
|
# essaie de copier la photo du portail
|
||||||
new_path, _ = copy_portal_photo_to_fs(context, etud, REQUEST=REQUEST)
|
new_path, _ = copy_portal_photo_to_fs(context, etud, REQUEST=REQUEST)
|
||||||
@ -141,7 +146,7 @@ def _http_jpeg_file(context, filename, REQUEST=None):
|
|||||||
RESPONSE.setHeader("Last-Modified", last_modified_str)
|
RESPONSE.setHeader("Last-Modified", last_modified_str)
|
||||||
RESPONSE.setHeader("Cache-Control", "max-age=3600")
|
RESPONSE.setHeader("Cache-Control", "max-age=3600")
|
||||||
RESPONSE.setHeader("Content-Length", str(file_size))
|
RESPONSE.setHeader("Content-Length", str(file_size))
|
||||||
header = REQUEST.get_header("If-Modified-Since", None)
|
header = request.headers.get("If-Modified-Since")
|
||||||
if header is not None:
|
if header is not None:
|
||||||
header = header.split(";")[0]
|
header = header.split(";")[0]
|
||||||
# Some proxies seem to send invalid date strings for this
|
# Some proxies seem to send invalid date strings for this
|
||||||
|
@ -13,14 +13,14 @@ function get_etudid_from_elem(e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$().ready(function(){
|
$().ready(function () {
|
||||||
|
|
||||||
var elems = $(".etudinfo");
|
var elems = $(".etudinfo");
|
||||||
|
|
||||||
var q_args = get_query_args();
|
var q_args = get_query_args();
|
||||||
var args_to_pass = new Set(
|
var args_to_pass = new Set(
|
||||||
[ "formsemestre_id", "group_ids","group_id", "partition_id",
|
["formsemestre_id", "group_ids", "group_id", "partition_id",
|
||||||
"moduleimpl_id", "evaluation_id"
|
"moduleimpl_id", "evaluation_id"
|
||||||
]);
|
]);
|
||||||
var qs = "";
|
var qs = "";
|
||||||
for (var k in q_args) {
|
for (var k in q_args) {
|
||||||
@ -28,11 +28,11 @@ $().ready(function(){
|
|||||||
qs += '&' + k + '=' + q_args[k];
|
qs += '&' + k + '=' + q_args[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var i=0; i < elems.length; i++) {
|
for (var i = 0; i < elems.length; i++) {
|
||||||
$(elems[i]).qtip({
|
$(elems[i]).qtip({
|
||||||
content: {
|
content: {
|
||||||
ajax: {
|
ajax: {
|
||||||
url: "etud_info_html?etudid=" + get_etudid_from_elem(elems[i]) + qs,
|
url: SCO_URL + "/etud_info_html?etudid=" + get_etudid_from_elem(elems[i]) + qs,
|
||||||
type: "GET"
|
type: "GET"
|
||||||
//success: function(data, status) {
|
//success: function(data, status) {
|
||||||
// this.set('content.text', data);
|
// this.set('content.text', data);
|
||||||
@ -40,14 +40,14 @@ $().ready(function(){
|
|||||||
// console.log(status);
|
// console.log(status);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
text: "Loading...",
|
text: "Loading...",
|
||||||
position: {
|
position: {
|
||||||
at: "right bottom",
|
at: "right bottom",
|
||||||
my: "left top"
|
my: "left top"
|
||||||
},
|
},
|
||||||
style: {
|
style: {
|
||||||
classes: 'qtip-etud'
|
classes: 'qtip-etud'
|
||||||
},
|
},
|
||||||
hide: {
|
hide: {
|
||||||
fixed: true,
|
fixed: true,
|
||||||
delay: 300
|
delay: 300
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// Affichage progressif du trombinoscope html
|
// Affichage progressif du trombinoscope html
|
||||||
|
|
||||||
$().ready(function(){
|
$().ready(function () {
|
||||||
var spans = $(".unloaded_img");
|
var spans = $(".unloaded_img");
|
||||||
for (var i=0; i < spans.length; i++) {
|
for (var i = 0; i < spans.length; i++) {
|
||||||
var sp = spans[i];
|
var sp = spans[i];
|
||||||
var etudid = sp.id;
|
var etudid = sp.id;
|
||||||
$(sp).load('etud_photo_html?etudid='+etudid);
|
$(sp).load(SCO_URL + '/etud_photo_html?etudid=' + etudid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -34,16 +34,16 @@ function select_tous() {
|
|||||||
var url = groups_view_url();
|
var url = groups_view_url();
|
||||||
var default_group_id = $("#group_selector")[0].default_group_id.value;
|
var default_group_id = $("#group_selector")[0].default_group_id.value;
|
||||||
delete url.param()['group_ids'];
|
delete url.param()['group_ids'];
|
||||||
url.param()['group_ids'] = [ default_group_id ];
|
url.param()['group_ids'] = [default_group_id];
|
||||||
|
|
||||||
var query_string = $.param(url.param(), traditional=true );
|
var query_string = $.param(url.param(), traditional = true);
|
||||||
window.location = url.attr('base') + url.attr('path') + '?' + query_string;
|
window.location = url.attr('base') + url.attr('path') + '?' + query_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// L'URL pour l'état courant de la page:
|
// L'URL pour l'état courant de la page:
|
||||||
function get_current_url() {
|
function get_current_url() {
|
||||||
var url = groups_view_url();
|
var url = groups_view_url();
|
||||||
var query_string = $.param(url.param(), traditional=true );
|
var query_string = $.param(url.param(), traditional = true);
|
||||||
return url.attr('base') + url.attr('path') + '?' + query_string;
|
return url.attr('base') + url.attr('path') + '?' + query_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,12 +53,12 @@ function submit_group_selector() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show_current_tab() {
|
function show_current_tab() {
|
||||||
$('.nav-tabs [href="#'+CURRENT_TAB_HASH+'"]').tab('show');
|
$('.nav-tabs [href="#' + CURRENT_TAB_HASH + '"]').tab('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
var CURRENT_TAB_HASH = $.url().param()['curtab'];
|
var CURRENT_TAB_HASH = $.url().param()['curtab'];
|
||||||
|
|
||||||
$().ready(function(){
|
$().ready(function () {
|
||||||
$('.nav-tabs a').on('shown.bs.tab', function (e) {
|
$('.nav-tabs a').on('shown.bs.tab', function (e) {
|
||||||
CURRENT_TAB_HASH = e.target.hash.slice(1); // sans le #
|
CURRENT_TAB_HASH = e.target.hash.slice(1); // sans le #
|
||||||
});
|
});
|
||||||
@ -69,15 +69,15 @@ $().ready(function(){
|
|||||||
function change_list_options() {
|
function change_list_options() {
|
||||||
var url = groups_view_url();
|
var url = groups_view_url();
|
||||||
var selected_options = $("#group_list_options").val();
|
var selected_options = $("#group_list_options").val();
|
||||||
var options = [ "with_paiement", "with_archives", "with_annotations", "with_codes" ];
|
var options = ["with_paiement", "with_archives", "with_annotations", "with_codes"];
|
||||||
for (var i=0; i<options.length; i++) {
|
for (var i = 0; i < options.length; i++) {
|
||||||
var option = options[i];
|
var option = options[i];
|
||||||
delete url.param()[option];
|
delete url.param()[option];
|
||||||
if ($.inArray( option, selected_options ) >= 0) {
|
if ($.inArray(option, selected_options) >= 0) {
|
||||||
url.param()[option] = 1;
|
url.param()[option] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var query_string = $.param(url.param(), traditional=true );
|
var query_string = $.param(url.param(), traditional = true);
|
||||||
window.location = url.attr('base') + url.attr('path') + '?' + query_string;
|
window.location = url.attr('base') + url.attr('path') + '?' + query_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,35 +86,35 @@ function toggle_visible_etuds() {
|
|||||||
//
|
//
|
||||||
$(".etud_elem").hide();
|
$(".etud_elem").hide();
|
||||||
var qargs = "";
|
var qargs = "";
|
||||||
$("#group_ids_sel option:selected").each( function(index, opt) {
|
$("#group_ids_sel option:selected").each(function (index, opt) {
|
||||||
var group_id = opt.value;
|
var group_id = opt.value;
|
||||||
$("."+group_id).show();
|
$("." + group_id).show();
|
||||||
qargs += "&group_ids=" + group_id;
|
qargs += "&group_ids=" + group_id;
|
||||||
});
|
});
|
||||||
// Update url saisie tableur:
|
// Update url saisie tableur:
|
||||||
var input_eval = $("#formnotes_evaluation_id");
|
var input_eval = $("#formnotes_evaluation_id");
|
||||||
if (input_eval.length > 0) {
|
if (input_eval.length > 0) {
|
||||||
var evaluation_id = input_eval[0].value;
|
var evaluation_id = input_eval[0].value;
|
||||||
$("#menu_saisie_tableur a").attr("href", "saisie_notes_tableur?evaluation_id=" + evaluation_id + qargs );
|
$("#menu_saisie_tableur a").attr("href", "saisie_notes_tableur?evaluation_id=" + evaluation_id + qargs);
|
||||||
// lien feuille excel:
|
// lien feuille excel:
|
||||||
$("#lnk_feuille_saisie").attr("href", "feuille_saisie_notes?evaluation_id=" + evaluation_id + qargs );
|
$("#lnk_feuille_saisie").attr("href", "feuille_saisie_notes?evaluation_id=" + evaluation_id + qargs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$().ready(function() {
|
$().ready(function () {
|
||||||
$('#group_ids_sel').multiselect(
|
$('#group_ids_sel').multiselect(
|
||||||
{
|
{
|
||||||
includeSelectAllOption: false,
|
includeSelectAllOption: false,
|
||||||
nonSelectedText:'choisir...',
|
nonSelectedText: 'choisir...',
|
||||||
// buttonContainer: '<div id="group_ids_sel_container"/>',
|
// buttonContainer: '<div id="group_ids_sel_container"/>',
|
||||||
onChange: function(element, checked){
|
onChange: function (element, checked) {
|
||||||
if (checked == true) {
|
if (checked == true) {
|
||||||
var default_group_id = $(".default_group")[0].value;
|
var default_group_id = $(".default_group")[0].value;
|
||||||
|
|
||||||
if (element.hasClass("default_group")) {
|
if (element.hasClass("default_group")) {
|
||||||
// click sur groupe "tous"
|
// click sur groupe "tous"
|
||||||
// deselectionne les autres
|
// deselectionne les autres
|
||||||
$("#group_ids_sel option:selected").each( function(index, opt) {
|
$("#group_ids_sel option:selected").each(function (index, opt) {
|
||||||
if (opt.value != default_group_id) {
|
if (opt.value != default_group_id) {
|
||||||
$("#group_ids_sel").multiselect('deselect', opt.value);
|
$("#group_ids_sel").multiselect('deselect', opt.value);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ $().ready(function() {
|
|||||||
// click sur un autre item
|
// click sur un autre item
|
||||||
// si le groupe "tous" est selectionne et que l'on coche un autre, le deselectionner
|
// si le groupe "tous" est selectionne et que l'on coche un autre, le deselectionner
|
||||||
var default_is_selected = false;
|
var default_is_selected = false;
|
||||||
$("#group_ids_sel option:selected").each( function(index, opt) {
|
$("#group_ids_sel option:selected").each(function (index, opt) {
|
||||||
if (opt.value == default_group_id) {
|
if (opt.value == default_group_id) {
|
||||||
default_is_selected = true;
|
default_is_selected = true;
|
||||||
return false;
|
return false;
|
||||||
@ -152,28 +152,28 @@ $().ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Trombinoscope
|
// Trombinoscope
|
||||||
$().ready(function(){
|
$().ready(function () {
|
||||||
|
|
||||||
var elems = $(".trombi-photo");
|
var elems = $(".trombi-photo");
|
||||||
for (var i=0; i < elems.length; i++) {
|
for (var i = 0; i < elems.length; i++) {
|
||||||
$(elems[i]).qtip(
|
$(elems[i]).qtip(
|
||||||
{
|
{
|
||||||
content: {
|
content: {
|
||||||
ajax: {
|
ajax: {
|
||||||
url: "etud_info_html?with_photo=0&etudid=" + get_etudid_from_elem(elems[i])
|
url: SCO_URL + "/etud_info_html?with_photo=0&etudid=" + get_etudid_from_elem(elems[i])
|
||||||
},
|
},
|
||||||
text: "Loading..."
|
text: "Loading..."
|
||||||
},
|
},
|
||||||
position: {
|
position: {
|
||||||
at : "right",
|
at: "right",
|
||||||
my : "left top"
|
my: "left top"
|
||||||
},
|
},
|
||||||
style: {
|
style: {
|
||||||
classes: 'qtip-etud'
|
classes: 'qtip-etud'
|
||||||
},
|
},
|
||||||
// utile pour debugguer le css:
|
// utile pour debugguer le css:
|
||||||
// hide: { event: 'unfocus' }
|
// hide: { event: 'unfocus' }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -77,3 +77,11 @@ def sco_get_version(REQUEST):
|
|||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
def sco_test_view(REQUEST=None):
|
def sco_test_view(REQUEST=None):
|
||||||
return """Vous avez vu sco_test_view !"""
|
return """Vous avez vu sco_test_view !"""
|
||||||
|
|
||||||
|
|
||||||
|
import flask
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/essrep")
|
||||||
|
def essrep():
|
||||||
|
return flask.Response(status=200, response="Bonjour")
|
||||||
|
@ -1482,7 +1482,7 @@ sco_publish(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/evaluation_edit")
|
@bp.route("/evaluation_edit", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.ScoEnsView)
|
@permission_required(Permission.ScoEnsView)
|
||||||
@scodoc7func(context)
|
@scodoc7func(context)
|
||||||
def evaluation_edit(context, evaluation_id, REQUEST):
|
def evaluation_edit(context, evaluation_id, REQUEST):
|
||||||
@ -1492,7 +1492,7 @@ def evaluation_edit(context, evaluation_id, REQUEST):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/evaluation_create")
|
@bp.route("/evaluation_create", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.ScoEnsView)
|
@permission_required(Permission.ScoEnsView)
|
||||||
@scodoc7func(context)
|
@scodoc7func(context)
|
||||||
def evaluation_create(context, moduleimpl_id, REQUEST):
|
def evaluation_create(context, moduleimpl_id, REQUEST):
|
||||||
|
@ -184,7 +184,7 @@ def about(context, REQUEST):
|
|||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/edit_preferences")
|
@bp.route("/edit_preferences", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.ScoChangePreferences)
|
@permission_required(Permission.ScoChangePreferences)
|
||||||
@scodoc7func(context)
|
@scodoc7func(context)
|
||||||
def edit_preferences(context, REQUEST):
|
def edit_preferences(context, REQUEST):
|
||||||
|
Loading…
Reference in New Issue
Block a user