populating service url from settings on cell initilisation
This commit is contained in:
parent
44f3490c8c
commit
b63758cd21
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('combo_plugin_subscriptions', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='subscriptionsmanagecell',
|
||||
name='passerelle_url',
|
||||
field=models.URLField(max_length=128, verbose_name='Subscriptions service url'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('combo_plugin_subscriptions', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='subscriptionsmanagecell',
|
||||
name='passerelle_url',
|
||||
field=models.URLField(max_length=128, verbose_name='Subscriptions service url'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -9,6 +9,7 @@ from django.utils.translation import ugettext as _
|
|||
from django.template.defaultfilters import slugify
|
||||
from django.core.cache import cache
|
||||
from django import template
|
||||
from django.forms import models as model_forms, Select
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -22,7 +23,6 @@ from .forms import SubscriptionsManageForm
|
|||
@register_cell_class
|
||||
class SubscriptionsManageCell(CellBase):
|
||||
passerelle_url = models.URLField(verbose_name=_('Subscriptions service url'),
|
||||
choices=settings.COMBO_SUBSCRIPTIONS,
|
||||
max_length=128)
|
||||
resources_restrictions = models.TextField(verbose_name=_('resources restrictions'), blank=True)
|
||||
transports_restrictions = models.TextField(verbose_name=_('transports restrictions'), blank=True)
|
||||
|
@ -35,6 +35,16 @@ class SubscriptionsManageCell(CellBase):
|
|||
class Meta:
|
||||
verbose_name = _('Manage your subscriptions')
|
||||
|
||||
def get_default_form_class(self):
|
||||
model_fields = ('passerelle_url', 'resources_restrictions',
|
||||
'transports_restrictions')
|
||||
try:
|
||||
return model_forms.modelform_factory(self.__class__, fields=model_fields,
|
||||
widgets={'passerelle_url': Select(choices=settings.COMBO_SUBSCRIPTIONS)})
|
||||
except AttributeError:
|
||||
return model_forms.modelform_factory(self.__class__, fields=model_fields)
|
||||
|
||||
|
||||
def simplify(self, name):
|
||||
return slugify(name.strip())
|
||||
|
||||
|
|
Reference in New Issue