Example #1
0
class IOpenLinkInNewWindow(form.Schema):
    """Add open in new window field to link content
    """

    form.order_after(open_link_in_new_window='remoteUrl')
    open_link_in_new_window = schema.Bool(
        title=_(u"open_link_in_new_window"),
        description=_(u"help_open_link_in_new_window"),
        required=False,
        default=False
    )
Example #2
0
    def render(self):
        context = aq_inner(self.context)
        is_important = IImportant(context).is_important
        if is_important:
            IImportant(context).is_important = False
            confirm = _(u'L\'element s\'ha desmarcat com important')
        else:
            IImportant(context).is_important = True
            confirm = _(u'L\'element s\'ha marcat com important')

        IStatusMessage(self.request).addStatusMessage(confirm, type='info')
        self.request.response.redirect(self.context.absolute_url())
Example #3
0
    def render(self):
        context = aq_inner(self.context)
        is_flash = IFlash(context).is_flash
        if is_flash:
            IFlash(context).is_flash = False
            confirm = _(u'L\'element s\'ha desmarcat com flash')
        else:
            IFlash(context).is_flash = True
            confirm = _(u'L\'element s\'ha marcat com flash')

        IStatusMessage(self.request).addStatusMessage(confirm, type='info')
        self.request.response.redirect(self.context.absolute_url())
Example #4
0
    def render(self):
        context = aq_inner(self.context)
        is_outoflist = IOutOfList(context).is_outoflist
        if is_outoflist:
            IOutOfList(context).is_outoflist = False
            confirm = _(u'L\'element s\'ha desmarcat de la blacklist')
        else:
            IOutOfList(context).is_outoflist = True
            confirm = _(u'L\'element s\'ha marcat com a blacklist')

        IStatusMessage(self.request).addStatusMessage(confirm, type='info')
        self.request.response.redirect(self.context.absolute_url())
Example #5
0
    def render(self):
        context = aq_inner(self.context)
        is_inapp = IShowInApp(context).is_inapp
        if is_inapp:
            IShowInApp(context).is_inapp = False
            confirm = _(u'L\'element no es mostra a la App')
        else:
            IShowInApp(context).is_inapp = True
            confirm = _(u'L\'element es mostra a la App')

        IStatusMessage(self.request).addStatusMessage(confirm, type='info')
        self.request.response.redirect(self.context.absolute_url())
Example #6
0
class AddForm(base.AddForm):

    schema = ISmart
    label = _(u"Add Query Portlet")
    description = _(u"This portlet displays a listing of items from a "
                    u"Collection.")

    fields = field.Fields(ISmart)
    fields['sort_on'].mode = 'hidden'
    fields['sort_order'].mode = 'hidden'

    def create(self, data):
        return Assignment(**data)
Example #7
0
class IFlash(Interface):
    """ An object which can be marked as flash
    """

    is_flash = schema.Bool(
        title=_(u"Tells if an object is marked as flash"),
        default=False
    )
Example #8
0
class EditForm(base.EditForm):

    schema = ISmart
    label = _(u"Edit Collection Portlet")
    description = _(u"This portlet displays a listing of items from a "
                    u"Collection.")

    fields = field.Fields(ISmart)
    fields['sort_on'].mode = 'hidden'
    fields['sort_order'].mode = 'hidden'

    def extractData(self):
        data, errors = super(EditForm, self).extractData()
        data['sort_on'] = self.request.form.get('sort_on')
        data['sort_order'] = False if self.request.form.get(
            'sort_order') is None else True
        return data, errors
Example #9
0
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        self.applyChanges(data)

        es = getUtility(IElasticSearch)
        es.create_new_connection()

        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                      "info")
        self.context.REQUEST.RESPONSE.redirect("@@base-controlpanel")
Example #10
0
class BaseCoreControlPanelSettingsForm(controlpanel.RegistryEditForm):
    """ Base settings form """

    schema = IBaseCoreControlPanelSettings
    id = "BaseCoreControlPanelSettingsForm"
    label = _(u"Base settings")
    description = _(u"help_base_core_settings_editform",
                    default=u"Configuracio de Base Core")

    def updateFields(self):
        super(BaseCoreControlPanelSettingsForm, self).updateFields()

    def updateWidgets(self):
        super(BaseCoreControlPanelSettingsForm, self).updateWidgets()

    @button.buttonAndHandler(_('Save'), name=None)
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        self.applyChanges(data)

        es = getUtility(IElasticSearch)
        es.create_new_connection()

        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                      "info")
        self.context.REQUEST.RESPONSE.redirect("@@base-controlpanel")

    @button.buttonAndHandler(_('Cancel'), name='cancel')
    def handleCancel(self, action):
        IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                      "info")
        self.request.response.redirect(
            "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
Example #11
0
class UserPropertiesSoupCatalogFactory(object):
    """ The local user catalog (LUC) properties index factory. Almost all the
        properties have a field type "FullTextIndex" to allow wildcard queries
        on them. However, the FullTextIndex has a limitation its supported type
        of queries, so for certain operations is needed a FieldIndex for the
        username.

        :index id: FieldIndex - The username id for exact queries
        :index notlegit: FieldIndex - Boolean, if the username is not legit
        :index username: FullTextIndex - The username id for wildcard queries
        :index fullname: FullTextIndex - The user display name
        :index email: FullTextIndex - The user e-mail
        :index location: FullTextIndex - The user location
        :index check_ubicacio: FullTextIndex - Boolean, if the ubicacio is visible for all users
        :index ubicacio: FullTextIndex - The user ubicacio
        :index check_telefon: FullTextIndex - Boolean, if the telefon is visible for all users
        :index telefon: FullTextIndex - The user telephone
        :index check_twitter_username: FullTextIndex - Boolean, if the twitter_username is visible for all userss
        :index twitter_username: FullTextIndex - The user Twitter username

        The properties attribute is used to know in advance which properties are
        listed as 'editable' or user accessible.

        The profile_properties is the list of the user properties displayed on
        the profile page, ordered.

        The public_properties is the list of the profile_properties searchable,
        those that have not been added will be private. If you do not add
        public_properties all the fields will be public.

        The directory_properties is the list of the user properties directory
        properties for display on the directory views, ordered.

        The directory_icons is the dict containing the correspondency with the
        field names and the icon.
    """

    properties = [
        _(u'username'),
        _(u'fullname'),
        _(u'email'),
        _(u'description'),
        _(u'location'),
        _(u'home_page')
    ]
    # public_properties = ['email', 'description', 'location', 'home_page']
    profile_properties = ['email', 'description', 'location', 'home_page']
    directory_properties = ['email', 'location']
    directory_icons = {
        'email': 'fa fa-envelope',
        'location': 'fa fa-building-o'
    }

    def __call__(self, context):
        catalog = Catalog()
        idindexer = NodeAttributeIndexer('id')
        catalog['id'] = CatalogFieldIndex(idindexer)
        searchable_blob = NodeAttributeIndexer('searchable_text')
        catalog['searchable_text'] = CatalogTextIndex(searchable_blob)
        notlegit = NodeAttributeIndexer('notlegit')
        catalog['notlegit'] = CatalogFieldIndex(notlegit)

        userindexer = NodeAttributeIndexer('username')
        catalog['username'] = CatalogTextIndex(userindexer)
        fullname = NodeAttributeIndexer('fullname')
        catalog['fullname'] = CatalogTextIndex(fullname)
        email = NodeAttributeIndexer('email')
        catalog['email'] = CatalogTextIndex(email)
        location = NodeAttributeIndexer('location')
        catalog['location'] = CatalogTextIndex(location)
        home_page = NodeAttributeIndexer('home_page')
        catalog['home_page'] = CatalogTextIndex(home_page)
        return catalog
Example #12
0
 def no_items_message(self):
     """Translate custom message for no events in this folder."""
     return _('description_no_events_in_folder',
              default=u'There are currently no events in this folder.')
Example #13
0
class IOutOfList(Interface):
    """ An object which can be marked as outoflist
    """

    is_outoflist = schema.Bool(
        title=_(u"Tells if an object is marked as outoflist"), default=False)
Example #14
0
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                   "info")
     self.request.response.redirect(
         "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
Example #15
0
class ISmart(IPortletDataProvider):
    """A portlet which renders the results of a collection object.
    """

    header = schema.TextLine(title=_(u"Portlet header"),
                             description=_(u"Title of the rendered portlet"),
                             required=True)

    show_header = schema.Bool(title=_(u'label_show_header',
                                      default=u'Show header'),
                              description=_(u'Renders the header'),
                              required=False,
                              default=True)

    description = schema.TextLine(title=_(u"Portlet description"),
                                  description=_(u"Description of the portlet"),
                                  required=False)

    container_view = schema.Choice(
        title=_(u'label_container_view', default=u'Portlet view to use'),
        description=_(u"""Portlet view to use"""),
        vocabulary="base.portlet.smart.AvailablePortletContainerRenderers",
        required=True)

    query = schema.List(
        title=_(u'label_query', default=u'Search terms'),
        description=_(u"""Define the search terms for the items you want to
            list by choosing what to match on.
            The list of results will be dynamically updated"""),
        value_type=schema.Dict(value_type=schema.Field(),
                               key_type=schema.TextLine()),
        required=False)

    form.mode(sort_on='hidden')
    sort_on = schema.TextLine(
        title=_(u'label_sort_on', default=u'Sort on'),
        description=_(u"Sort the collection on this index"),
        required=False,
    )

    form.mode(sort_order='hidden')
    sort_order = schema.Bool(
        title=_(u'label_sort_reversed', default=u'Reversed order'),
        description=_(u'Sort the results in reversed order'),
        required=False,
    )

    sort_folderorder = schema.Bool(
        title=_(u'label_sort_folderorder', default=u'Order as in folder'),
        description=_(u'Override query sort order using folder order'),
        required=False,
    )

    limit = schema.Int(
        title=_(u"Limit"),
        description=_(u"Specify the maximum number of items to show in the "
                      u"portlet. Leave this blank to show all items."),
        required=False)

    random = schema.Bool(
        title=_(u"Select random items"),
        description=_(u"If enabled, items will be selected randomly from the "
                      u"collection, rather than based on its sort order."),
        required=True,
        default=False)

    more_link = schema.TextLine(
        title=_(u"Show more link"),
        description=_(
            u"Link to display in the footer, leave empty to hide it"),
        required=False)

    more_text = schema.TextLine(
        title=_(u"Show more link text"),
        description=_(u"Label the 'Show more link' defined avobe"),
        default=u'+',
        required=False)
Example #16
0
class IImportant(Interface):
    """ An object which can be marked as important
    """

    is_important = schema.Bool(
        title=_(u"Tells if an object is marked as important"), default=False)
Example #17
0
class IBaseCoreControlPanelSettings(Interface):
    """ Global Base settings. This describes records stored in the
    configuration registry and obtainable via plone.registry.
    """

    model.fieldset('General', (u'General'),
                   fields=[
                       'user_properties_extender', 'custom_editor_icons',
                       'elasticsearch'
                   ])

    model.fieldset('Ldap', (u'Ldap'),
                   fields=[
                       'alt_ldap_uri', 'alt_bind_dn', 'alt_bindpasswd',
                       'alt_base_dn', 'groups_query', 'user_groups_query',
                       'create_group_type'
                   ])

    user_properties_extender = schema.Choice(
        title=_(u'User properties extender'),
        vocabulary=u'base5.core.controlpanel.core.user_extenders',
        required=False,
        default=u'')

    custom_editor_icons = schema.List(
        title=_(u'Llista personalitzada d\'icones per l\'editor TinyMCE'),
        description=
        _(u'Cada línia és una fila d\'icones. Si es deixa en blanc s\'agafen els valors per defecte. Han d\'omplir-se fins a 4 files obligatòriament.'
          ),
        value_type=schema.TextLine(),
        required=False,
        default=[])

    elasticsearch = schema.TextLine(
        title=_(u"elasticsearch", default=u"ElasticSearch"),
        description=_(
            u"elasticsearch_help",
            default=u"URL del servidor d'ElasticSearch per aquest site"),
        required=False,
        default=u'localhost',
    )

    alt_ldap_uri = schema.TextLine(
        title=_(u"alt_ldap_uri", default=u"alt_ldap_uri"),
        description=_(u"alt_ldap_uri_help",
                      default=u"URL del servidor ldap per aquest site"),
        required=False,
        default=u'',
    )

    alt_bind_dn = schema.TextLine(
        title=_(u"alt_bind_dn", default=u"alt_bind_dn"),
        description=_(u"alt_bind_dn_help", default=u"LDAP bind dn"),
        required=False,
        default=u'',
    )

    alt_bindpasswd = schema.TextLine(
        title=_(u"alt_bindpasswd", default=u"alt_bindpasswd"),
        description=_(u"alt_bindpasswd_help", default=u"LDAP bind password"),
        required=False,
        default=u'',
    )

    alt_base_dn = schema.TextLine(
        title=_(u"alt_base_dn", default=u"alt_base_dn"),
        description=_(u"alt_base_dn_help", default=u"LDAP base dn"),
        required=False,
        default=u'',
    )

    groups_query = schema.TextLine(
        title=_(u"groups_query", default=u"groups_query"),
        description=_(
            u"groups_query_help",
            default=u"LDAP groups query. Ex: (&(objectClass=groupOfNames))"),
        required=False,
        default=u'',
    )

    user_groups_query = schema.TextLine(
        title=_(u"user_groups_query", default=u"user_groups_query"),
        description=_(
            u"user_groups_query_help",
            default=
            u"LDAP user groups query. Ex: (&(objectClass=groupOfNames)(member=%s))"
        ),
        required=False,
        default=u'',
    )

    create_group_type = schema.TextLine(
        title=_(u"create_group_type", default=u"create_group_type"),
        description=_(u"Type of group to create on ldap",
                      default=u"groupOfNames or groupOfUniqueNames"),
        required=False,
        default=u'groupOfNames',
    )