class SelectIdp(PageForm): label = _(u"select_idp_title", u"Select your identity provider.") def __init__(self, context, request): def title(eid): """the title of entity *eid* (or *eid* itself).""" return getattr(context.get_entity(eid), "title", eid) self.form_fields = Fields( Choice( __name__=u"idp", title=_(u"identity_provider", u"Your identity provider"), vocabulary=SimpleVocabulary( tuple( SimpleTerm(eid, title(eid)) for eid in context.list_idps())), default=context.default_idp, required=True, ), ASCIILine( __name__=u"came_from", default=request.get("came_from", ""), required=False, ), ) super(SelectIdp, self).__init__(context, request) self.form_fields["came_from"].custom_widget = make_hidden( GenericTextWidget) @action(_(u"login", u"login")) def login(self, action, data): c = self.context idp = data["idp"] c.set_idp_cookie(idp) return self.context.authn(idp, data["came_from"])
class IManageableEntity(IEntity): specified_title = TextLine( title=_(u"specified_title_title", u"Title"), description=_(u"specified_title_description", u"An explicitely specified title. If you do not specify a tilte, it defaults to the entity id."), required=False )
class IEntityByUrl(IManageableEntity): url = URI( title=_(u"entity_url_title", "Url"), description=_( u"entity_url_description", u"Url from which this entities' metadata can be fetched.", ), required=True, )
class Update(ZmiMixin, PageForm): label = _(u"entity_metadata_update", u"Metadata update") form_fields = Fields(IUpdateSchema) @action(_(u"update_metadata", u"Update metadata")) def update_(self, action, data): e = self.context e.aq_inner.aq_parent.metadata_by_id(e.id).fetch_metadata( data["clear_existing_metadata"]) self.status = _(u"metadata_updated", u"Metadata updated")
def __init__(self, context, request): def title(eid): """the title of entity *eid* (or *eid* itself).""" return getattr(context.get_entity(eid), "title", eid) self.form_fields = Fields( Choice( __name__=u"idp", title=_(u"identity_provider", u"Your identity provider"), vocabulary=SimpleVocabulary( tuple( SimpleTerm(eid, title(eid)) for eid in context.list_idps())), default=context.default_idp, required=True, ), ASCIILine( __name__=u"came_from", default=request.get("came_from", ""), required=False, ), ) super(SelectIdp, self).__init__(context, request) self.form_fields["came_from"].custom_widget = make_hidden( GenericTextWidget)
def _delOb(self, id): e = self.get_entity(_unquote(id)) if e is None: return if getattr(e, "protected", False): raise TypeError( _(u"protected_entity_deletion", u"Cannot delete a protected entity")) self.del_entity(e.id)
def _delOb(self, id): e = self.get_entity(_unquote(id)) if e is None: return if getattr(e, "protected", False): raise TypeError(_(u"protected_entity_deletion", u"Cannot delete a protected entity") ) self.del_entity(e.id)
def __init__(self, context, request): def title(eid): """the title of entity *eid* (or *eid* itself).""" return getattr(context.get_entity(eid), "title", eid) self.form_fields = Fields( Choice( __name__=u"idp", title=_(u"identity_provider", u"Your identity provider"), vocabulary=SimpleVocabulary( tuple(SimpleTerm(eid, title(eid)) for eid in context.list_idps()) ), default=context.default_idp, required=True, ), ASCIILine( __name__=u"came_from", default=request.get("came_from", ""), required=False, ), ) super(SelectIdp, self).__init__(context, request) self.form_fields["came_from"].custom_widget = make_hidden(GenericTextWidget)
def __call__(self): r = self.request IStatusMessage(r).addStatusMessage(_(u"SAML request failed")) r.response.redirect(getToolByName(self.context, "portal_url")())
def update_(self, action, data): e = self.context e.aq_inner.aq_parent.metadata_by_id(e.id).fetch_metadata(data["clear_existing_metadata"]) self.status = _(u"metadata_updated", u"Metadata updated")
def update_(self, action, data): e = self.context e.aq_inner.aq_parent.metadata_by_id(e.id).fetch_metadata( data["clear_existing_metadata"]) self.status = _(u"metadata_updated", u"Metadata updated")
class IUpdateSchema(Interface): clear_existing_metadata = Bool( title=_(u"clear_existing_metadata", u"Clear existing metadata"), required=False, )