Merge branch 'fepem'

This commit is contained in:
Benjamin Dauvergne 2011-01-04 01:43:39 +01:00
commit 6f7c651086
7 changed files with 362 additions and 75 deletions

View File

@ -6,6 +6,9 @@ import modules.configuration
import authentic.admin.root
import modules.afterjobs
import modules.callback
import modules.admin_settings
import modules.qommon_template
import modules.authentic_saml
get_publisher_class().register_translation_domain('ifef')
authentic.admin.root.register_page('afterjobs',

View File

@ -0,0 +1,58 @@
import authentic.admin.settings as settings
from authentic.form import *
import qommon.template
from qommon import get_cfg
from quixote import get_publisher, redirect
import authentic.identities as identities
STYLESHEET_URL = 'stylesheet_url'
REFERER_PREFIX_URL = 'referer_prefix_url'
CUSTOM_DOMAIN = 'custom_domain'
REGISTRATION_FIELD = 'registration_fields'
THEME = 'theme'
class NewLibertyProviderUI(settings.LibertyProviderUI):
def edit_form(self):
form = super(NewLibertyProviderUI, self).edit_form()
form.add(StringWidget, STYLESHEET_URL,
title=_('Customized stylesheet URL'),
value=self.lp.get(STYLESHEET_URL, ''),
hint=_('The URL must be https if authentic also use https'))
form.add(StringWidget, REFERER_PREFIX_URL,
title=_('Prefix URL of the HTTP_REFERER'),
value=self.lp.get(REFERER_PREFIX_URL, ''),
hint=_('Used to find which service initiated a request to Authentic'))
names = [None] + [x[0] for x in qommon.template.get_themes().iteritems()]
form.add(SingleSelectWidget, THEME,
title=_('Custom theme'),
value=self.lp.get(THEME,None),
hint=_('Theme to use when an interaction is initated by this service'),
options=names)
form.add(StringWidget, CUSTOM_DOMAIN,
title=_('Custom domain'),
value=self.lp.get(CUSTOM_DOMAIN,None),
hint=_('If the IdP is published on this domain, the used theme will the custom theme for this service.'),
options=names)
form.add(identities.WidgetList, REGISTRATION_FIELD,
title=_('Registration fields'),
element_type=StringWidget,
value=self.lp.get(REGISTRATION_FIELD,[]),
hint=_('List of specific fields to show on the registration page.'))
return form
def edit_submit(self):
return super(NewLibertyProviderUI, self).edit_submit()
class NewLibertyProvidersDir(settings.LibertyProvidersDir):
def submit_new(self, form, key_provider_id=None):
lpk, error = super(NewLibertyProvidersDir, self).submit_new(form,
key_provider_id)
if not error and form.get_widget(STYLESHEET_URL):
v = {}
for k in (STYLESHEET_URL, REFERER_PREFIX_URL, THEME, CUSTOM_DOMAIN, REGISTRATION_FIELD):
v[k] = form.get_widget(k).parse()
get_cfg('providers').get(lpk).update(v)
get_publisher().write_cfg()
return lpk, error
settings.LibertyProviderUI = NewLibertyProviderUI
settings.LibertyProvidersDir = NewLibertyProvidersDir

View File

@ -0,0 +1,11 @@
from quixote import get_session
import authentic.liberty.saml2
import qommon.misc as misc
# Yeah another monkey patch
old_invoke_login = authentic.liberty.saml2.RootDirectory.invoke_login
def invoke_login(self, login, query):
print 'my invoke login'
get_session().service = misc.get_provider_key(login.remoteProviderId)
return old_invoke_login(self, login, query)
authentic.liberty.saml2.RootDirectory.invoke_login = invoke_login

View File

@ -0,0 +1,44 @@
import qommon.template as template
from quixote import get_request, get_publisher, get_session
from qommon import get_cfg
from admin_settings import STYLESHEET_URL, REFERER_PREFIX_URL, THEME, \
CUSTOM_DOMAIN
__old_decorate = template.decorate
def decorate(body, response):
request = get_request()
referer = request.environ.get('HTTP_REFERER')
domain = request.environ.get('SERVER_NAME')
session = get_session()
more_css = []
body_class = []
theme = None
stylesheet_url = None
requesting_service = None
for key, value in get_cfg('providers', {}).iteritems():
custom_domain = value.get(CUSTOM_DOMAIN)
referer_prefix_url = value.get(REFERER_PREFIX_URL)
if custom_domain == domain or \
(request.form and request.form.get('service') == key) or \
(referer_prefix_url and referer and referer.startswith(referer_prefix_url)) or \
getattr(session, 'service', None) == key:
theme = value.get(THEME)
requesting_service = key
stylesheet_url = value.get(STYLESHEET_URL)
break
if requesting_service:
session.service = requesting_service
body_class.append(requesting_service)
if stylesheet_url:
more_css.append(stylesheet_url)
if theme:
get_publisher().cfg['branding']['theme'] = theme
response.filter.update({'more_css': more_css, 'body_class': body_class})
return __old_decorate(body, response)
template.decorate = decorate
import authentic.sessions
authentic.sessions.BasicSession._has_info_keys.append('service')

View File

@ -1,6 +1,7 @@
from qommon import get_cfg, get_logger
from quixote import redirect
from quixote import redirect, get_session
from authentic.form import *
from quixote.html import htmltext
import qommon.errors as errors
import qommon.template as template
import authentic.identities as identities
@ -10,6 +11,8 @@ import authentic.admin.configuration as configuration
import urllib2
import captcha
from callback import BatchJob, XmlRpcAction
import lasso
import authentic.misc as misc
schema = (('PART_EMP', _('Particulier-employeur')),
(_('Salarie du Particulier-employeur'),
@ -50,17 +53,34 @@ def check_classification(classification):
class IfefRootDirectory(authentic.root.RootDirectory):
_q_exports = authentic.root.RootDirectory._q_exports + [ 'register2' ]
def _q_traverse(self, path):
request = get_request()
if request.form and request.form.get('service'):
service = request.form['service']
get_session().service = service
request.service = service
return super(IfefRootDirectory, self)._q_traverse(path)
def register2 (self):
return self.register(version=2)
def register (self, version=1):
identities_cfg = get_cfg('identities', {})
session = get_session()
if not identities_cfg.get('creation') in ('self', 'moderated'):
raise errors.TraversalError()
form = Form(enctype="multipart/form-data")
for field in identities.get_store_class().fields:
fields = identities.get_store_class().fields
keys = []
if getattr(session, 'service', None):
keys = get_cfg('providers',{}).get(session.service, {}) \
.get('registration_fields')
if keys:
fields = [ field for field in fields \
if field.key in keys ]
for field in fields:
if getattr(field, str('on_register'), True):
field.add_to_form(form) and None
@ -79,51 +99,58 @@ vous connecter au portail de l'IFEF. Il peut contenir seulement des lettres et d
else:
form.add(HtmlWidget, htmltext('<p>%s</p>') % _('A password will be mailed to you.'))
classification = get_request().form.get('classification')
if classification:
if not check_classification(classification):
classification = None
if version == 1:
s='<label><p><em>%s:</em></p></label><select name="classification" size="18">' % _('Vous etes')
for q in schema:
if isinstance(q[1], tuple):
s += '<optgroup label="%s">' % q[0]
for r in q[1:]:
code, text = r
add_classification = True
if keys and 'classification' not in keys:
add_classification = False
if add_classification:
classification = get_request().form.get('classification')
if classification:
if not check_classification(classification):
classification = None
if version == 1:
s='<label><p><em>%s:</em></p></label><select name="classification" size="18">' % _('Vous etes')
for q in schema:
if isinstance(q[1], tuple):
s += '<optgroup label="%s">' % q[0]
for r in q[1:]:
code, text = r
if code == classification:
selected = 'selected="1"'
else:
selected = ''
s += '<option %s value="%s">%s</option>\n' % (selected, code, text)
s += '</optgroup>\n'
else:
code, text = q
if code == classification:
selected = 'selected="1"'
else:
selected = ''
s += '<option %s value="%s">%s</option>\n' % (selected, code, text)
s += '</optgroup>\n'
s += '</select>'
else:
s='<label><p><em>%s:</em></p></label><cite style="display: block; margin: 1em; font-size: 70%%">' % _('Vous etes')
for i, q in enumerate(schema):
if isinstance(q, tuple):
s += '<p>%s' % q[0]
for j, q in enumerate(q[1:]):
s += '<input id="s%s-%s" value="%s-%s" type="radio" name="RadioGroup">%s</input>' % (i, j, i, j, q)
s += '</p>\n'
else:
code, text = q
if code == classification:
selected = 'selected="1"'
else:
selected = ''
s += '<option %s value="%s">%s</option>\n' % (selected, code, text)
s += '</select>'
else:
s='<label><p><em>%s:</em></p></label><cite style="display: block; margin: 1em; font-size: 70%%">' % _('Vous etes')
for i, q in enumerate(schema):
if isinstance(q, tuple):
s += '<p>%s' % q[0]
for j, q in enumerate(q[1:]):
s += '<input id="s%s-%s" value="%s-%s" type="radio" name="RadioGroup">%s</input>' % (i, j, i, j, q)
s += '</p>\n'
s += '<p><input id="s%s" value="%s" type="radio" name="RadioGroup">%s</input></p>' % (i, i, q)
s+='</cite>'
else:
s += '<p><input id="s%s" value="%s" type="radio" name="RadioGroup">%s</input></p>' % (i, i, q)
s+='</cite>'
if get_request().get_method() == 'POST' and not classification:
if add_classification and get_request().get_method() == 'POST' \
and not classification:
form.set_error('username', ' ')
form.add(HtmlWidget, 'erreur', htmltext('<div class="error"><strong>%s</strong></div>') % _('Vous devez choisir une classification'))
elif get_request().get_method() == 'GET':
get_request().form = {}
form.add(HtmlWidget, 'classification', htmltext(s))
if add_classification:
form.add(HtmlWidget, 'classification', htmltext(s))
# domain name: fepem
re_captcha_public_key = '6LcIULoSAAAAAIbUohbBeHCcUeWAt74sjvjK6w5W'
re_captcha_private_key = '6LcIULoSAAAAADfaFk2E9x9G2FgpSsnNIfUV1rlS'
@ -198,5 +225,29 @@ RecaptchaOptions = { "theme" : "white", "lang" : "fr" };
get_response().add_after_job('''Send registration to Neogia, email = %r,\
classification = %r''' % (email, classification), BatchJob(action))
def get_idp_sso_list [html] (self):
if not get_cfg('providers', {}).items():
return ''
'<ul>'
for klp, lp in get_cfg('providers', {}).items():
if lp['role'] == lasso.PROVIDER_ROLE_IDP:
continue # only allows initiated login to service providers
if lp.get('idp_initiated_sso', True) is False:
continue
try:
provider, label = misc.get_provider_and_label(klp)
except KeyError:
continue
if hasattr(provider, str('getProtocolConformance')) and \
provider.getProtocolConformance() == lasso.PROTOCOL_SAML_2_0:
url = 'saml/sp/%s/login' % klp
else:
url = 'liberty/sp/%s/login' % klp
'<li class="%s"><a href="%s">%s</a></li>' % (
klp,
url, htmltext(_('Log on %s') % label))
'</ul>'
from qommon.publisher import get_publisher_class
get_publisher_class().root_directory_class = IfefRootDirectory

102
po/fr.po
View File

@ -13,10 +13,34 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n>1;\n"
#: ../extra/ifef.py:13 ../extra/modules/afterjobs.ptl:32
#: ../extra/ifef.py:15 ../extra/modules/afterjobs.ptl:32
msgid "Neogia registration jobs"
msgstr "Appel d'enregistrement à Neogia"
#: ../extra/modules/admin_settings.py:15
msgid "Customized stylesheet URL"
msgstr ""
#: ../extra/modules/admin_settings.py:17
msgid "The URL must be https if authentic also use https"
msgstr ""
#: ../extra/modules/admin_settings.py:19
msgid "Prefix URL of the HTTP_REFERER"
msgstr ""
#: ../extra/modules/admin_settings.py:21
msgid "Used to find which service initiated a request to Authentic"
msgstr ""
#: ../extra/modules/admin_settings.py:24
msgid "Custom theme"
msgstr ""
#: ../extra/modules/admin_settings.py:26
msgid "Theme to use when an interaction is initated by this service"
msgstr ""
#: ../extra/modules/configuration.py:6
msgid "XMLRPC Neogia registration URL"
msgstr ""
@ -29,67 +53,67 @@ msgstr ""
msgid "Condition d'utilisation"
msgstr "Conditions d'utilisation"
#: ../extra/modules/root.ptl:14
#: ../extra/modules/root.ptl:17
msgid "Particulier-employeur"
msgstr ""
#: ../extra/modules/root.ptl:15
#: ../extra/modules/root.ptl:18
msgid "Salarie du Particulier-employeur"
msgstr "Salarié du Particulier-employeur"
#: ../extra/modules/root.ptl:16 ../extra/modules/root.ptl:19
#: ../extra/modules/root.ptl:19 ../extra/modules/root.ptl:22
msgid "inscrit"
msgstr ""
#: ../extra/modules/root.ptl:17 ../extra/modules/root.ptl:20
#: ../extra/modules/root.ptl:20 ../extra/modules/root.ptl:23
msgid "pas inscrit en formation"
msgstr ""
#: ../extra/modules/root.ptl:18
#: ../extra/modules/root.ptl:21
msgid "Assistante(e) maternel(le)"
msgstr ""
#: ../extra/modules/root.ptl:21
#: ../extra/modules/root.ptl:24
msgid "Formateur ou directeur d'un organisme de formation"
msgstr ""
#: ../extra/modules/root.ptl:22
#: ../extra/modules/root.ptl:25
msgid "labellise par l'Institut-Fepem"
msgstr "labellisé par l'Institut-Fepem"
#: ../extra/modules/root.ptl:23
#: ../extra/modules/root.ptl:26
msgid "souhaitant etre labellise"
msgstr "souhaitant être labellisé"
#: ../extra/modules/root.ptl:24
#: ../extra/modules/root.ptl:27
msgid "pas encore labellise"
msgstr "pas encore labéllisé"
#: ../extra/modules/root.ptl:25
#: ../extra/modules/root.ptl:28
msgid "Formateur consultant souhaitant entrer dans la communaute"
msgstr "Formateur consultant souhaitant entrer dans la communauté"
#: ../extra/modules/root.ptl:26
#: ../extra/modules/root.ptl:29
msgid "Salarie d'un organisme public, d'une association ou d'une organisation"
msgstr ""
#: ../extra/modules/root.ptl:27
#: ../extra/modules/root.ptl:30
msgid "partenaire de l'Institut-Fepem"
msgstr ""
#: ../extra/modules/root.ptl:28
#: ../extra/modules/root.ptl:31
msgid "souhaitant devenir partenaire"
msgstr ""
#: ../extra/modules/root.ptl:29
#: ../extra/modules/root.ptl:32
msgid "pas encore partenaire"
msgstr ""
#: ../extra/modules/root.ptl:30
#: ../extra/modules/root.ptl:33
msgid "Un professionnel de la formation"
msgstr ""
#: ../extra/modules/root.ptl:31
#: ../extra/modules/root.ptl:34
msgid ""
"Une personne interessee par le sujet de la professionnalisation de l'emploi "
"familial"
@ -97,11 +121,11 @@ msgstr ""
"Une personne interessée par le sujet de la professionnalisation de l'emploi "
"familial"
#: ../extra/modules/root.ptl:69
#: ../extra/modules/root.ptl:72
msgid "Username"
msgstr "Identifiant"
#: ../extra/modules/root.ptl:71
#: ../extra/modules/root.ptl:72
msgid ""
"C'est cet identifiant qui vous permettra de vous connecter au portail de "
"l'IFEF. Il peut contenir seulement des lettres et des chiffres."
@ -136,9 +160,45 @@ msgid "Cancel"
msgstr "Annuler"
#: ../extra/modules/root.ptl:180 ../extra/modules/root.ptl:181
=======
#: ../extra/modules/root.ptl:76
msgid "Password"
msgstr "Mot de passe"
#: ../extra/modules/root.ptl:78
msgid "A password will be mailed to you."
msgstr "Un mot de passe vous sera envoyé par courriel."
#: ../extra/modules/root.ptl:85 ../extra/modules/root.ptl:107
msgid "Vous etes"
msgstr "Vous êtes"
#: ../extra/modules/root.ptl:121
msgid "Vous devez choisir une classification"
msgstr ""
#: ../extra/modules/root.ptl:148
msgid "J'accepte les conditions d'utilisation"
msgstr ""
#: ../extra/modules/root.ptl:157
msgid "Submit"
msgstr "Valider"
#: ../extra/modules/root.ptl:158
msgid "Cancel"
msgstr "Annuler"
#: ../extra/modules/root.ptl:178 ../extra/modules/root.ptl:179
>>>>>>> Update translation:po/fr.po
msgid "Registration"
msgstr "Inscription"
#: ../extra/modules/root.ptl:219
#, python-format
msgid "Log on %s"
msgstr ""
#: ../extra/modules/afterjobs.ptl:38
#, python-format
msgid "Run job %s"
@ -296,11 +356,11 @@ msgstr ""
#: ../extra/modules/store.py:71
msgid "votre page web personnelle"
msgstr ""
msgstr "Votre page web personelle"
#: ../extra/modules/store.py:72
msgid "Adresse telephonie IP"
msgstr ""
msgstr "Addresse de téléphonie par internet"
#: ../extra/modules/store.py:73
msgid "exemple: skype, sip, gtalk"

View File

@ -16,10 +16,34 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../extra/ifef.py:13 ../extra/modules/afterjobs.ptl:32
#: ../extra/ifef.py:15 ../extra/modules/afterjobs.ptl:32
msgid "Neogia registration jobs"
msgstr ""
#: ../extra/modules/admin_settings.py:15
msgid "Customized stylesheet URL"
msgstr ""
#: ../extra/modules/admin_settings.py:17
msgid "The URL must be https if authentic also use https"
msgstr ""
#: ../extra/modules/admin_settings.py:19
msgid "Prefix URL of the HTTP_REFERER"
msgstr ""
#: ../extra/modules/admin_settings.py:21
msgid "Used to find which service initiated a request to Authentic"
msgstr ""
#: ../extra/modules/admin_settings.py:24
msgid "Custom theme"
msgstr ""
#: ../extra/modules/admin_settings.py:26
msgid "Theme to use when an interaction is initated by this service"
msgstr ""
#: ../extra/modules/configuration.py:6
msgid "XMLRPC Neogia registration URL"
msgstr ""
@ -32,77 +56,77 @@ msgstr ""
msgid "Condition d'utilisation"
msgstr ""
#: ../extra/modules/root.ptl:14
#: ../extra/modules/root.ptl:17
msgid "Particulier-employeur"
msgstr ""
#: ../extra/modules/root.ptl:15
#: ../extra/modules/root.ptl:18
msgid "Salarie du Particulier-employeur"
msgstr ""
#: ../extra/modules/root.ptl:16 ../extra/modules/root.ptl:19
#: ../extra/modules/root.ptl:19 ../extra/modules/root.ptl:22
msgid "inscrit"
msgstr ""
#: ../extra/modules/root.ptl:17 ../extra/modules/root.ptl:20
#: ../extra/modules/root.ptl:20 ../extra/modules/root.ptl:23
msgid "pas inscrit en formation"
msgstr ""
#: ../extra/modules/root.ptl:18
#: ../extra/modules/root.ptl:21
msgid "Assistante(e) maternel(le)"
msgstr ""
#: ../extra/modules/root.ptl:21
#: ../extra/modules/root.ptl:24
msgid "Formateur ou directeur d'un organisme de formation"
msgstr ""
#: ../extra/modules/root.ptl:22
#: ../extra/modules/root.ptl:25
msgid "labellise par l'Institut-Fepem"
msgstr ""
#: ../extra/modules/root.ptl:23
#: ../extra/modules/root.ptl:26
msgid "souhaitant etre labellise"
msgstr ""
#: ../extra/modules/root.ptl:24
#: ../extra/modules/root.ptl:27
msgid "pas encore labellise"
msgstr ""
#: ../extra/modules/root.ptl:25
#: ../extra/modules/root.ptl:28
msgid "Formateur consultant souhaitant entrer dans la communaute"
msgstr ""
#: ../extra/modules/root.ptl:26
#: ../extra/modules/root.ptl:29
msgid "Salarie d'un organisme public, d'une association ou d'une organisation"
msgstr ""
#: ../extra/modules/root.ptl:27
#: ../extra/modules/root.ptl:30
msgid "partenaire de l'Institut-Fepem"
msgstr ""
#: ../extra/modules/root.ptl:28
#: ../extra/modules/root.ptl:31
msgid "souhaitant devenir partenaire"
msgstr ""
#: ../extra/modules/root.ptl:29
#: ../extra/modules/root.ptl:32
msgid "pas encore partenaire"
msgstr ""
#: ../extra/modules/root.ptl:30
#: ../extra/modules/root.ptl:33
msgid "Un professionnel de la formation"
msgstr ""
#: ../extra/modules/root.ptl:31
#: ../extra/modules/root.ptl:34
msgid ""
"Une personne interessee par le sujet de la professionnalisation de l'emploi "
"familial"
msgstr ""
#: ../extra/modules/root.ptl:69
#: ../extra/modules/root.ptl:72
msgid "Username"
msgstr ""
#: ../extra/modules/root.ptl:71
#: ../extra/modules/root.ptl:72
msgid ""
"C'est cet identifiant qui vous permettra de vous connecter au portail de "
"l'IFEF. Il peut contenir seulement des lettres et des chiffres."
@ -137,9 +161,45 @@ msgid "Cancel"
msgstr ""
#: ../extra/modules/root.ptl:180 ../extra/modules/root.ptl:181
=======
#: ../extra/modules/root.ptl:76
msgid "Password"
msgstr ""
#: ../extra/modules/root.ptl:78
msgid "A password will be mailed to you."
msgstr ""
#: ../extra/modules/root.ptl:85 ../extra/modules/root.ptl:107
msgid "Vous etes"
msgstr ""
#: ../extra/modules/root.ptl:121
msgid "Vous devez choisir une classification"
msgstr ""
#: ../extra/modules/root.ptl:148
msgid "J'accepte les conditions d'utilisation"
msgstr ""
#: ../extra/modules/root.ptl:157
msgid "Submit"
msgstr ""
#: ../extra/modules/root.ptl:158
msgid "Cancel"
msgstr ""
#: ../extra/modules/root.ptl:178 ../extra/modules/root.ptl:179
>>>>>>> Update translation:po/ifef.pot
msgid "Registration"
msgstr ""
#: ../extra/modules/root.ptl:219
#, python-format
msgid "Log on %s"
msgstr ""
#: ../extra/modules/afterjobs.ptl:38
#, python-format
msgid "Run job %s"