forked from ScoDoc/DocScoDoc
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 logging
|
||||
|
||||
import werkzeug
|
||||
from werkzeug.exceptions import BadRequest
|
||||
import flask
|
||||
from flask import g
|
||||
from flask import abort, current_app
|
||||
@ -14,7 +16,6 @@ from flask import request
|
||||
from flask_login import current_user
|
||||
from flask_login import login_required
|
||||
from flask import current_app
|
||||
from werkzeug.exceptions import BadRequest
|
||||
from app.auth.models import Permission
|
||||
|
||||
|
||||
@ -80,7 +81,8 @@ class ZResponse(object):
|
||||
self.headers = {}
|
||||
|
||||
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):
|
||||
self.headers[header.lower()] = value
|
||||
@ -188,6 +190,8 @@ def scodoc7func(context):
|
||||
if not top_level:
|
||||
return value
|
||||
else:
|
||||
if isinstance(value, werkzeug.wrappers.response.Response):
|
||||
return value # redirected
|
||||
# Build response, adding collected http headers:
|
||||
headers = []
|
||||
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 type="text/javascript">
|
||||
window.onload=function(){enableTooltips("gtrcontent")};
|
||||
|
||||
var SCO_URL="%(ScoURL)s";
|
||||
</script>"""
|
||||
% params
|
||||
)
|
||||
|
@ -248,6 +248,7 @@ def do_evaluation_create(
|
||||
evaluation_type=None,
|
||||
numero=None,
|
||||
REQUEST=None,
|
||||
**kw # ceci pour absorber les arguments excedentaires de tf #sco8
|
||||
):
|
||||
"""Create an evaluation"""
|
||||
if not sco_permissions_check.can_edit_evaluation(
|
||||
|
@ -53,15 +53,17 @@ from PIL import Image as PILImage
|
||||
from cStringIO import StringIO
|
||||
import glob
|
||||
|
||||
from flask import request
|
||||
|
||||
from config import Config
|
||||
|
||||
import app.scodoc.sco_utils as scu
|
||||
import app.scodoc.notesdb as ndb
|
||||
from app.scodoc.notes_log import log
|
||||
from app.scodoc.scolog import logdb
|
||||
from app.scodoc import sco_etud
|
||||
from app.scodoc import sco_portal_apogee
|
||||
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"
|
||||
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.
|
||||
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:
|
||||
return photo_url
|
||||
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)
|
||||
if not ext_url:
|
||||
# fallback: Photo "unknown"
|
||||
photo_url = UNKNOWN_IMAGE_URL
|
||||
photo_url = scu.ScoURL() + "/" + UNKNOWN_IMAGE_URL
|
||||
else:
|
||||
# essaie de copier la photo du portail
|
||||
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("Cache-Control", "max-age=3600")
|
||||
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:
|
||||
header = header.split(";")[0]
|
||||
# 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 q_args = get_query_args();
|
||||
var args_to_pass = new Set(
|
||||
[ "formsemestre_id", "group_ids","group_id", "partition_id",
|
||||
"moduleimpl_id", "evaluation_id"
|
||||
["formsemestre_id", "group_ids", "group_id", "partition_id",
|
||||
"moduleimpl_id", "evaluation_id"
|
||||
]);
|
||||
var qs = "";
|
||||
for (var k in q_args) {
|
||||
@ -28,11 +28,11 @@ $().ready(function(){
|
||||
qs += '&' + k + '=' + q_args[k];
|
||||
}
|
||||
}
|
||||
for (var i=0; i < elems.length; i++) {
|
||||
$(elems[i]).qtip({
|
||||
content: {
|
||||
ajax: {
|
||||
url: "etud_info_html?etudid=" + get_etudid_from_elem(elems[i]) + qs,
|
||||
for (var i = 0; i < elems.length; i++) {
|
||||
$(elems[i]).qtip({
|
||||
content: {
|
||||
ajax: {
|
||||
url: SCO_URL + "/etud_info_html?etudid=" + get_etudid_from_elem(elems[i]) + qs,
|
||||
type: "GET"
|
||||
//success: function(data, status) {
|
||||
// this.set('content.text', data);
|
||||
@ -40,14 +40,14 @@ $().ready(function(){
|
||||
// console.log(status);
|
||||
}
|
||||
},
|
||||
text: "Loading...",
|
||||
position: {
|
||||
at: "right bottom",
|
||||
my: "left top"
|
||||
},
|
||||
style: {
|
||||
classes: 'qtip-etud'
|
||||
},
|
||||
text: "Loading...",
|
||||
position: {
|
||||
at: "right bottom",
|
||||
my: "left top"
|
||||
},
|
||||
style: {
|
||||
classes: 'qtip-etud'
|
||||
},
|
||||
hide: {
|
||||
fixed: true,
|
||||
delay: 300
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Affichage progressif du trombinoscope html
|
||||
|
||||
$().ready(function(){
|
||||
$().ready(function () {
|
||||
var spans = $(".unloaded_img");
|
||||
for (var i=0; i < spans.length; i++) {
|
||||
var sp = spans[i];
|
||||
var etudid = sp.id;
|
||||
$(sp).load('etud_photo_html?etudid='+etudid);
|
||||
for (var i = 0; i < spans.length; i++) {
|
||||
var sp = spans[i];
|
||||
var etudid = sp.id;
|
||||
$(sp).load(SCO_URL + '/etud_photo_html?etudid=' + etudid);
|
||||
}
|
||||
});
|
||||
|
||||
@ -25,7 +25,7 @@ function groups_view_url() {
|
||||
|
||||
var selected_groups = $("#group_selector select").val();
|
||||
url.param()['group_ids'] = selected_groups; // remplace par groupes selectionnes
|
||||
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
@ -34,16 +34,16 @@ function select_tous() {
|
||||
var url = groups_view_url();
|
||||
var default_group_id = $("#group_selector")[0].default_group_id.value;
|
||||
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;
|
||||
}
|
||||
|
||||
// L'URL pour l'état courant de la page:
|
||||
function get_current_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;
|
||||
}
|
||||
|
||||
@ -53,12 +53,12 @@ function submit_group_selector() {
|
||||
}
|
||||
|
||||
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'];
|
||||
|
||||
$().ready(function(){
|
||||
$().ready(function () {
|
||||
$('.nav-tabs a').on('shown.bs.tab', function (e) {
|
||||
CURRENT_TAB_HASH = e.target.hash.slice(1); // sans le #
|
||||
});
|
||||
@ -69,15 +69,15 @@ $().ready(function(){
|
||||
function change_list_options() {
|
||||
var url = groups_view_url();
|
||||
var selected_options = $("#group_list_options").val();
|
||||
var options = [ "with_paiement", "with_archives", "with_annotations", "with_codes" ];
|
||||
for (var i=0; i<options.length; i++) {
|
||||
var options = ["with_paiement", "with_archives", "with_annotations", "with_codes"];
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
var option = options[i];
|
||||
delete url.param()[option];
|
||||
if ($.inArray( option, selected_options ) >= 0) {
|
||||
if ($.inArray(option, selected_options) >= 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -86,45 +86,45 @@ function toggle_visible_etuds() {
|
||||
//
|
||||
$(".etud_elem").hide();
|
||||
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;
|
||||
$("."+group_id).show();
|
||||
$("." + group_id).show();
|
||||
qargs += "&group_ids=" + group_id;
|
||||
});
|
||||
// Update url saisie tableur:
|
||||
var input_eval = $("#formnotes_evaluation_id");
|
||||
if (input_eval.length > 0) {
|
||||
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:
|
||||
$("#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(
|
||||
{
|
||||
includeSelectAllOption: false,
|
||||
nonSelectedText:'choisir...',
|
||||
nonSelectedText: 'choisir...',
|
||||
// buttonContainer: '<div id="group_ids_sel_container"/>',
|
||||
onChange: function(element, checked){
|
||||
onChange: function (element, checked) {
|
||||
if (checked == true) {
|
||||
var default_group_id = $(".default_group")[0].value;
|
||||
|
||||
|
||||
if (element.hasClass("default_group")) {
|
||||
// click sur groupe "tous"
|
||||
// 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) {
|
||||
$("#group_ids_sel").multiselect('deselect', opt.value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
// click sur un autre item
|
||||
// si le groupe "tous" est selectionne et que l'on coche un autre, le deselectionner
|
||||
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) {
|
||||
default_is_selected = true;
|
||||
return false;
|
||||
@ -133,13 +133,13 @@ $().ready(function() {
|
||||
if (default_is_selected) {
|
||||
$("#group_ids_sel").multiselect('deselect', default_group_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toggle_visible_etuds();
|
||||
// referme le menu apres chaque choix:
|
||||
$("#group_selector .btn-group").removeClass('open');
|
||||
|
||||
|
||||
if ($("#group_ids_sel").hasClass("submit_on_change")) {
|
||||
submit_group_selector();
|
||||
}
|
||||
@ -152,28 +152,28 @@ $().ready(function() {
|
||||
});
|
||||
|
||||
// Trombinoscope
|
||||
$().ready(function(){
|
||||
$().ready(function () {
|
||||
|
||||
var elems = $(".trombi-photo");
|
||||
for (var i=0; i < elems.length; i++) {
|
||||
$(elems[i]).qtip(
|
||||
{
|
||||
content: {
|
||||
ajax: {
|
||||
url: "etud_info_html?with_photo=0&etudid=" + get_etudid_from_elem(elems[i])
|
||||
},
|
||||
text: "Loading..."
|
||||
},
|
||||
position: {
|
||||
at : "right",
|
||||
my : "left top"
|
||||
},
|
||||
style: {
|
||||
classes: 'qtip-etud'
|
||||
},
|
||||
// utile pour debugguer le css:
|
||||
// hide: { event: 'unfocus' }
|
||||
}
|
||||
);
|
||||
for (var i = 0; i < elems.length; i++) {
|
||||
$(elems[i]).qtip(
|
||||
{
|
||||
content: {
|
||||
ajax: {
|
||||
url: SCO_URL + "/etud_info_html?with_photo=0&etudid=" + get_etudid_from_elem(elems[i])
|
||||
},
|
||||
text: "Loading..."
|
||||
},
|
||||
position: {
|
||||
at: "right",
|
||||
my: "left top"
|
||||
},
|
||||
style: {
|
||||
classes: 'qtip-etud'
|
||||
},
|
||||
// utile pour debugguer le css:
|
||||
// hide: { event: 'unfocus' }
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -77,3 +77,11 @@ def sco_get_version(REQUEST):
|
||||
@permission_required(Permission.ScoView)
|
||||
def sco_test_view(REQUEST=None):
|
||||
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)
|
||||
@scodoc7func(context)
|
||||
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)
|
||||
@scodoc7func(context)
|
||||
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)
|
||||
@scodoc7func(context)
|
||||
def edit_preferences(context, REQUEST):
|
||||
|
Loading…
Reference in New Issue
Block a user