Parcourir la source

Added first draft of FDNWhiteLabel model and admin

Damien Nicolas il y a 9 ans
Parent
commit
6dee8944ab
3 fichiers modifiés avec 65 ajouts et 5 suppressions
  1. 22 1
      fdnwhitelabel/admin.py
  2. 31 0
      fdnwhitelabel/migrations/0001_initial.py
  3. 12 4
      fdnwhitelabel/models.py

+ 22 - 1
fdnwhitelabel/admin.py

@@ -1,3 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
 from django.contrib import admin
+from polymorphic.admin import PolymorphicChildModelAdmin
+
+from coin.configuration.admin import ConfigurationAdminFormMixin
+from fdnwhitelabel.models import FDNWhiteLabel
+
+
+class FDNWhiteLabelInline(admin.StackedInline):
+    model = FDNWhiteLabel
+
+
+class FDNWhiteLabelAdmin(ConfigurationAdminFormMixin, PolymorphicChildModelAdmin):
+    base_model = FDNWhiteLabel
+    # Used for form inclusion (when browsing a subscription object in the
+    # admin, SimpleDSLInline will be displayed)
+    inline = FDNWhiteLabelInline
+    # Since we don't provide a view, don't display a "view on site" link
+    # in the admin.
+    view_on_site = False
 
-# Register your models here.
+admin.site.register(FDNWhiteLabel, FDNWhiteLabelAdmin)

+ 31 - 0
fdnwhitelabel/migrations/0001_initial.py

@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import django.core.validators
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('configuration', '0003_configuration_comment'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='FDNWhiteLabel',
+            fields=[
+                ('configuration_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='configuration.Configuration')),
+                ('phone_number', models.CharField(help_text='Phone number associated to the DSL line', max_length=20, verbose_name='phone number')),
+                ('address', models.TextField(null=True, verbose_name='adresse postale', blank=True)),
+                ('postal_code', models.CharField(blank=True, max_length=5, null=True, verbose_name='code postal', validators=[django.core.validators.RegexValidator(regex='^\\d{5}$', message='Code postal non valide.')])),
+                ('city', models.CharField(max_length=200, null=True, verbose_name='commune', blank=True)),
+                ('ppp_login', models.CharField(max_length=200, null=True, verbose_name='identifiant PPP', blank=True)),
+                ('ppp_password', models.CharField(max_length=200, null=True, verbose_name='mot de passe PPP', blank=True)),
+            ],
+            options={
+                'verbose_name': 'marque blanche FDN',
+            },
+            bases=('configuration.configuration',),
+        ),
+    ]

+ 12 - 4
fdnwhitelabel/models.py

@@ -19,16 +19,24 @@ class FDNWhiteLabel(Configuration):
     url_namespace = "fdn"
     phone_number = models.CharField(max_length=20,
                                     verbose_name='phone number',
-                                    help_text="Phone number associated to the DSL line")
+                                    help_text='Phone number associated to the '
+                                              'DSL line')
     address = models.TextField(
         verbose_name='adresse postale', blank=True, null=True)
     postal_code = models.CharField(max_length=5, blank=True, null=True,
-                                   validators=[RegexValidator(regex=r'^\d{5}$',
-                                                              message='Code postal non valide.')],
+                                   validators=[
+                                       RegexValidator(regex=r'^\d{5}$',
+                                                      message='Code postal '
+                                                              'non valide.')
+                                       ],
                                    verbose_name='code postal')
     city = models.CharField(max_length=200, blank=True, null=True,
                             verbose_name='commune')
-    
+    ppp_login = models.CharField(max_length=200, blank=True, null=True,
+                                 verbose_name='identifiant PPP')
+    ppp_password = models.CharField(max_length=200, blank=True, null=True,
+                                    verbose_name='mot de passe PPP')
+
     def __unicode__(self):
         return self.phone_number