diff --git a/portail_citoyen/apps/auquotidien_plugin/cms_plugins.py b/portail_citoyen/apps/auquotidien_plugin/cms_plugins.py index fad929f..6e3ca1e 100644 --- a/portail_citoyen/apps/auquotidien_plugin/cms_plugins.py +++ b/portail_citoyen/apps/auquotidien_plugin/cms_plugins.py @@ -10,8 +10,9 @@ from cms.plugin_pool import plugin_pool from data_source_plugin.cms_plugins import DataSourcePlugin, Data from data_source_plugin.models import DataSource -from .models import (AuQuotidienActiveFormsPlugin as AuQuotidienActiveFormsPluginModel, - AuQuotidienCategoryPlugin as AuQuotidienCategoryPluginModel, AuQuotidienAPI) +from .models import ( + AuQuotidienActiveFormsPlugin as AuQuotidienActiveFormsPluginModel, + AuQuotidienCategoryPlugin as AuQuotidienCategoryPluginModel) logger = logging.getLogger(__name__) @@ -33,7 +34,7 @@ class AuQuotidienBasePlugin(DataSourcePlugin): def get_apis(self, context, instance): user = context['request'].user - return AuQuotidienAPI.objects.filter(service_provider__libertyfederation__user=user, active=True) + return instance.apis.filter(service_provider__libertyfederation__user=user, active=True) def get_sources(self, context, instance): for api in self.get_apis(context, instance): @@ -46,6 +47,12 @@ class AuQuotidienBasePlugin(DataSourcePlugin): source = FakeSource(url=url, api=api) yield Data(source, context, 0, instance.refresh) + def render(self, context, instance, placeholder): + ctx = super(AuQuotidienBasePlugin, self).render(context, instance, + placeholder) + ctx['instance'] = instance + return ctx + class AuQuotidienActiveFormsPlugin(AuQuotidienBasePlugin): model = AuQuotidienActiveFormsPluginModel diff --git a/portail_citoyen/apps/auquotidien_plugin/locale/fr/LC_MESSAGES/django.po b/portail_citoyen/apps/auquotidien_plugin/locale/fr/LC_MESSAGES/django.po index 35387b2..0ec1b74 100644 --- a/portail_citoyen/apps/auquotidien_plugin/locale/fr/LC_MESSAGES/django.po +++ b/portail_citoyen/apps/auquotidien_plugin/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-10 10:55+0100\n" +"POT-Creation-Date: 2014-02-10 16:31+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,11 +18,11 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: cms_plugins.py:52 models.py:60 models.py:61 +#: cms_plugins.py:59 models.py:67 models.py:68 msgid "au-quotidien active forms" msgstr "affichage des démarches en cours" -#: cms_plugins.py:64 models.py:71 +#: cms_plugins.py:71 models.py:82 msgid "au-quotidien categories" msgstr "affichage des catégories de démarches" @@ -76,26 +76,30 @@ msgstr "temps d'expiration pour la requête HTTP" msgid "time in second to wait before failing to download a datasource" msgstr " " -#: models.py:47 +#: models.py:50 msgid "au-quotidien API endpoint" msgstr "terminaison de l'API au-quotidien" -#: models.py:48 +#: models.py:51 msgid "au-quotidien API endpoints" msgstr "terminaisons de l'API au-quotidien" -#: models.py:53 models.py:64 +#: models.py:56 models.py:71 msgid "refresh timeout" msgstr "durée de rafraîchissement" -#: models.py:54 models.py:65 +#: models.py:57 models.py:72 msgid "Number of seconds between two web service calls" msgstr "nombre de secondes entre deux appels au web-service" -#: models.py:57 models.py:68 +#: models.py:61 models.py:76 msgid "refresh {0}" msgstr "durée de rafraîchissement {0}s" +#: templates/auquotidien_plugin/categories.html:2 +msgid "Other procedures.." +msgstr "Autres démarches..." + #: templates/auquotidien_plugin/categories.html:20 msgid "All categories" msgstr "Toutes les démarches" diff --git a/portail_citoyen/apps/auquotidien_plugin/migrations/0002_auto.py b/portail_citoyen/apps/auquotidien_plugin/migrations/0002_auto.py new file mode 100644 index 0000000..a25f376 --- /dev/null +++ b/portail_citoyen/apps/auquotidien_plugin/migrations/0002_auto.py @@ -0,0 +1,177 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding M2M table for field apis on 'AuQuotidienCategoryPlugin' + m2m_table_name = db.shorten_name(u'auquotidien_plugin_auquotidiencategoryplugin_apis') + db.create_table(m2m_table_name, ( + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), + ('auquotidiencategoryplugin', models.ForeignKey(orm[u'auquotidien_plugin.auquotidiencategoryplugin'], null=False)), + ('auquotidienapi', models.ForeignKey(orm[u'auquotidien_plugin.auquotidienapi'], null=False)) + )) + db.create_unique(m2m_table_name, ['auquotidiencategoryplugin_id', 'auquotidienapi_id']) + + # Adding M2M table for field apis on 'AuQuotidienActiveFormsPlugin' + m2m_table_name = db.shorten_name(u'auquotidien_plugin_auquotidienactiveformsplugin_apis') + db.create_table(m2m_table_name, ( + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), + ('auquotidienactiveformsplugin', models.ForeignKey(orm[u'auquotidien_plugin.auquotidienactiveformsplugin'], null=False)), + ('auquotidienapi', models.ForeignKey(orm[u'auquotidien_plugin.auquotidienapi'], null=False)) + )) + db.create_unique(m2m_table_name, ['auquotidienactiveformsplugin_id', 'auquotidienapi_id']) + + + def backwards(self, orm): + # Removing M2M table for field apis on 'AuQuotidienCategoryPlugin' + db.delete_table(db.shorten_name(u'auquotidien_plugin_auquotidiencategoryplugin_apis')) + + # Removing M2M table for field apis on 'AuQuotidienActiveFormsPlugin' + db.delete_table(db.shorten_name(u'auquotidien_plugin_auquotidienactiveformsplugin_apis')) + + + models = { + u'attribute_aggregator.attributeitem': { + 'Meta': {'object_name': 'AttributeItem'}, + 'attribute_name': ('django.db.models.fields.CharField', [], {'default': "('OpenLDAProotDSE', 'OpenLDAProotDSE')", 'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'output_name_format': ('django.db.models.fields.CharField', [], {'default': "('urn:oasis:names:tc:SAML:2.0:attrname-format:uri', 'SAMLv2 URI')", 'max_length': '100'}), + 'output_namespace': ('django.db.models.fields.CharField', [], {'default': "('Default', 'Default')", 'max_length': '100'}), + 'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['attribute_aggregator.AttributeSource']", 'null': 'True', 'blank': 'True'}) + }, + u'attribute_aggregator.attributelist': { + 'Meta': {'object_name': 'AttributeList'}, + 'attributes': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'attributes of the list'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['attribute_aggregator.AttributeItem']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + u'attribute_aggregator.attributesource': { + 'Meta': {'object_name': 'AttributeSource'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}), + 'namespace': ('django.db.models.fields.CharField', [], {'default': "('Default', 'Default')", 'max_length': '100'}) + }, + u'auquotidien_plugin.auquotidienactiveformsplugin': { + 'Meta': {'object_name': 'AuQuotidienActiveFormsPlugin', 'db_table': "u'cmsplugin_auquotidienactiveformsplugin'", '_ormbases': ['cms.CMSPlugin']}, + 'apis': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auquotidien_plugin.AuQuotidienAPI']", 'symmetrical': 'False'}), + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), + 'refresh': ('django.db.models.fields.IntegerField', [], {'default': '60'}) + }, + u'auquotidien_plugin.auquotidienapi': { + 'Meta': {'ordering': "('order', 'name')", 'object_name': 'AuQuotidienAPI'}, + 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'allow_redirects': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'hash_algo': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '16', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128', 'blank': 'True'}), + 'order': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'orig': ('django.db.models.fields.CharField', [], {'max_length': '64'}), + 'service_provider': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['saml.LibertyServiceProvider']"}), + 'signature_key': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128', 'blank': 'True'}), + 'timeout': ('django.db.models.fields.IntegerField', [], {'default': '10'}), + 'verify_certificate': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) + }, + u'auquotidien_plugin.auquotidiencategoryplugin': { + 'Meta': {'object_name': 'AuQuotidienCategoryPlugin', 'db_table': "u'cmsplugin_auquotidiencategoryplugin'", '_ormbases': ['cms.CMSPlugin']}, + 'apis': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auquotidien_plugin.AuQuotidienAPI']", 'symmetrical': 'False'}), + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), + 'refresh': ('django.db.models.fields.IntegerField', [], {'default': '60'}) + }, + 'cms.cmsplugin': { + 'Meta': {'object_name': 'CMSPlugin'}, + 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}), + 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), + 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), + 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) + }, + 'cms.placeholder': { + 'Meta': {'object_name': 'Placeholder'}, + 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) + }, + u'idp.attributepolicy': { + 'Meta': {'object_name': 'AttributePolicy'}, + 'allow_attributes_selection': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'ask_consent_attributes': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'attribute_filter_for_sso_from_push_sources': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'filter attributes of push sources with list'", 'null': 'True', 'to': u"orm['attribute_aggregator.AttributeList']"}), + 'attribute_list_for_sso_from_pull_sources': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'attributes from pull sources'", 'null': 'True', 'to': u"orm['attribute_aggregator.AttributeList']"}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'filter_source_of_filtered_attributes': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'forward_attributes_from_push_sources': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'map_attributes_from_push_sources': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'map_attributes_of_filtered_attributes': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'output_name_format': ('django.db.models.fields.CharField', [], {'default': "('urn:oasis:names:tc:SAML:2.0:attrname-format:uri', 'SAMLv2 URI')", 'max_length': '100'}), + 'output_namespace': ('django.db.models.fields.CharField', [], {'default': "('Default', 'Default')", 'max_length': '100'}), + 'send_error_and_no_attrs_if_missing_required_attrs': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'source_filter_for_sso_from_push_sources': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'filter attributes of push sources with sources'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['attribute_aggregator.AttributeSource']"}) + }, + u'saml.libertyprovider': { + 'Meta': {'ordering': "('name',)", 'object_name': 'LibertyProvider'}, + 'ca_cert_chain': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'entity_id': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '200'}), + 'entity_id_sha1': ('django.db.models.fields.CharField', [], {'max_length': '40', 'blank': 'True'}), + 'federation_source': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'metadata': ('django.db.models.fields.TextField', [], {}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '140', 'blank': 'True'}), + 'protocol_conformance': ('django.db.models.fields.IntegerField', [], {'max_length': '10'}), + 'public_key': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '140'}), + 'ssl_certificate': ('django.db.models.fields.TextField', [], {'blank': 'True'}) + }, + u'saml.libertyproviderpolicy': { + 'Meta': {'object_name': 'LibertyProviderPolicy'}, + 'authn_request_signature_check_hint': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}) + }, + u'saml.libertyserviceprovider': { + 'Meta': {'object_name': 'LibertyServiceProvider'}, + 'attribute_policy': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'attribute_policy'", 'null': 'True', 'to': u"orm['idp.AttributePolicy']"}), + 'enable_following_attribute_policy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'enable_following_sp_options_policy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'liberty_provider': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'service_provider'", 'unique': 'True', 'primary_key': 'True', 'to': u"orm['saml.LibertyProvider']"}), + 'policy': ('django.db.models.fields.related.ForeignKey', [], {'default': '1', 'to': u"orm['saml.LibertyProviderPolicy']", 'null': 'True'}), + 'sp_options_policy': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'sp_options_policy'", 'null': 'True', 'to': u"orm['saml.SPOptionsIdPPolicy']"}) + }, + u'saml.spoptionsidppolicy': { + 'Meta': {'object_name': 'SPOptionsIdPPolicy'}, + 'accept_slo': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'accepted_name_id_format': ('authentic2.saml.fields.MultiSelectField', [], {'max_length': '1024', 'blank': 'True'}), + 'ask_user_consent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'authn_request_signed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'default_name_id_format': ('django.db.models.fields.CharField', [], {'default': "'none'", 'max_length': '256'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'encrypt_assertion': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'encrypt_nameid': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'federation_mode': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), + 'forward_slo': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'http_method_for_slo_request': ('django.db.models.fields.IntegerField', [], {'default': '4'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'idp_initiated_sso': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'iframe_logout_timeout': ('django.db.models.fields.PositiveIntegerField', [], {'default': '300'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'needs_iframe_logout': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'prefered_assertion_consumer_binding': ('django.db.models.fields.CharField', [], {'default': "'meta'", 'max_length': '4'}) + } + } + + complete_apps = ['auquotidien_plugin'] diff --git a/portail_citoyen/apps/auquotidien_plugin/models.py b/portail_citoyen/apps/auquotidien_plugin/models.py index d0655c6..b4bf2ff 100644 --- a/portail_citoyen/apps/auquotidien_plugin/models.py +++ b/portail_citoyen/apps/auquotidien_plugin/models.py @@ -39,6 +39,9 @@ class AuQuotidienAPI(models.Model): url = self.service_provider.liberty_provider.entity_id return url.split('/saml/')[0] + def __unicode__(self): + return self.name + @property def provider_id(self): return self.service_provider.liberty_provider.pk @@ -52,10 +55,14 @@ class AuQuotidienAPI(models.Model): class AuQuotidienActiveFormsPlugin(CMSPlugin): refresh = models.IntegerField(verbose_name=_('refresh timeout'), default=60, help_text=_('Number of seconds between two web service calls')) + apis = models.ManyToManyField(AuQuotidienAPI, verbose_name=('au-quotidien API endpoints')) def __unicode__(self): return _('refresh {0}').format(self.refresh) + def copy_relations(self, old_instance): + self.apis = old_instance.apis.all() + class Meta: verbose_name = _('au-quotidien active forms') verbose_name_plural = _('au-quotidien active forms') @@ -63,9 +70,13 @@ class AuQuotidienActiveFormsPlugin(CMSPlugin): class AuQuotidienCategoryPlugin(CMSPlugin): refresh = models.IntegerField(verbose_name=_('refresh timeout'), default=60, help_text=_('Number of seconds between two web service calls')) + apis = models.ManyToManyField(AuQuotidienAPI, verbose_name=('au-quotidien API endpoints')) def __unicode__(self): return _('refresh {0}').format(self.refresh) + def copy_relations(self, old_instance): + self.apis = old_instance.apis.all() + class Meta: verbose_name = _('au-quotidien categories') diff --git a/portail_citoyen/apps/auquotidien_plugin/static/auquotidien_plugin/js/categories.js b/portail_citoyen/apps/auquotidien_plugin/static/auquotidien_plugin/js/categories.js index 679631f..599d9b7 100644 --- a/portail_citoyen/apps/auquotidien_plugin/static/auquotidien_plugin/js/categories.js +++ b/portail_citoyen/apps/auquotidien_plugin/static/auquotidien_plugin/js/categories.js @@ -3,21 +3,28 @@ $(document).ready(function () { var $plugin = $(elt); var $titles = $('.aq-catgr-plg-title', elt); var $categories = $('.aq-catgr-plg-body', elt); + var $empty = $plugin.attr('data-empty'); if ($plugin.data('initialized')) { return; } $plugin.data('initialized', 1); - $titles.hide(); - - // Hide all but first - $categories.slice(1).hide(); - if ($categories.length > 1) { + $titles.hide(); + if ($empty) { + $categories.hide(); + } else { + $categories.slice(1).hide(); + } // Create a selector from titles var $p = $('

'); var $select = $('