예제 #1
0
    def configletThumbnails(self, REQUEST=None):
        """Provides a structure for configlet thumbnails as
        [{'label': xxx, 'url': xxx, 'cssclass': xxx}, ...]
        """

        if REQUEST is None:
            REQUEST = self.REQUEST

        out = []
        tab_defs = (
            # (translated title, template id),
            (ArticleMessageFactory(u'label_article_preferences',
                                   default=u'PloneArticle Preferences'),
             'pa_management_form'),
            (PloneMessageFactory(u'models',
                                 default=u'Models'), 'pa_manage_models_form'),
            (PloneMessageFactory(u'images',
                                 default=u'Images'), 'pa_manage_images_form'),
            (PloneMessageFactory(u'files', default=u'Attachments'),
             'pa_manage_attachments_form'),
            (PloneMessageFactory(u'links',
                                 default=u'Links'), 'pa_manage_links_form'))

        for message, template_id in tab_defs:
            thumbnail = {
                'label': message,
                'url': self.absolute_url() + '/' + template_id,
                'css_class': None
            }
            if REQUEST.URL.endswith(template_id):
                thumbnail['css_class'] = "selected"
            out.append(thumbnail)
        return out
예제 #2
0
    def get_title(self):
        default_title = DEFAULT_ROLE_TITLES.get(
            self.plonerole, PloneMessageFactory(self.plonerole))

        workflow = get_workflow_for(self.context)
        if workflow:
            return PloneMessageFactory('%s--ROLE--%s' %
                                       (workflow.getId(), self.plonerole),
                                       default=translate(default_title,
                                                         context=self.request))

        else:
            return default_title
class IMonetCalendarPortlet(IPortletDataProvider):

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

    calendar_section_path = schema.Choice(title=_(u'Calendar Section'),
                                          description=_('calendar_section_path',
                                                        u'Calendar section providing the events to be shown in the portlet'),
                                          required=True,
                                          source=SearchableTextSourceBinder({'object_provides': IMonetCalendarSection.__identifier__},
                                                                            default_query='path: '))

    days_before = schema.Int(title=_('Days before'),
                             description=_('days_before_help',
                                           u'Number of days, before the current date, to be included in the search.\n '
                                           u'Keep 0 to show only today events.'),
                             required=True,
                             min=0,
                             default=0)

    days_after = schema.Int(title=_('Days after'),
                            description=_('days_after_help',
                                           u'Number of days, after the current date, to be included in the search.\n '
                                           u'Keep 0 to show only today events.'),
                            required=True,
                            min=0,
                            default=7)

    header_as_link = schema.Bool(title=_(u"Header as link"),
                              description=_('header_as_link_help',
                                            _(u"Tick this box if you want that the portlet header will "
                                               "be a link to then related calendar.")
                                             ),
                              required=True,
                              default=True)


    omit_border = schema.Bool(title=_(u"Hide portlet"),
                              description=_('hide_portlet_help',
                                            _(u"Tick this box if you want to render the text above "
                                               "without the standard header, border or footer.")
                                             ),
                              required=True,
                              default=False)


    timeout = schema.Int(title=_(u'Cache timeout'),
                         description=_(u'Expiration time for cached results (in minutes)'),
                         required=True,
                         default=0)
예제 #4
0
    def __init__(self, context, request):
        super(BatchBookView, self).__init__(context, request)
        self.icon = self.portal_url + \
            "/++resource++bika.lims.images/batchbook_big.png"
        self.context_actions = {}
        self.contentFilter = {"sort_on":"created"}
        self.title = context.Title()
        self.Description = context.Description()
        self.show_select_all_checkbox = True
        self.show_sort_column = False
        self.show_column_toggles = True
        self.show_select_row = False
        self.show_select_column = True
        self.pagesize = 0
        self.form_id = "list"
        self.page_start_index = 0
        self.show_categories = True
        self.expand_all_categories = True

        self.insert_submit_button = False

        request.set('disable_plone.rightcolumn', 1)

        self.columns = {
            'AnalysisRequest': {
                'title': _('Analysis Request'),
                'index': 'id',
                'sortable': True,
            },
            'Batch': {
                'title': _('Batch'),
                'sortable': True,
            },
            'Sub-group': {
                'title': _('Sub-group'),
                'sortable': True,
            },
            'created': {
                'title': PloneMessageFactory('Date Created'),
                'index': 'created',
                'toggle': False,
            },
            'state_title': {
                'title': _('State'),
                'index': 'review_state'
            },
        }

        self.review_states = [
            {'id': 'default',
             'title': _('All'),
             'contentFilter': {},
             'columns': ['AnalysisRequest',
                         'Batch',
                         'Sub-group',
                         'created',
                         'state_title'],
             },
        ]
예제 #5
0
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        self.applyChanges(data)

        self.status = PloneMessageFactory('Changes saved.')
def find_matches_in_object(matcher, obj):
    """ Find location of search strings """
    results = []
    path = "/".join(obj.getPhysicalPath())
    base = aq_base(obj)
    try:
        title = safe_unicode(base.Title())
    except AttributeError:
        # Title might be acquired from parent for some types, which breaks
        # now that we have stripped away the acquisition chain with
        # aq_base.
        title = u""
    mobj = matcher.finditer(title)
    for x in mobj:
        start, end = x.span()
        results.append({
            "path":
            path,
            "url":
            obj.absolute_url(),
            "line":
            "title",
            "linecol":
            translate(PloneMessageFactory(u"Title"), context=obj.REQUEST),
            "pos":
            "%d" % start,
            "text":
            getLinePreview(title, start, end),
        })
    text_fields = getTextFields(obj)
    if text_fields:
        for field in text_fields:
            if hasattr(field, "widget"):
                label = translate(field.widget.label, context=obj.REQUEST)
            else:
                label = translate(field.title, context=obj.REQUEST)
            text = getRawTextField(obj, field)
            if not text:
                continue
            mobj = matcher.finditer(text)
            for x in mobj:
                start, end = x.span()
                results.append({
                    "path":
                    path,
                    "url":
                    obj.absolute_url(),
                    "line":
                    "%s %d" % (field.__name__, getLineNumber(text, start)),
                    "linecol":
                    "%s %d" % (label, getLineNumber(text, start)),
                    "pos":
                    "%d" % start,
                    "text":
                    getLinePreview(text, start, end),
                })
    return results
예제 #7
0
    def getPath(self, site='default', menuid=''):
        """ Given a menuid or object, it returns a list of dictionaries
            with path nav info (breadcrumbs) """

        catalog = getToolByName(self.context, 'portal_catalog')
        language = self.request.get('LANGUAGE', 'en')

        navManager = getToolByName(self.context, 'portal_navigationmanager')

        siteobj = getattr(navManager, site, None)

        if siteobj is not None:
            if language != 'en' and siteobj.hasTranslation(language):
                siteobj = siteobj.getTranslation(language)
                site = siteobj.getId()

        bpath = []
        menuobj = None
        if menuid == '':
            bpath = self.createObjPathFromObject(self.context)
        else:
            #find menuitem with id=menuid
            menubrains = catalog(getId=menuid,
                                 portal_type='NavigationItem',
                                 Language=language)
            if not menubrains:
                menubrains = catalog(getId=menuid,
                                     portal_type='NavigationItem',
                                     Language='en')

            if menubrains:
                menuobj = menubrains[0].getObject()
                #create the base path for menuobj
                bpath = self.createPathFromObject(site, menuobj)

        homeobj = False
        if siteobj is not None:
            if hasattr(siteobj, 'home'):
                siteobj = getattr(siteobj, 'home')
                homeobj = True
        if homeobj:
            home_title = siteobj.Title()
        else:
            home_title = PloneMessageFactory('Home')
        # create first item Home (=first item of navmanager)
        # and insert on start of path
        if siteobj is not None:
            home = {
                'id': siteobj.getId(),
                'url': siteobj.getUrl(),
                'title': home_title,
                'description': siteobj.Description()
            }
            bpath.insert(0, home)

        return bpath
예제 #8
0
def translateHelper(domain, msgid, language):
    """ Translate helper
    """
    if domain == 'plone':
        return translate(PloneMessageFactory(msgid),
                         target_language=language).encode('utf8')
    elif domain == 'eea.translations':
        return translate(eeaTranslationFactory(msgid),
                         target_language=language).encode('utf8')

    return msgid
예제 #9
0
파일: view.py 프로젝트: talkara/slt.theme
 def __call__(self):
     url = self.context.absolute_url()
     message = PloneMessageFactory(u'Welcome! You are now logged in.')
     portal_state = self.context.restrictedTraverse('@@plone_portal_state')
     member = portal_state.member()
     if not member.getProperty('fullname'):
         url = '{}/@@personal-information'.format(portal_state.portal_url())
         message = _(u'first-time-login',
                     default=u'Please fill your personal information.')
     IStatusMessage(self.request).addStatusMessage(message, type='info')
     return self.request.response.redirect(url)
예제 #10
0
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        self.applyChanges(data)

        url = getMultiAdapter(
            (self.context, self.request), name='absolute_url')() + '/view'
        self.request.response.redirect(url)

        self.context.plone_utils.addPortalMessage(
            PloneMessageFactory('Changes saved.'))
예제 #11
0
 def kind(self):
     return PloneMessageFactory(u'forwarding-added',
                                default=u'Forwarding added')
예제 #12
0
from zope.interface import implementer
from zope.interface import implements
import pkg_resources

try:
    pkg_resources.get_distribution('plone.rest')

except pkg_resources.DistributionNotFound:
    is_rest_available = False

else:
    is_rest_available = True
    from plone.rest.traverse import RESTWrapper

DEFAULT_ROLE_TITLES = {
    'Reader': PloneMessageFactory(u"title_can_view", default=u"Can view"),
    'Editor': PloneMessageFactory(u"title_can_edit", default=u"Can edit"),
    'Contributor': PloneMessageFactory(u"title_can_add", default=u"Can add"),
    'Reviewer': PloneMessageFactory(u"title_can_review",
                                    default=u"Can review"),
}


class DynamicRolesUtility(object):
    implements(ISharingPageRole)

    def __init__(self, plonerole):
        self.plonerole = plonerole

    @property
    def title(self):
예제 #13
0
 def label(self):
     return self.translate_to_all_languages(
         PloneMessageFactory(self.entry.transition))
예제 #14
0
class DiscussionSchema(form.Schema):
    """A discussion.
    """
    title = schema.TextLine(title=PloneMessageFactory(u"Title"))
    description = schema.Text(title=_(u"Subject"))
    file = NamedBlobFile(title=_(u"File"), required=False)
예제 #15
0
 def kind(self):
     return PloneMessageFactory(u'task-added', default=u'Task added')
예제 #16
0
 def kind(self):
     return PloneMessageFactory(u'task-commented',
                                default=u'Task commented')
예제 #17
0
 def __call__(self):
     self.remove_from_portal_messages(
         self.context.translate(PloneMessageFactory('Item state changed.')))
     return super().__call__()
예제 #18
0
 def kind(self):
     return PloneMessageFactory(u'disposition-added',
                                default=u'Disposition added')
예제 #19
0
class AddFormSchema(group_base.BaseAddFormSchema):
    """Add form"""
    title = schema.TextLine(title=PloneMessageFactory(u"Title"))
    description = schema.Text(title=_(u"Subject"))
    file = NamedBlobFile(title=_(u"Attachment"), required=False)