Project

General

Profile

« Previous | Next » 

Revision b773431d

Added by Jérôme Schneider over 10 years ago

dossiers: format phone numbers with a template tag

View differences:

calebasse/dossiers/templates/dossiers/patientrecord_tab3_adresses.html
1
{% load dossiers %}
1 2
<div id="tabs-3">
2 3
  <form method="post" action="tab3" id="policyholder-form" class="patientrecordform">{% csrf_token %}
3 4
    <p>
......
66 67
        <ul class="ajax_messages" style="display: none;"></ul>
67 68
        <input type="checkbox" data-id="{{ address.id }}" class="place_of_life" {% if address.place_of_life %}checked{% endif %}>Lieu de vie</input>
68 69
      </div>
69
      {% if address.phone %}<p><span class="icon-phone">{{ address.phone }}</span></p>{% endif %}
70
      {% if address.phone %}<p><span class="icon-phone">{{ address.phone|phone }}</span></p>{% endif %}
70 71
      {% if address.comment %}<p><label>Commentaire :</label>{{ address.comment }}</p>{% endif %}
71 72
      {% if not address.phone and not address.comment %}<p>&nbsp;<!-- intentionaly empty --></p>{% endif %}
72 73
      {% for contact in address.patientcontact_set.all  %}
calebasse/dossiers/templates/dossiers/patientrecord_update.html
1 1
{% extends "dossiers/base.html" %}
2 2
{% load url from future %}
3
{% load dossiers %}
3 4

  
4 5
{% block extrascripts %}
5 6
<link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}filter-widget/css/filter-widget.css"/>
calebasse/dossiers/templatetags/dossiers.py
1
from django import template
2

  
3
register = template.Library()
4

  
5
def phone(value):
6
    result = ""
7
    if len(value) == 10:
8
        for i in range(2, 11, 2):
9
            result += value[i-2:i] + " "
10
        result = result[:-1]
11
    else:
12
        result = value
13
    return result
14

  
15
register.filter('phone', phone)

Also available in: Unified diff