Browse Source

Fix programme display for chrome

Integrate Piernov Pull request
Added missing deletion behavior
Fixed badge generation
Added intervention summary

Signed-off-by: tr4ck3ur <tr4ck3ur@style-python.fr>
master
tr4ck3ur des JM2L 9 years ago
parent
commit
c058eb9245
4 changed files with 149 additions and 60 deletions
  1. +132
    -49
      jm2l/static/js/programme.js
  2. +1
    -1
      jm2l/templates/Participer.mako
  3. +2
    -2
      jm2l/templates/Salles/list.mako
  4. +14
    -8
      jm2l/views.py

+ 132
- 49
jm2l/static/js/programme.js View File

@@ -22,23 +22,23 @@ var Tasks = Array();
d3.json("le-prog-json",
function(error, json) {
if (error) return console.warn(error);
var Keys = Object.keys(json["all"])
var Keys = Object.keys(json["all"]);
// Build set of data in memory
for (var k = 0; k < Keys.length; k++) {
Salles[Keys[k]] = Array();
Areas[Keys[k]] = Array();
Tasks[Keys[k]] = json["all"][Keys[k]]
Tasks[Keys[k]] = json["all"][Keys[k]];
// Fix Json to make date objects
Tasks[Keys[k]].forEach(function(d) {
d.startDate = new Date(d.startDate);
d.endDate = new Date(d.endDate);
})
});

// Build the list of Salles and Areas
Tasks[Keys[k]].forEach(function(d) {
Salles[Keys[k]].push( d.placeName );
Areas[Keys[k]].push( d.status );
} )
} );
Salles[Keys[k]] = d3.set(Salles[Keys[k]]).values();
Areas[Keys[k]] = d3.set(Areas[Keys[k]]).values();
// Create Controls to Handle user selection
@@ -61,6 +61,10 @@ d3.json("le-prog-json",
.style("margin-left", "5px")
.text(TypeArea);
});
d3.select("#Schedule_SVG_"+Keys[k])
.append("br");
// Create a dedicated SVG for it
svg = d3.select("#Schedule_SVG_"+Keys[k])
.append("svg")
@@ -69,7 +73,9 @@ d3.json("le-prog-json",
//.attr("height", height + margin.top + margin.bottom)
.attr("viewBox", "0 0 " + (width + margin.right + margin.left) + " " + (height + margin.top + margin.bottom) )
.attr("preserveAspectRatio", "xMidYMid meet");

// Add some gradient
header(svg);
// Create axis
svg.append("g")
.attr("class", "xAxis axis");
@@ -84,6 +90,82 @@ d3.json("le-prog-json",
}
});

function header(svg) {
defs = svg.append("svg:defs");
conf = defs.append("svg:linearGradient")
.attr("id", "BoxGradient-Conference")
.attr("x1", "100%")
.attr("y1", "0%")
.attr("x2", "50%")
.attr("y2", "100%")
.attr("spreadMethod", "pad");

conf.append("svg:stop")
.attr("offset", "0%")
.attr("stop-color", "#EEE")
.attr("stop-opacity", 0);
conf.append("svg:stop")
.attr("offset", "15%")
.attr("stop-color", "#BDF86B")
.attr("stop-opacity", .5);
atlier = defs.append("svg:linearGradient")
.attr("id", "BoxGradient-Atelier")
.attr("x1", "100%")
.attr("y1", "0%")
.attr("x2", "50%")
.attr("y2", "100%")
.attr("spreadMethod", "pad");

atlier.append("svg:stop")
.attr("offset", "0%")
.attr("stop-color", "#EEE")
.attr("stop-opacity", 0);
atlier.append("svg:stop")
.attr("offset", "15%")
.attr("stop-color", "#FF856E")
.attr("stop-opacity", .5);

// append filter element
var filter = defs.append( 'filter' )
.attr( 'id', 'dropshadow' ); /// !!! important - define id to reference it later
// append gaussian blur to filter
filter.append( 'feGaussianBlur' )
.attr( 'in', 'SourceAlpha' )
.attr( 'stdDeviation', 3 ) // !!! important parameter - blur
.attr( 'result', 'blur' );
// append offset filter to result of gaussion blur filter
filter.append( 'feOffset' )
.attr( 'in', 'blur' )
.attr( 'dx', 2 ) // !!! important parameter - x-offset
.attr( 'dy', 2 ) // !!! important parameter - y-offset
.attr( 'result', 'offsetBlur' );

filter.append( 'feComponentTransfer' )
.append( 'feFuncA' )
.attr( "type", "linear" )
.attr( "slope", "0.4" );
// merge result with original image
var feMerge = filter.append( 'feMerge' );
// first layer result of blur and offset
feMerge.append( 'feMergeNode' )
.attr( 'in", "offsetBlur' );
// original image on top
feMerge.append( 'feMergeNode' )
.attr( 'in', 'SourceGraphic' );
// end filter stuff

}


var keyFunction = function(d) {
return d.startDate + d.placeName + d.endDate;
};
@@ -92,14 +174,14 @@ function HandleEvents(Ctrl) {
d3.selectAll("input[name=OptTimetable-"+Ctrl+"]")
.data(Areas[Ctrl])
.on("change", function(TypeData) {
ArrayChoice = Array()
ArrayChoice = Array();
checked = d3.selectAll("input[name=OptTimetable-"+Ctrl+"]")[0]
.forEach( function(v)
{
if (d3.select(v).node().checked)
ArrayChoice.push(v.attributes['area'].value)
ArrayChoice.push(v.attributes['area'].value);
}
)
);
area_select = Array();
selection = Tasks[Ctrl].filter(function(v) {
return ArrayChoice.indexOf(v.status)>=0;
@@ -154,53 +236,18 @@ function displayit(Set_of_Task, Set_of_Area, key) {

var svg = d3.select("#TimeTable-"+key);
var chart = svg.select(".timetable")

var content = chart.selectAll("foreignObject")
.data(Set_of_Task, keyFunction);

content.enter()
.insert("foreignObject",":first-child")
.append("xhtml:body")
.attr("class", "SvgBody")
.html(function(d) {
return '<div class="EvtBox '+ taskStatus[d.status] +'"><a href="/event/'+ d.uid +
'">' + d.desc + '</a></div>'
})
.transition()
.duration(750);
content.transition()
.duration(750)
.attr("x", function(d){
return xScale(d.placeName || "unk");
})
.attr("y", function(d){
return yScale( d.startDate );
})
.attr("width", function(d) {
return xScale.rangeBand();
})
.attr("height", function(d) {
return (yScale( d.endDate ) - yScale( d.startDate ));
});

content.exit()
.transition()
.duration(300)
.style("opacity", 1e-6)
.remove();
var chart = svg.select(".timetable");

var rect = chart.selectAll("rect")
.data(Set_of_Task, keyFunction);
rect.enter()
.insert("rect",":first-child")
.insert("rect")
.attr("rx", 5)
.attr("ry", 5)
.attr("filter", "url(/img/shadow.svg#dropshadow)")
.attr("style", function(d){
return "fill:url(/img/shadow.svg#BoxGradient-"+ taskStatus[d.status] +")"
.attr("filter", "url(#dropshadow)")
.style("fill", function(d){
return "url(#BoxGradient-"+ taskStatus[d.status] +")";
})
.attr("class", function(d){
if(taskStatus[d.status] == null)
@@ -208,7 +255,7 @@ function displayit(Set_of_Task, Set_of_Area, key) {
return taskStatus[d.status];
})
.transition()
.duration(750)
.duration(750);


rect.transition()
@@ -232,6 +279,42 @@ function displayit(Set_of_Task, Set_of_Area, key) {
.style("opacity", 1e-6)
.remove();

var content = chart.selectAll("foreignObject")
.data(Set_of_Task, keyFunction);

content.enter()
.insert("foreignObject")
.append("xhtml:div")
.attr("class", "SvgBody")
.html(function(d) {
return '<div class="EvtBox '+ taskStatus[d.status] +'"><a href="/event/'+ d.uid +
'">' + d.desc + '</a></div>';
})
.transition()
.duration(750);
content.transition()
.duration(750)
.attr("x", function(d){
return xScale(d.placeName || "unk");
})
.attr("y", function(d){
return yScale( d.startDate );
})
.attr("width", function(d) {
return xScale.rangeBand();
})
.attr("height", function(d) {
return (yScale( d.endDate ) - yScale( d.startDate ));
});
// .attr("transform" ,"scale(1)");

content.exit()
.transition()
.duration(300)
.style("opacity", 1e-6)
.remove();

svg.select(".yAxis")
.attr("transform", "translate("+ margin.left +","+ margin.top +")")
.transition()


+ 1
- 1
jm2l/templates/Participer.mako View File

@@ -55,7 +55,7 @@ DicForm ={
}
%>
<form action="/participer-l-evenement#inscription" method="post">
<h3 id="inscription" class="form-signin-heading">Je m'inscris</h3>
<h3 id="inscription">Je m'inscris</h3>
<div class="container">
${helpers.DisplayForm(form, DicForm)}
<div style="border:1px dashed #CCC;float:left;">


+ 2
- 2
jm2l/templates/Salles/list.mako View File

@@ -13,7 +13,7 @@ from slugify import slugify

<div class="tabbable" id="main_tab">
<ul class="nav nav-tabs" style="margin-bottom: 5px;">
% for Num, Entity in enumerate(sorted(DicSalle.keys(), key=lambda x:x.year_uid)):
% for Num, Entity in enumerate(sorted(DicSalle.keys(), key=lambda x:x.year_uid, reverse=True)):
<li class="${["","active"][Num==0]}">
<a href="#${Entity.year_uid}" id="Map_Pole_${Entity.year_uid}" data-toggle="tab">${Entity.year_uid}</a>
</li>
@@ -22,7 +22,7 @@ from slugify import slugify

<div class="tab-content" style="padding:0 10px">

% for Num, Entity in enumerate(sorted(DicSalle.keys(), key=lambda x:x.year_uid)):
% for Num, Entity in enumerate(sorted(DicSalle.keys(), key=lambda x:x.year_uid, reverse=True)):
<div class="tab-pane fade ${["","active "][Num==0]} in" id="${Entity.year_uid}">
<h4>${Entity.year_uid}</h4>
<table class="table table-striped table-bordered table-hover">


+ 14
- 8
jm2l/views.py View File

@@ -11,8 +11,8 @@ from .forms import *
# Database access imports
from .models import *
from .helpers import Orga_helpers
from sqlalchemy import func, or_
from os import path, makedirs
from sqlalchemy import func, or_, text
from os import path, makedirs, listdir
# Usefull tools
from slugify import slugify
from icalendar import Calendar
@@ -140,7 +140,7 @@ def JSON_Progamme_Request(request):
Events = DBSession.query(Event)\
.filter(Event.for_year == year)\
.filter(Event.event_type != 'Stand')\
.filter("strftime('%d', start_time) = :dow").params(dow=Day.day)\
.filter(text("strftime('%d', start_time) = :dow")).params(dow=Day.day)\
.order_by(Event.start_time)
ListEv = []
@@ -176,7 +176,7 @@ def JSON_TimeLine_Request(request):
Events = DBSession.query(Event)\
.filter(Event.for_year == year)\
.filter(Event.event_type != 'Stand')\
.filter("strftime('%d', start_time) = :dow").params(dow=Day.day)\
.filter(text("strftime('%d', start_time) = :dow")).params(dow=Day.day)\
.order_by(Event.start_time)
#ListEv = []
@@ -192,10 +192,10 @@ def JSON_TimeLine_Request(request):
Container = ""
ListEv.append( {
#"uid":"%d/%d" % ( year, ev.uid ),
"headline":ev.name,
"headline":'<a href="/event/%s/%s">%s</a>' % (ev.for_year, ev.slug, ev.name),
"startDate":ev.start_time.strftime('%Y,%m,%d,%H,%M'),
"endDate":ev.end_time.strftime('%Y,%m,%d,%H,%M'),
"text":ev.Salle and (ev.Salle.name or "unk"),
"text": ev.Salle and (ev.Salle.name or "unk"),
#"text":ev.description[:100],
"tags":ev.Salle and (ev.Salle.salle_id or "unk") ,
#"status":ev.event_type,
@@ -296,7 +296,13 @@ def index_page(request):
raise HTTPNotFound()
else:
content = DBSession.query(JM2L_Year).filter(JM2L_Year.year_uid==CurrentYear).first().description
return {'year': CurrentYear, 'content':content, 'edition':u"9<sup>ème</sup>"}
TargetDir = "jm2l/static/img/%s/Photos" % (year or 2015)
TargetUrl = "/static/img/%s/Photos/" % (year or 2015)
if path.isdir(TargetDir):
ListPhotos = map(lambda x: TargetUrl + x, listdir(TargetDir))
else:
ListPhotos = []
return {'year': CurrentYear, 'content':content, 'edition':u"9<sup>ème</sup>", 'ListPhotos': ListPhotos}

@view_config(route_name='edit_index', renderer="jm2l:templates/Staff/EditIndex.mako")
def edit_index(request):
@@ -1424,7 +1430,7 @@ def edit_event(request):
form.duration.choices.append( (duration,u'Conférence (%d min)' % duration) )
if not form._fields.has_key("uid"):
form.duration.data=60
SalleDispo = SalleDispo.filter(Salles.place_type.in_(['Conference', 'MAO']))
SalleDispo = SalleDispo.filter(Salles.place_type.in_(['Conference', 'MAO', 'Atelier']))
elif intervention=="Stand":
form.duration.choices =[
(8*60, u'Toute la journée'),


Loading…
Cancel
Save