Projet

Général

Profil

0001-backoffice-allow-more-word-breaking-in-logged-error-.patch

Frédéric Péters, 09 août 2022 06:46

Télécharger (2,76 ko)

Voir les différences:

Subject: [PATCH 1/2] backoffice: allow more word breaking in logged error
 summaries (#68038)

 wcs/admin/logged_errors.py               | 2 +-
 wcs/logged_errors.py                     | 8 ++++++++
 wcs/templates/wcs/backoffice/studio.html | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)
wcs/admin/logged_errors.py
177 177
        )
178 178
        r += htmltext('<ul>')
179 179
        for error in errors[:3]:
180
            r += htmltext('<li><a href="logged-errors/%s/">%s</a> ') % (error.id, error.summary)
180
            r += htmltext('<li><a href="logged-errors/%s/">%s</a> ') % (error.id, error.wbr_summary)
181 181
            if error.exception_class or error.exception_message:
182 182
                message = _('error %(class)s (%(message)s)') % {
183 183
                    'class': error.exception_class,
wcs/logged_errors.py
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import re
18

  
17 19
from django.utils.formats import number_format
18 20
from django.utils.timezone import now
21
from quixote.html import htmlescape, htmltext
19 22

  
20 23
from wcs.carddef import CardDef
21 24
from wcs.formdef import FormDef
......
201 204
    @property
202 205
    def formatted_occurences_count(self):
203 206
        return number_format(self.occurences_count, force_grouping=True)
207

  
208
    @property
209
    def wbr_summary(self):
210
        # allow word breaking before parenthesis, dots, underscores, and between CamelCasedWords
211
        return htmltext(re.sub(r'([\(\._]|[A-Z][a-z])', r'<wbr/>\1', str(htmlescape(self.summary))))
wcs/templates/wcs/backoffice/studio.html
51 51
      {% if recent_errors %}
52 52
        <ul>
53 53
          {% for error in recent_errors %}
54
          <li><a href="logged-errors/{{ error.id }}/">{{ error.summary|split:'_'|join:'_<wbr/>' }}</a></li>
54
          <li><a href="logged-errors/{{ error.id }}/">{{ error.wbr_summary|safe }}</a></li>
55 55
          {% endfor %}
56 56
        </ul>
57 57
        <p><a class="logged-errors-all pk-button" href="logged-errors/">{% trans "See all errors" context "studio" %}</a></p>
58
-