summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Mihai <smihai@entrouvert.com>2015-04-17 12:50:50 (GMT)
committerSerghei Mihai <smihai@entrouvert.com>2015-04-17 13:04:22 (GMT)
commitb63758cd21e836cba761c7d12188bede2dffdd54 (patch)
tree900f984400705001c8f77f07ca973f5fc8cdfa95
parent44f3490c8c7e6f6e64384cc712e4b350496da704 (diff)
downloadcombo-plugin-subscriptions-b63758cd21e836cba761c7d12188bede2dffdd54.zip
combo-plugin-subscriptions-b63758cd21e836cba761c7d12188bede2dffdd54.tar.gz
combo-plugin-subscriptions-b63758cd21e836cba761c7d12188bede2dffdd54.tar.bz2
populating service url from settings on cell initilisationv0.0.2
-rw-r--r--combo_plugin_subscriptions/migrations/0002_auto_20150417_1255.py20
-rw-r--r--combo_plugin_subscriptions/migrations/0002_auto_20150417_1302.py20
-rw-r--r--combo_plugin_subscriptions/models.py12
3 files changed, 51 insertions, 1 deletions
diff --git a/combo_plugin_subscriptions/migrations/0002_auto_20150417_1255.py b/combo_plugin_subscriptions/migrations/0002_auto_20150417_1255.py
new file mode 100644
index 0000000..7fc0801
--- /dev/null
+++ b/combo_plugin_subscriptions/migrations/0002_auto_20150417_1255.py
@@ -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,
+ ),
+ ]
diff --git a/combo_plugin_subscriptions/migrations/0002_auto_20150417_1302.py b/combo_plugin_subscriptions/migrations/0002_auto_20150417_1302.py
new file mode 100644
index 0000000..7fc0801
--- /dev/null
+++ b/combo_plugin_subscriptions/migrations/0002_auto_20150417_1302.py
@@ -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,
+ ),
+ ]
diff --git a/combo_plugin_subscriptions/models.py b/combo_plugin_subscriptions/models.py
index feeb7a6..f1987ed 100644
--- a/combo_plugin_subscriptions/models.py
+++ b/combo_plugin_subscriptions/models.py
@@ -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())