Browse Source

Use localflavors for phone number field.

opi 8 years ago
parent
commit
01f85f1829
1 changed files with 13 additions and 0 deletions
  1. 13 0
      coin/isp_database/admin.py

+ 13 - 0
coin/isp_database/admin.py

@@ -2,9 +2,20 @@
 from __future__ import unicode_literals
 
 from django.contrib import admin
+from django.forms import ModelForm
+
+from localflavor.fr.forms import FRPhoneNumberField
 
 from coin.isp_database.models import ISPInfo, RegisteredOffice, OtherWebsite, ChatRoom, CoveredArea, BankInfo
 
+class ISPAdminForm(ModelForm):
+
+    class Meta:
+        model = ISPInfo
+
+    phone_number = FRPhoneNumberField(required=False,
+                                      help_text='Main contact phone number')
+
 
 class SingleInstanceAdminMixin(object):
     """Hides the "Add" button when there is already an instance"""
@@ -82,5 +93,7 @@ class ISPInfoAdmin(SingleInstanceAdminMixin, admin.ModelAdmin):
                CoveredAreaInline)
     save_on_top = True
 
+    # Use custom form
+    form = ISPAdminForm
 
 admin.site.register(ISPInfo, ISPInfoAdmin)