Passage à python 3

This commit is contained in:
Evarin 2018-12-26 22:00:36 +01:00
parent a3f12a22f8
commit ca14bf09fc
15 changed files with 106 additions and 97 deletions

View file

@ -20,7 +20,7 @@ class Command(BaseCommand):
if options.get('apply', False):
rundb = True
else:
print u"Les modifications ne seront pas appliquées"
print(u"Les modifications ne seront pas appliquées")
min_lieu = options.get('min_lieu', 0)
@ -28,16 +28,16 @@ class Command(BaseCommand):
lproches = Lieu.objects.filter(id__lt=lieu.id, coord__distance_lte=(lieu.coord, 5))
if len(lproches) == 0:
continue
print u"Doublons possibles pour %s (id=%d, %d avis) :" % (lieu, lieu.id, lieu.avislieu_set.count())
print(u"Doublons possibles pour %s (id=%d, %d avis) :" % (lieu, lieu.id, lieu.avislieu_set.count()))
for plieu in lproches:
pprint = u" > %s (id=%d, %d avis)" % (plieu, plieu.id, plieu.avislieu_set.count())
if plieu.nom == lieu.nom and plieu.ville == lieu.ville and plieu.type_lieu == lieu.type_lieu:
print u"%s %s" % (pprint, self.style.SUCCESS(u'-> Suppression'))
print(u"%s %s" % (pprint, self.style.SUCCESS(u'-> Suppression')))
if rundb:
for avis in plieu.avislieu_set.all():
avis.lieu = lieu
avis.save()
plieu.delete()
else:
print u"%s %s" % (pprint, self.style.WARNING(u'-> À supprimer manuellement'))
print(u"%s %s" % (pprint, self.style.WARNING(u'-> À supprimer manuellement')))
self.stdout.write(self.style.SUCCESS(u'Nettoyage des lieux effectué'))

View file

@ -30,7 +30,7 @@ class Command(BaseCommand):
if options.get('apply', False):
rundb = True
else:
print u"Les modifications ne seront pas appliquées"
print(u"Les modifications ne seront pas appliquées")
min_stage = options.get('min_stage', 0)
@ -52,15 +52,15 @@ class Command(BaseCommand):
problems += [(avis, alen), lieuset[aid]]
lieuset[aid] = (avis, alen)
if len(todel) > 0:
print u"Doublons détectés dans %s" % (stage,)
print(u"Doublons détectés dans %s" % (stage,))
for avis, alen in todel:
print u" > Suppression de l'avis sur %s de %d mots" % \
(avis.lieu, alen)
print(u" > Suppression de l'avis sur %s de %d mots" % \
(avis.lieu, alen))
if rundb:
avis.delete()
if len(problems) > 0:
self.stdout.write(self.style.WARNING(u"Réparation impossible de %s (id=%d)" % (stage, stage.id)))
for avis, alen in problems:
print u" > Avis sur %s de %d mots" % \
(avis.lieu, alen)
print(u" > Avis sur %s de %d mots" % \
(avis.lieu, alen))
self.stdout.write(self.style.SUCCESS(u'Nettoyage des stages effectué'))

View file

@ -21,12 +21,12 @@ class Command(BaseCommand):
if options.get('apply', False):
rundb = True
else:
print u"Les modifications ne seront pas appliquées"
print(u"Les modifications ne seront pas appliquées")
plieu = Lieu.objects.get(id=options['del_lieu'])
lieu = Lieu.objects.get(id=options['repl_lieu'])
print u"Suppression de %s (id=%d, %d avis)" % (plieu, plieu.id, plieu.avislieu_set.count())
print u"Remplacement par %s (id=%d, %d avis)" % (lieu, lieu.id, lieu.avislieu_set.count())
print(u"Suppression de %s (id=%d, %d avis)" % (plieu, plieu.id, plieu.avislieu_set.count()))
print(u"Remplacement par %s (id=%d, %d avis)" % (lieu, lieu.id, lieu.avislieu_set.count()))
if rundb:
for avis in plieu.avislieu_set.all():
avis.lieu = lieu

View file

@ -40,7 +40,7 @@ class Normalien(models.Model):
verbose_name = u"Profil élève"
verbose_name_plural = u"Profils élèves"
def __unicode__(self):
def __str__(self):
return u"%s (%s)" % (self.nom, self.user.username)
# Liste des stages publiés
@ -131,7 +131,7 @@ class Lieu(models.Model):
def type_lieu_fem(self):
return TYPE_LIEU_DICT.get(self.type_lieu, ("lieu", False))[1]
def __unicode__(self):
def __str__(self):
return u"%s (%s)" % (self.nom, self.ville)
class Meta:
@ -150,7 +150,7 @@ class StageMatiere(models.Model):
verbose_name = "Matière des stages"
verbose_name_plural = "Matières des stages"
def __unicode__(self):
def __str__(self):
return self.nom
#
@ -221,7 +221,7 @@ class Stage(models.Model):
def get_absolute_url(self):
return reverse('avisstage:stage', self)
def __unicode__(self):
def __str__(self):
return u"%s (par %s)" % (self.sujet, self.auteur.user.username)
def update_stats(self, save=True):
@ -263,7 +263,7 @@ class AvisStage(models.Model):
les_plus = models.TextField(u"Les plus de cette expérience", blank=True)
les_moins = models.TextField(u"Les moins de cette expérience", blank=True)
def __unicode__(self):
def __str__(self):
return u"Avis sur {%s} par %s" % (self.stage.sujet, self.stage.auteur.user.username)
# Liste des champs d'avis, couplés à leur nom (pour l'affichage)
@ -292,7 +292,7 @@ class AvisLieu(models.Model):
verbose_name = "Avis sur un lieu de stage"
verbose_name_plural = "Avis sur un lieu de stage"
def __unicode__(self):
def __str__(self):
return u"Avis sur {%s} par %s" % (self.lieu.nom, self.stage.auteur.user_id)
# Liste des champs d'avis, couplés à leur nom (pour l'affichage)

View file

@ -542,6 +542,8 @@ ul.as-selections {
div.as-results {
position: relative;
z-index: 2;
ul {
position: absolute;
width: 100%;

View file

@ -900,28 +900,29 @@ ul.as-selections .as-original input {
/* line 543, ../../sass/screen.scss */
div.as-results {
position: relative;
z-index: 2;
}
/* line 545, ../../sass/screen.scss */
/* line 547, ../../sass/screen.scss */
div.as-results ul {
position: absolute;
width: 100%;
background: #fff;
border: 1px solid #d2ebad;
}
/* line 552, ../../sass/screen.scss */
/* line 554, ../../sass/screen.scss */
div.as-results ul li {
padding: 3px 5px;
}
/* line 558, ../../sass/screen.scss */
/* line 560, ../../sass/screen.scss */
div.as-results ul li.as-result-item.active {
background: #fddeb5;
}
/* line 563, ../../sass/screen.scss */
/* line 565, ../../sass/screen.scss */
div.as-results ul li.as-message {
font-style: italic;
}
/* line 573, ../../sass/screen.scss */
/* line 575, ../../sass/screen.scss */
.window {
display: none;
position: fixed;
@ -932,11 +933,11 @@ div.as-results ul li.as-message {
left: 0;
z-index: 50;
}
/* line 583, ../../sass/screen.scss */
/* line 585, ../../sass/screen.scss */
.window.visible {
display: block;
}
/* line 587, ../../sass/screen.scss */
/* line 589, ../../sass/screen.scss */
.window .window-bg {
background: #000;
opacity: 0.7;
@ -947,7 +948,7 @@ div.as-results ul li.as-message {
top: 0;
z-index: -1;
}
/* line 598, ../../sass/screen.scss */
/* line 600, ../../sass/screen.scss */
.window .window-content {
position: relative;
margin: 0 auto;
@ -961,11 +962,11 @@ div.as-results ul li.as-message {
max-height: 100%;
overflow: auto;
}
/* line 612, ../../sass/screen.scss */
/* line 614, ../../sass/screen.scss */
.window .window-content form label, .window .window-content form .label {
width: 150px;
}
/* line 618, ../../sass/screen.scss */
/* line 620, ../../sass/screen.scss */
.window .window-closer {
position: absolute;
top: 0;
@ -973,65 +974,65 @@ div.as-results ul li.as-message {
padding: 12px;
z-index: 3;
}
/* line 624, ../../sass/screen.scss */
/* line 626, ../../sass/screen.scss */
.window .window-closer:after {
content: "×";
}
/* line 635, ../../sass/screen.scss */
/* line 637, ../../sass/screen.scss */
#lieu_widget .lieu-ui {
position: relative;
}
/* line 637, ../../sass/screen.scss */
/* line 639, ../../sass/screen.scss */
#lieu_widget .lieu-ui .map {
height: 400px;
width: 100%;
}
/* line 641, ../../sass/screen.scss */
/* line 643, ../../sass/screen.scss */
#lieu_widget .lieu-ui.hidden {
display: none;
}
/* line 644, ../../sass/screen.scss */
/* line 646, ../../sass/screen.scss */
#lieu_widget .lieu-ui .masked {
visibility: hidden;
}
/* line 649, ../../sass/screen.scss */
/* line 651, ../../sass/screen.scss */
#lieu_widget .lieu-choixmodif {
display: none;
}
/* line 654, ../../sass/screen.scss */
/* line 656, ../../sass/screen.scss */
#lieu_widget.modif .lieu-choixmodif {
display: unset;
}
/* line 659, ../../sass/screen.scss */
/* line 661, ../../sass/screen.scss */
#lieu_widget.modif .lieu-ui, #lieu_widget.attente .lieu-ui {
display: none;
}
/* line 666, ../../sass/screen.scss */
/* line 668, ../../sass/screen.scss */
#lieu_widget.edit .lieu-ui .lieu-acinput {
display: none;
}
/* line 669, ../../sass/screen.scss */
/* line 671, ../../sass/screen.scss */
#lieu_widget.edit .lieu-ui .map {
height: 200px;
}
/* line 675, ../../sass/screen.scss */
/* line 677, ../../sass/screen.scss */
#lieu_widget #avis_lieu_vide {
display: none;
}
/* line 679, ../../sass/screen.scss */
/* line 681, ../../sass/screen.scss */
#lieu_widget .message {
background: #fddeb5;
padding: 5px;
font-style: italic;
font-size: 0.9em;
}
/* line 685, ../../sass/screen.scss */
/* line 687, ../../sass/screen.scss */
#lieu_widget .message.hidden {
display: none;
}
/* line 691, ../../sass/screen.scss */
/* line 693, ../../sass/screen.scss */
a.lieu-change {
color: #fff;
background: #f99b20;
@ -1044,25 +1045,25 @@ a.lieu-change {
border-radius: 5px;
margin-right: 7px;
}
/* line 703, ../../sass/screen.scss */
/* line 705, ../../sass/screen.scss */
a.lieu-change.ajout:before {
content: "+";
margin-right: 5px;
}
/* line 709, ../../sass/screen.scss */
/* line 711, ../../sass/screen.scss */
#stages-map {
width: 100%;
height: 600px;
max-height: 90vh;
}
/* line 716, ../../sass/screen.scss */
/* line 718, ../../sass/screen.scss */
#id_stage-thematiques {
display: none;
}
/* line 722, ../../sass/screen.scss */
/* line 724, ../../sass/screen.scss */
.homeh1 {
display: flex;
justify-content: space-between;
@ -1072,26 +1073,26 @@ a.lieu-change.ajout:before {
border-bottom: 3px solid #000;
margin-bottom: 15px;
}
/* line 731, ../../sass/screen.scss */
/* line 733, ../../sass/screen.scss */
.homeh1 h1 {
margin-bottom: 3px;
}
/* line 735, ../../sass/screen.scss */
/* line 737, ../../sass/screen.scss */
.homeh1 > * {
display: inline-block;
}
/* line 738, ../../sass/screen.scss */
/* line 740, ../../sass/screen.scss */
.homeh1 p {
text-align: right;
}
/* line 743, ../../sass/screen.scss */
/* line 745, ../../sass/screen.scss */
.betacadre {
background: #fa6cae;
padding: 10px;
}
/* line 748, ../../sass/screen.scss */
/* line 750, ../../sass/screen.scss */
.entrer {
background: #fff;
max-width: 500px;
@ -1100,84 +1101,84 @@ a.lieu-change.ajout:before {
margin: 15px auto;
}
/* line 756, ../../sass/screen.scss */
/* line 758, ../../sass/screen.scss */
article.promo {
display: block;
font-size: 1.1em;
}
/* line 760, ../../sass/screen.scss */
/* line 762, ../../sass/screen.scss */
article.promo .explications {
display: table;
}
/* line 763, ../../sass/screen.scss */
/* line 765, ../../sass/screen.scss */
article.promo .explications:first-child {
direction: rtl;
}
/* line 765, ../../sass/screen.scss */
/* line 767, ../../sass/screen.scss */
article.promo .explications:first-child > * {
direction: ltr;
}
/* line 770, ../../sass/screen.scss */
/* line 772, ../../sass/screen.scss */
article.promo .explications > div {
display: table-cell;
vertical-align: middle;
text-align: center;
}
/* line 775, ../../sass/screen.scss */
/* line 777, ../../sass/screen.scss */
article.promo .explications > div p {
margin: 15px 15px;
}
/* line 783, ../../sass/screen.scss */
/* line 785, ../../sass/screen.scss */
.faq-toc {
font-family: "Lato", sans-serif;
display: block;
max-width: 700px;
margin: 0 auto;
}
/* line 788, ../../sass/screen.scss */
/* line 790, ../../sass/screen.scss */
.faq-toc ul {
margin: 20px;
}
/* line 792, ../../sass/screen.scss */
/* line 794, ../../sass/screen.scss */
.faq-toc ul li a {
color: #000;
display: block;
padding: 5px;
}
/* line 798, ../../sass/screen.scss */
/* line 800, ../../sass/screen.scss */
.faq-toc ul li.toc-h1 {
display: none;
}
/* line 802, ../../sass/screen.scss */
/* line 804, ../../sass/screen.scss */
.faq-toc ul li.toc-h2 a {
background: #fcc883;
}
/* line 806, ../../sass/screen.scss */
/* line 808, ../../sass/screen.scss */
.faq-toc ul li.toc-h3 a {
padding-left: 10px;
background: #fff;
font-weight: normal;
}
/* line 812, ../../sass/screen.scss */
/* line 814, ../../sass/screen.scss */
.faq-toc ul li a:hover {
color: #395214;
background: #bce085 !important;
}
/* line 821, ../../sass/screen.scss */
/* line 823, ../../sass/screen.scss */
.faq article {
background: #fff;
padding: 15px;
}
/* line 824, ../../sass/screen.scss */
/* line 826, ../../sass/screen.scss */
.faq article h2 {
background-color: #fcc883;
color: #ae6505;
margin: -15px;
padding: 15px;
}
/* line 831, ../../sass/screen.scss */
/* line 833, ../../sass/screen.scss */
.faq article h3 {
color: #0f4c82;
background-color: #9dcbf3;
@ -1185,19 +1186,19 @@ article.promo .explications > div p {
margin-top: 30px;
padding: 10px 15px;
}
/* line 838, ../../sass/screen.scss */
/* line 840, ../../sass/screen.scss */
.faq article h3:nth-child(2) {
margin-top: 0;
}
/* line 843, ../../sass/screen.scss */
/* line 845, ../../sass/screen.scss */
.faq article ul {
padding-left: 20px;
}
/* line 845, ../../sass/screen.scss */
/* line 847, ../../sass/screen.scss */
.faq article ul li {
list-style: initial;
}
/* line 850, ../../sass/screen.scss */
/* line 852, ../../sass/screen.scss */
.faq article p, .faq article ul {
font-family: "Lato", sans-serif;
font-size: 18px;
@ -1206,20 +1207,20 @@ article.promo .explications > div p {
margin-right: 5%;
}
/* line 864, ../../sass/screen.scss */
/* line 866, ../../sass/screen.scss */
table.stats {
width: 100%;
background: #fff;
margin: 20px 0;
cellspacing: 1px;
}
/* line 869, ../../sass/screen.scss */
/* line 871, ../../sass/screen.scss */
table.stats th {
font-weight: bold;
border-top: 1px solid #000;
border-bottom: 1px solid #999;
}
/* line 874, ../../sass/screen.scss */
/* line 876, ../../sass/screen.scss */
table.stats td, table.stats th {
padding: 5px 3px;
text-align: center;

View file

@ -16,6 +16,7 @@
<link rel="stylesheet" type="text/css" href="{% static "css/MarkerCluster.Default.css" %}" />
<script type="text/javascript" src="{% static "js/selectize.min.js" %}"></script>
<link rel="stylesheet" type="text/css" href="{% static "css/selectize.css" %}" />
<link href="{% static "jquery-autosuggest/css/autoSuggest-upshot.css" %}" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="{% static "js/editstage.js" %}"></script>
<script type="text/javascript">
$(function(){
@ -23,7 +24,10 @@
"{{ STATIC_URL|escapejs }}",
"{% url 'avisstage:api_dispatch_list' resource_name="lieu" api_name="v1" %}");
});
var django = {};
django.jQuery = $;
</script>
<script type="text/javascript" src="{% static "jquery-autosuggest/js/jquery.autoSuggest.minified.js" %}"> </script>
{% endblock %}
{% block content %}

View file

@ -18,8 +18,6 @@ def feedback_widget():
@register.filter
def typonazisme(value):
#print value
#return value
value = re.sub(r'(\w)\s*([?!:])', u'\\1\\2', value)
value = re.sub(r'(\w)\s*([,.])', u'\\1\\2', value)
value = re.sub(r'([?!:,.])(\w)', u'\\1 \\2', value)

View file

@ -1,4 +1,6 @@
# coding: utf-8
from functools import reduce
def choices_length (choices):
return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0)

View file

@ -130,7 +130,7 @@ def manage_stage(request, pk=None):
avis_stage_form.instance.stage = stage
avis_stage_form.save()
avis_lieu_formset.save()
print request.POST
print(request.POST)
if "continuer" in request.POST:
if pk is None:
return redirect(reverse('avisstage:stage_edit',kwargs={'pk':stage.id}))
@ -158,7 +158,7 @@ def save_lieu(request):
if request.method == "POST":
pk = request.POST.get("id", None)
print request.POST
print(request.POST)
jitter = False
if pk is None or pk == '':
lieu = Lieu()

View file

@ -64,7 +64,7 @@ def cherche(**kwargs):
# Champ générique : recherche dans tous les champs
if field_relevant("generique"):
#print "Filtre generique", kwargs['generique']
#print("Filtre generique", kwargs['generique'])
dsl = dsl.query(
"match",
_all={"query": kwargs["generique"],
@ -117,7 +117,7 @@ def cherche(**kwargs):
if use_dsl:
filtres &= Q(id__in=[s.meta.id for s in dsl.scan()])
#print filtres
#print(filtres)
resultat = Stage.objects.filter(filtres)
tri = 'pertinence'
@ -178,7 +178,8 @@ def recherche_resultats(request):
stageids = []
if cached is None:
stages = stages[stageids.start_index()-1:stageids.end_index()]
stages = stages[max(0, stageids.start_index()-1):
stageids.end_index()]
else:
stages = Stage.objects.filter(id__in=stageids)

View file

@ -1,6 +1,6 @@
from settings_base import *
from .settings_base import *
from secrets import SECRET_KEY
from .secrets import SECRET_KEY
DEBUG = True

View file

@ -1,6 +1,6 @@
from settings_base import *
from .settings_base import *
from secrets import SECRET_KEY
from .secrets import SECRET_KEY
import os, sys
from django.core.urlresolvers import reverse_lazy

View file

@ -1,2 +1,3 @@
-r requirements.txt
#spatialite-bin
django-debug-toolbar

View file

@ -1,11 +1,11 @@
django
django-cas-ng
django-taggit
python-ldap
django-tinymce
django-braces
django-taggit-autosuggest
pytz
django-tastypie
lxml
git+https://github.com/sabricot/django-elasticsearch-dsl
django==1.11.*
django-cas-ng==3.5.*
django-taggit==0.22.*
python-ldap==3.0.*
django-tinymce==2.7.*
django-braces==1.12.*
django-taggit-autosuggest==0.3.*
pytz==2018.*
django-tastypie==0.14.*
lxml==4.2.*
django-elasticsearch-dsl==0.4.*