From 686999b97d28a5ad3b8887b0990f34383180449a Mon Sep 17 00:00:00 2001 From: Evarin Date: Fri, 30 Jun 2017 19:26:05 +0200 Subject: [PATCH] Typonazisme --- avisstage/templates/avisstage/detail/avis.html | 10 +++++----- avisstage/templatetags/avisstage_tags.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/avisstage/templates/avisstage/detail/avis.html b/avisstage/templates/avisstage/detail/avis.html index 3ca8462..1723210 100644 --- a/avisstage/templates/avisstage/detail/avis.html +++ b/avisstage/templates/avisstage/detail/avis.html @@ -1,9 +1,9 @@ - +{% load avisstage_tags %}

{{ titre }}

{% if avis.chapo %}

- {{ avis.chapo|linebreaksbr }} + {{ avis.chapo|typonazisme|linebreaksbr }}

{% endif %} {% for av in avis.avis_all %} @@ -11,7 +11,7 @@

{{ av.0 }}

- {{ av.1|safe }} + {{ av.1|typonazisme|safe }}
{% endif %} @@ -21,7 +21,7 @@

Super si vous aimez...

-

{{ avis.les_plus|linebreaksbr }}

+

{{ avis.les_plus|typonazisme|linebreaksbr }}

{% endif %} @@ -29,7 +29,7 @@

Pas génial pour...

-

{{ avis.les_moins|linebreaksbr }}

+

{{ avis.les_moins|typonazisme|linebreaksbr }}

{% endif %} diff --git a/avisstage/templatetags/avisstage_tags.py b/avisstage/templatetags/avisstage_tags.py index 82c3b10..ee3e8f6 100644 --- a/avisstage/templatetags/avisstage_tags.py +++ b/avisstage/templatetags/avisstage_tags.py @@ -1,6 +1,8 @@ +# coding: utf-8 from django import template from avisstage.forms import LieuForm, FeedbackForm +import re register = template.Library() @@ -13,3 +15,12 @@ def lieu_widget(): def feedback_widget(): form = FeedbackForm() return {"form": form} + +@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) + return value