]> git.ipfire.org Git - ipfire.org.git/commitdiff
people: List IPFire phone numbers
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 18 Oct 2018 10:33:04 +0000 (11:33 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 18 Oct 2018 10:33:04 +0000 (11:33 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/accounts.py
src/templates/people/user.html

index 1c956c8b24114578af80dce3e77810f5511cdeb4..dca60aa41132a64ac3d2910cb3895b7c2cde7351 100644 (file)
@@ -509,6 +509,19 @@ class Account(Object):
 
        # Phone Numbers
 
+       @lazy_property
+       def phone_number(self):
+               """
+                       Returns the IPFire phone number
+               """
+               if self.sip_id:
+                       return phonenumbers.parse("+4923636035%s" % self.sip_id)
+
+       @lazy_property
+       def fax_number(self):
+               if self.sip_id:
+                       return phonenumbers.parse("+49236360359%s" % self.sip_id)
+
        def get_phone_numbers(self):
                ret = []
 
@@ -548,6 +561,10 @@ class Account(Object):
        def _all_telephone_numbers(self):
                ret = [ self.sip_id, ]
 
+               if self.phone_number:
+                       s = phonenumbers.format_number(self.phone_number, phonenumbers.PhoneNumberFormat.E164)
+                       ret.append(s)
+
                for number in self.phone_numbers:
                        s = phonenumbers.format_number(number, phonenumbers.PhoneNumberFormat.E164)
                        ret.append(s)
index 98c9ea2c8c81e5afa038a3b9df4188f5ed14fc31..f5b23cc351b89fbf97de3bea0bc66c151bb8d043 100644 (file)
                                        </div>
                                {% end %}
 
-                               {% if account.phone_numbers %}
-                                       <div class="col-md-6 mt-5">
-                                               <h6>{{ _("Phone Numbers") }}</h6>
+                               <div class="col-md-6 mt-5">
+                                       {% if account.phone_number or account.fax_number %}
+                                               <h6 class="mb-2">{{ _("Phone Numbers") }}</h6>
+
+                                               <ul class="list-unstyled">
+                                                       {% if account.phone_number %}
+                                                               <li>
+                                                                       <span class="fas fa-phone"></span>
+
+                                                                       <a href="tel:{{ format_phone_number_to_e164(account.phone_number) }}">
+                                                                               {{ format_phone_number(account.phone_number) }}
+                                                                       </a>
+                                                               </li>
+                                                       {% end %}
+
+                                                       {% if account.fax_number %}
+                                                               <li>
+                                                                       <span class="fas fa-fax"></span>
+
+                                                                       <a href="fax:{{ format_phone_number_to_e164(account.fax_number) }}">
+                                                                               {{ format_phone_number(account.fax_number) }}
+                                                                       </a>
+                                                               </li>
+                                                       {% end %}
+                                               </ul>
+                                       {% end %}
+
+                                       {% if account.phone_numbers %}
+                                               <h6 class="mb-2">{{ _("External Phone Numbers") }}</h6>
 
                                                <ul class="list-unstyled">
                                                        {% for number in account.phone_numbers %}
                                                                <li>
                                                                        {% if phonenumbers.number_type(number) == phonenumbers.PhoneNumberType.MOBILE %}
-                                                                               <span class="fa fa-mobile" title="{{ _("Mobile") }}"></span>
+                                                                               <span class="fas fa-mobile" title="{{ _("Mobile") }}"></span>
                                                                        {% else %}
-                                                                               <span class="fa fa-phone"></span>
+                                                                               <span class="fas fa-phone"></span>
                                                                        {% end %}
 
                                                                        <a href="tel:{{ format_phone_number_to_e164(number) }}"
@@ -46,8 +72,8 @@
                                                                </li>
                                                        {% end %}
                                                </ul>
-                                       </div>
-                               {% end %}
+                                       {% end %}
+                               </div>
                        </div>
                </div>
        </div>