예제 #1
0
class SamplePointSchemaExtender(object):
    adapts(ISamplePoint)
    implements(IOrderableSchemaExtender, IBrowserLayerAwareExtender)
    layer = INalLimsLayer

    fields = [
        ExtStringField("MBGType",
                       vocabulary=MBGTypes,
                       widget=SelectionWidget(
                           label="MBG Location Type",
                           format="radio",
                           render_own_label=False,
                       )),
        ExtStringField("WSSN", widget=StringWidget(label="WSSN", )),
        ExtStringField(
            "FormattedAddress",
            widget=StringWidget(
                label=_("Formatted Address"),
                description=
                "How the address should appear on a Report if different from the \"title\""
            ),
        ),
    ]

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

    def getOrder(self, schematas):
        return schematas

    def getFields(self):
        return self.fields
예제 #2
0
class ExternalIdentifierExtender(object):
    """ExternalIdentifier class"""

    implements(ISchemaExtender, IBrowserLayerAwareExtender)

    # adapts elements that provide the IExternalIdentifierable marker interface
    adapts(IExternalIdentifierable)

    layer = IWS4PMLayer

    fields = [
        ExternalIdentifierStringField(
            EXTERNAL_IDENTIFIER_FIELD_NAME,
            required=False,
            default='',
            searchable=False,
            languageIndependent=True,
            widget=StringWidget(
                label=(u"External identifier"),
                description=(u"You may enter an external identifier here if the "
                             u"item is created using an external service"),))
    ]

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

    def getOrder(self, schematas):
        """
        """
        return schematas

    def getFields(self):
        return self.fields
예제 #3
0
class VocabularioExtender(object):
    implements(ISchemaExtender)

    fields = [
        MJStringField(
            "cor_categoria",
            required=True,
            searchable=False,
            widget=StringWidget(
                label=_(u"Cor da categoria"),
                helper_js=('++resource++color.js', ),
                size=8,
            ),
        ),
    ]

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

    def getFields(self):
        portal_type = getattr(self.context, 'portal_type', None)
        if portal_type == 'SimpleVocabularyTerm':
            return self.fields
        else:
            return []
예제 #4
0
class ContentExtender(object):
    adapts(ATEvent)
    implements(ISchemaExtender)

    fields = [
        ProfResponsableField(
            name='profResponsable',
            required=False,
            searchable=True,
            widget=StringWidget(description='',
                                label=u'Professeur responsable',
                                size=40)),
        ProfsAccompagnateursField(
            name='profsAccompagnateurs',
            required=False,
            searchabl=True,
            widget=TextAreaWidget(description='',
                                  label=u'Professeurs accompagnateurs',
                                  cols=40))]

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

    def getFields(self):
        return self.fields
예제 #5
0
class FGSelectionFieldExtender(object):
    adapts(FGSelectionField)
    implements(IOrderableSchemaExtender)

    fields = [
        CorrectAnswerField("correct_answer",
                           widget=StringWidget(label="Correct answer")),
    ]

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

    def getOrder(self, schematas):
        """Manipulate the order in which fields appear.

        @param schematas: Dictonary of schemata name -> field lists
        @return: Dictionary of reordered field lists per schemata.

        """
        new_schemata = schematas.copy()
        new_schemata['default'].remove('correct_answer')
        new_schemata['default'].insert(
            new_schemata['default'].index('fgVocabulary') + 1,
            'correct_answer')
        return new_schemata

    def getFields(self):
        return self.fields
예제 #6
0
class SlickSettingsExtender(object):
    adapts(IListingBlock)
    implements(IOrderableSchemaExtender)

    fields = [
        SlickSettingsField(
            'slick_settings',
            searchable=False,
            default=u'{"autoplay": true, "autoplaySpeed": 3000}',
            validators=('isValidSlickSettings', ),
            required=True,
            widget=StringWidget(
                label=_(u'label_slicksettings',
                        default=u'Settings for diashow'),
                description=_(
                    u'help_slicksettings',
                    default=u'Be careful changing. This is the configuration '
                    'for the diashow javascript. Available options: '
                    '<a href="https://github.com/kenwheeler/slick/#options">'
                    'github.com/kenwheeler/slick/#options</a> <br />If all '
                    'goes wrong, use the default: {"autoplay": true, '
                    '"autoplaySpeed": 3000}'),
            ),
        ),
    ]

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

    def getFields(self):
        return self.fields

    def getOrder(self, original):
        return original
예제 #7
0
class ProfResponsableField(ExtensionField, StringField):
    """
    """
    StringField(
        name='profResponsable',
        required=False,
        searchable=True,
        widget=StringWidget(
            description='',
            label=u'Professeur responsable',
            size=40))
예제 #8
0
class ECQGroup(ECQAbstractGroup):
    """Groups several questions into a unit."""

    # See comments in 'ECQAbstractGroup' for an explanation
    # of the function of a schema, therein defined properties (fields) and
    # internationalization of the widgets
    schema = ECQAbstractGroup.schema + Schema((StringField(
        'title',
        required=False,
        searchable=True,
        default='',
        widget=StringWidget(label_msgid='label_title',
                            description_msgid='title',
                            i18n_domain='plone'),
    ), ), )

    typeDescription = "Using this form, you can create a question group."
    typeDescMsgId = 'description_edit_mcquestiongroup'

    security = ClassSecurityInfo()

    # The functions needed for ECQAbstractGroup,
    # 'getResults', 'setResults', 'isPublic' and
    # 'getEvaluationScripts' don't have to be implemented. They are
    # acquired from the group's parent

    security.declarePrivate('computeCandidatePoints')

    def computeCandidatePoints(self, result):
        """Return how many points the candidate got for the questions
        in this container.  If a custom evaluation script has been
        uploaded it will be invoked. Otherwise a default method will
        be used.
            
        @param candidateId The user ID of the candidate whose points
        you want to know."""
        customScript = self.getEvaluationScript(self.portal_type)
        questions = self.getQuestions(result)
        if not customScript:  # default
            points = 0
            for question in questions:
                if not shasattr(question, 'getCandidatePoints'):
                    return None
                qPoints = question.getCandidatePoints(result)
                if not isNumeric(qPoints):
                    return None
                points += qPoints
            return points
        else:  # custom
            return evalFunString(customScript, \
                                 CUSTOM_EVALUATION_FUNCTION_NAME, \
                                 [self, result, questions])
예제 #9
0
class PageExtender(object):
    adapts(IATDocument)  # XXX Might not work on Plone 3.

    fields = [
        MyStringField(
            "extensive_text",
            default="default text",
            widget=StringWidget(label="This page has extensive text")),
    ]

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

    def getFields(self):
        return self.fields
예제 #10
0
class PlominoExtender(object):
    adapts(IPlominoField)

    fields = [
        _ExtensionStringField(
            "extension_field",
            widget=StringWidget(
                label=u"A new field",
                description=u"Added with atschemaextender",
            ),
        ),
    ]

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

    def getFields(self):
        return self.fields
예제 #11
0
class ContactSchemaExtender(object):
    adapts(IContact)
    implements(IOrderableSchemaExtender, IBrowserLayerAwareExtender)
    layer = INalLimsLayer

    fields = [
        ExtStringField("Initials",
                       schemata='default',
                       widget=StringWidget(label="Initials", )),
    ]

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

    def getOrder(self, schematas):
        return schematas

    def getFields(self):
        return self.fields
예제 #12
0
                                        ReferenceField, ReferenceWidget,
                                        Schema, StringField, StringWidget,
                                        TextAreaWidget, TextField)
from Products.CMFPlone.utils import safe_unicode
from bika.lims import bikaMessageFactory as _
from bika.lims.browser.widgets import ScheduleInputWidget
from bika.lims.config import PROJECTNAME
from bika.lims.content.bikaschema import BikaSchema
from bika.lims.interfaces import ICancellable
from zope.interface import implements

schema = BikaSchema.copy() + Schema((
    ReferenceField("Instrument",
                   allowed_types=("Instrument", ),
                   relationship="InstrumentScheduledTaskInstrument",
                   widget=StringWidget(visible=False, )),
    ComputedField(
        "InstrumentUID",
        expression=
        "context.getInstrument() and context.getInstrument().UID() or None",
        widget=ComputedWidget(visible=False, ),
    ),
    StringField(
        "Type",
        vocabulary="getTaskTypes",
        widget=ReferenceWidget(
            checkbox_bound=0,
            label=_("Task type", "Type"),
        ),
    ),
    RecordsField(
예제 #13
0
        items = getContainers(instance, allow_blank=True)
        return DisplayList(items)


registerField(PartitionSetupField, title="", description="")

# # XXX When you modify this schema, be sure to edit the list of fields
## to duplicate, in bika_analysisservices.py.

schema = BikaSchema.copy() + Schema((
    StringField('ShortTitle',
                schemata="Description",
                widget=StringWidget(
                    label=_("Short title"),
                    description=_(
                        "If text is entered here, it is used instead of the "
                        "title when the service is listed in column headings. "
                        "HTML formatting is allowed.")
                ),
    ),
    StringField('Unit',
                schemata="Description",
                widget=StringWidget(
                    label=_("Unit"),
                    description=_(
                        "The measurement units for this analysis service' results, "
                        "e.g. mg/l, ppm, dB, mV, etc."),
                ),
    ),
    IntegerField('Precision',
                 schemata="Analysis",
예제 #14
0
from eea.facetednavigation.widgets import TrustedEngine
from eea.facetednavigation.widgets import TrustedZopeContext
from eea.facetednavigation.widgets import ViewPageTemplateFile
from eea.facetednavigation.widgets.widget import Widget as AbstractWidget
from eea.facetednavigation import EEAMessageFactory as _
from eea.facetednavigation.widgets.resultsfilter.interfaces import (
    IResultsFilterWidget, )

logger = logging.getLogger('eea.facetednavigation.widgets.resultsfilter')

EditSchema = Schema(
    (StringField('default',
                 schemata="default",
                 default='python:hasattr(brain, "Title")',
                 widget=StringWidget(
                     label=_(u'Results Filter'),
                     description=_(u'Default tal expression for query value'),
                     i18n_domain="eea")), ))


class Widget(AbstractWidget):
    """ Results Filter widget

    The following contexts can be used within tal expressions:

    context   -- faceted navigable context
    referer   -- request.HTTP_REFERER object. Use this if you load
                 faceted from another place (like: portal_relations)
    request   -- faceted navigable REQUEST object
    widget    -- Results Filter Widget instance
    criterion -- Results Filter Criterion instance
    brain     -- Catalog brain
from countries import LOCATIONS

REFERRERS = DisplayList((
    ('search', 'Search Engine'),
    ('person', 'Individual "word-of-mouth"'),
    ('article', 'Published Article'),
    ('conference', 'Conference Presentation'),
    ('other', 'Other'),
))

schema = BaseSchema + Schema((
    StringField('title',
                required=1,
                accessor='Title',
                widget=StringWidget(
                    label="Name",
                    description='The name of the person being featured',
                )),
    StringField('email',
                widget=StringWidget(
                    label="Email",
                    description="User's email address",
                )),
    StringField('location',
                vocabulary=LOCATIONS,
                widget=SelectionWidget(
                    label="Location",
                    description="Where is the user from?",
                )),
    StringField('occupation',
                widget=StringWidget(
                    label="Occupation",
예제 #16
0
 CoordinateField(
     'Longitude',
     schemata='Location',
     widget=CoordinateWidget(
         label=_("Longitude"),
         description=
         _("Enter the Sample Point's longitude in degrees 0-180, minutes 0-59, seconds 0-59 and E/W indicator"
           ),
     ),
 ),
 StringField(
     'Elevation',
     schemata='Location',
     widget=StringWidget(
         label=_("Elevation"),
         description=_(
             "The height or depth at which the sample has to be taken"),
     ),
 ),
 DurationField(
     'SamplingFrequency',
     vocabulary_display_path_bound=sys.maxint,
     widget=DurationWidget(
         label=_("Sampling Frequency"),
         description=
         _("If a sample is taken periodically at this sample point, enter frequency here, e.g. weekly"
           ),
     ),
 ),
 ReferenceField(
     'SampleTypes',
예제 #17
0
from zope.interface import implements

from bika.lims import bikaMessageFactory as _
from bika.lims.browser.fields import AddressField
from bika.lims.browser.widgets import AddressWidget
from bika.lims.config import PROJECTNAME
from bika.lims.content.bikaschema import BikaFolderSchema
from bika.lims.content.bikaschema import BikaSchema
from bika.lims.interfaces import IOrganisation

schema = BikaFolderSchema.copy() + BikaSchema.copy() + ManagedSchema((
    StringField(
        "Name",
        required=1,
        searchable=True,
        widget=StringWidget(label=_("Name"), ),
    ),
    StringField(
        "TaxNumber",
        widget=StringWidget(label=_("VAT number"), ),
    ),
    StringField(
        "Phone",
        widget=StringWidget(label=_("Phone"), ),
    ),
    StringField(
        "Fax",
        widget=StringWidget(label=_("Fax"), ),
    ),
    StringField("EmailAddress",
                schemata="Address",
예제 #18
0
${accreditation_standard} conformant by ${accreditation_body_abbr},
${accreditation_body_name}<br/><br/> ${accreditation_body_abbr} is the single
national accreditation body assessing testing and calibration laboratories for
compliance to the ISO/IEC 17025 standard.<br/></br/>\n The following analysis
services have been included in the ${accreditation_body_abbr} schedule of
Accreditation for this Laboratory:
"""

schema = Organisation.schema.copy() + Schema((
    StringField(
        "LabURL",
        schemata="Address",
        write_permission=ManageBika,
        widget=StringWidget(
            size=60,
            label=_("Lab URL"),
            description=_("The Laboratory's web address"),
        ),
    ),
    UIDReferenceField("Supervisor",
                      required=0,
                      allowed_types=("LabContact", ),
                      vocabulary="_getLabContacts",
                      write_permission=ManageBika,
                      accessor="getSupervisorUID",
                      widget=SelectionWidget(
                          format="select",
                          label=_("Supervisor"),
                          description=_("Supervisor of the Lab"))),
    IntegerField(
        "Confidence",
예제 #19
0
from Products.ATContentTypes.content.base import ATCTContent
from Products.ATContentTypes.content.schemata import finalizeATCTSchema
from Products.ATContentTypes.configuration import zconf

from Products.statusmessages.interfaces import IStatusMessage

from Products.PloneShellConsole.config import PROJECTNAME

PSCWorklogSchema = ATCTContent.schema.copy() + Schema(
    (

        # user name who perform this work.
        StringField(
            'psc_log_username',
            widget=StringWidget(
                label='User Name',
                description='The user, who performed this work',
            ),
            #mode = 'r',
        ),

        # time stamp for this work.
        StringField(
            'psc_log_timestamp',
            widget=StringWidget(
                label='Time Stamp',
                description='Time stamp for this work',
            ),
            #mode = 'r',
        ),

        # log subject, a brief message which
        ),
    ),
    ReferenceField(
        'referencedContent',
        relationship='article_link',
        widget=ReferenceBrowserWidget(
            label='Referenced link',
            label_msgid='label_referenced_link',
            i18n_domain='plonearticle',
        ),
    ),
    StringField(
        'attachedLink',
        widget=StringWidget(
            label='Link',
            label_msgid='label_link',
            i18n_domain='plonearticle',
        ),
    ),
))


class LinkInnerContentProxy(BaseInnerContentProxy):
    """Proxy implementing IATLink. It means this proxy has a remoteUrl
    method.

    remoteUrl returns attached link by default if existing otherwise returns
    the referenced content.
    """

    implements(ILinkInnerContentProxy)
예제 #21
0
                  description=_(u'Number of items visible in widget'),
                  i18n_domain="eea")),
 IntegerField('maxchars',
              schemata="display",
              default=0,
              widget=IntegerWidget(
                  label=_(u'Maximum characters'),
                  description=_(
                      u'Cut long phrases to provided number of characters'),
                  i18n_domain="eea")),
 StringField('colormin',
             schemata="display",
             default="A1BE7E",
             widget=StringWidget(
                 label='Minimum color',
                 label_msgid='faceted_criteria_colormin',
                 description='Tagscloud minimum color',
                 description_msgid='help_faceted_criteria_colormin',
                 i18n_domain="eea")),
 StringField('colormax',
             schemata="display",
             default="95B229",
             widget=StringWidget(
                 label='Maximum color',
                 label_msgid='faceted_criteria_colormax',
                 description='Tagscloud max color',
                 description_msgid='help_faceted_criteria_colormax',
                 i18n_domain="eea")),
 BooleanField('sortreversed',
              schemata="display",
              widget=BooleanWidget(label=_(u'Reverse options'),
                                   description=_(u'Sort options reversed'),
예제 #22
0
    ReferenceField(
        "Instrument",
        schemata="Description",
        required=0,
        vocabulary_display_path_bound=sys.maxint,
        vocabulary="getInstruments",
        allowed_types=("Instrument", ),
        relationship="WorksheetTemplateInstrument",
        referenceClass=HoldingReference,
        widget=ReferenceWidget(
            checkbox_bound=0,
            label=_("Instrument"),
            description=_("Select the preferred instrument"),
        ),
    ),
    StringField("InstrumentTitle", widget=StringWidget(visible=False)),
    BooleanField(
        "EnableMultipleUseOfInstrument",
        default=True,
        schemata="Description",
        widget=BooleanWidget(
            label=_("Enable Multiple Use of Instrument in Worksheets."),
            description=_(
                "If unchecked, Lab Managers won't be able to assign the same "
                "Instrument more than one Analyses while creating a Worksheet."
            ))),
))

schema["title"].schemata = "Description"
schema["title"].widget.visible = True
예제 #23
0
def compare(a, b):
    """ Compare lower values
    """
    return cmp(a.lower(), b.lower())


logger = logging.getLogger('eea.facetednavigation.widgets.widget')

CommonEditSchema = Schema((
    StringField('title',
                schemata="default",
                required=True,
                widget=StringWidget(
                    size=25,
                    label=_(u"Friendly name"),
                    description=_(u"Title for widget to display in view page"),
                )),
    StringField('position',
                schemata="layout",
                vocabulary_factory="eea.faceted.vocabularies.WidgetPositions",
                widget=SelectionWidget(
                    format='select',
                    label=_(u'Position'),
                    description=_(u"Widget position in page"),
                )),
    StringField('section',
                schemata="layout",
                vocabulary_factory="eea.faceted.vocabularies.WidgetSections",
                widget=SelectionWidget(
                    format='select',
예제 #24
0
class MapServer(BaseFolder):
    '''Map Server for CoGIS'''
    schema = BaseFolderSchema

    schema = BaseSchema + Schema([
        StringField('description',
                    required=False,
                    searchable=1,
                    widget=StringWidget(
                        label='Description',
                        description="Enter project description")),
        ReferenceField('relatedItems',
                       relationship='relatesTo',
                       multiValued=True,
                       isMetadata=True,
                       languageIndependent=False,
                       index='KeywordIndex',
                       write_permission=ModifyPortalContent,
                       widget=ReferenceBrowserWidget(
                           allow_search=True,
                           allow_browse=True,
                           show_indexes=False,
                           force_close_on_insert=True,
                           label=_(u'label_related_items',
                                   default=u'Related Items'),
                           description='',
                           visible={
                               'edit': 'visible',
                               'view': 'invisible'
                           }))
    ], )

    actions = (
        {
            'id': 'publish',
            'name': 'Publish',
            'action': 'string:${object_url}/Map_Server_PublishAll',
            'permissions': (permissions.ViewManagementScreens, )
        },
        {
            'id': 'pingServer',
            'name': 'Ping Server',
            'action': 'string:${object_url}/Map_Server_PingServer',
            'permissions': (permissions.ViewManagementScreens, )
        },
        {
            'id': 'licenseAgreement',
            'name': 'License Agreement',
            'action': 'string:${object_url}/Map_Server_LicenseAgreement_Edit',
            'permissions': (permissions.ViewManagementScreens, )
        },
    )

    #schema = schema + extra_schema
    content_icon = "mapServer.gif"
    security = ClassSecurityInfo()

    archetype_name = 'MapServer'
    meta_type = 'MapServer'
    portal_type = 'MapServer'
    allowed_content_types = []  #['MapLayer']
    filter_content_types = 1
    global_allow = 0
    allow_discussion = 0
    content_icon = "mapServer.gif"

    def __init__(self, id, title=''):
        '''Initialize an instance of the class'''
        self.id = id
        if title == '':
            self.title = id
        else:
            self.title = title

        self.organization = ""
        self.wmsSource = ""
        self.wfsSource = ""
        self.enableLicenseAgreement = False
        # licenseAgreent is the text to display in the tbx
        self.licenseAgreement = "Put the license text here \nPlease read license before publishing"
        # its a list of usernames that have accepted the license agreement
        self.acceptedUserNames = []

    def dummyTest(self):
        """
        """
        return dir(self)

    def updateLicenseAgreement(self, REQUEST=None):
        """
        @summary: udpate the server license agreement and disables/enables the agreement
        """
        try:
            self.acceptedUserNames = []

            if REQUEST.has_key('enableIt'):
                enable = True
            else:
                enable = False

            licenseText = REQUEST.form['licenseText']

            self.enableLicenseAgreement = enable
            self.licenseAgreement = licenseText

            self._p_changed = 1
            transaction.savepoint(True)

            status_message = "License Agreement Updated"

            REQUEST.RESPONSE.redirect(
                "%s/Map_Server_LicenseAgreement_Edit?portal_status_message=%s"
                % (self.absolute_url(), status_message))
        except:
            logger.exception('failed updateLicenseAgreement')

    security.declarePublic('userIsOwner')

    def userIsOwner(self):
        """
        @summary: this is a zope specific method to get logged in user name
        @return: boolean, true if logged in user is the owner
        """
        try:
            ownerName = self.owner_info()['id']
            member = self.portal_membership.getAuthenticatedMember()
            userName = member.getUserName()
            if userName == ownerName:
                return True
            else:
                return False
        except:
            logger.exception('failed user is owner')

    def publishLayersForRoles(self, rolesToPublish):
        """
        @summary : publishes layer for the given roles passed
        @param   : a list of roles to publish layers for
        """

        try:
            items = self.objectItems()
            for i in items:
                if i[1].meta_type == 'MapLayer':
                    l = i[1]
                    secStruct = l.setSecurity(
                        self.getPublishedStructureForRoles(rolesToPublish))
            return 1
        except:
            logger.exception('failed publishLayersForRoles')

    def publishAllLayers(self):
        """
        @summary: this will publish all the layers in the server
        @return: 1
        """

        try:
            items = self.objectItems()
            for i in items:
                if i[1].meta_type == 'MapLayer':
                    l = i[1]
                    secStruct = l.setSecurity(
                        self.getPublishedSecurityStructure())
            return 1
        except:
            logger.exception('failed publishAllLayers')

    def retractAllLayers(self):
        """
        @summary: this will retract all the layers in the server
        @return: 1
        """

        try:
            items = self.objectItems()
            for i in items:
                if i[1].meta_type == 'MapLayer':
                    l = i[1]
                    secStruct = l.setSecurity(
                        self.getRetractedSecurityStructure())
            return 1
        except:
            logger.exception('failed retractAllLayers')

    def pingServer(self):
        """
        """
        try:
            startTime = time.time()
            wmsPingRes = self._getURLContent(self.wmsSource)
            endTime = time.time()
            wmsTime = endTime - startTime
            if wmsPingRes.find("Exception occured") != -1:
                wmsTime = "Server Unavailable"

            startTime = time.time()
            wfsPingRes = self._getURLContent(self.wfsSource)
            endTime = time.time()
            wfsTime = endTime - startTime
            if wfsPingRes.find("Exception occured") != -1:
                wfsTime = "Server Unavailable"

            return [str(wfsTime), str(wmsTime)]
        except:
            logger.exception('failed pingServer')

    def pingAllLayers(self):
        """
        """
        try:
            results = {}
            items = self.objectItems()
            for i in items:
                layer = i[1]
                pingResWMS = layer.pingWMSLayer()
                pingResWFS = layer.pingWFSLayer()
                results[layer.uniqueName] = [pingResWFS, pingResWMS]
            return results
        except:
            logger.exception('error')

    def getPublishedSecurityStructure(self):
        """
        @summary: builds a security structure that will expose all layers
        @return: a dictionary with all the roles as keys and another dict as value
        """
        try:
            roles = self.validRoles()
            tmpDict = {}
            for role in roles:
                tmpDict[role] = {'Render': 1, 'Extract': 1}
            return tmpDict
        except:
            logger.exception('failed getPublishedSercurityStructure')

    def getPublishedStructureForRoles(self, theRoles):
        """
        """
        try:
            roles = self.validRoles()
            tmpDict = {}
            for role in roles:
                if role in theRoles:
                    tmpDict[role] = {'Render': 1, 'Extract': 1}
                else:
                    tmpDict[role] = {'Render': 0, 'Extract': 0}
            return tmpDict
        except:
            logger.exception('Error')

    def getRetractedSecurityStructure(self):
        """
        @summary: builds a security structure that will expose all layers
        @return: a dictionary with all the roles as keys and another dict as value
        """
        try:
            roles = self.validRoles()
            tmpDict = {}
            for role in roles:
                tmpDict[role] = {'Render': 0, 'Extract': 0}
            return tmpDict
        except:
            logger.exception('Error')

    def _getURLContent(self, url, data={}):
        """        
        """
        try:
            if data:
                if type(data) == unicode:
                    data = str(urllib.unquote(data))
                if type(data) == str:
                    f = urllib.urlopen(url, data)
                else:
                    params = urllib.urlencode(data)
                    f = urllib.urlopen(url, params)
            else:
                f = urllib.urlopen(url)
            data = f.read()
            f.close()
            return data
        except:
            import traceback
            sio = StringIO.StringIO()
            traceback.print_exc(file=sio)
            sio.seek(0)
            trace = sio.read()
            logger.exception('Error')
            return MapServerTemplates.ogcServiceException % (
                "Exception occured getURLContent request, check log for details %s"
                % trace)
예제 #25
0
                    description='',
                    label_msgid='label_batch_size',
                    description_msgid='help_batch_size',
                    i18n_domain='plone',
                    ),
        schemata='cbsettings_display',
        ),

    #Entry
    StringField('entrydate_format',
        searchable=0,
        default = '%Y/%m/%d',
        widget=StringWidget(label='Entrydate format',
                    description='',
                    label_msgid='label_entrydate_format',
                    description_msgid='help_entrydate_format',
                    i18n_domain='plone',
                    size=60,
                    ),
        schemata='cbsettings_display',
        ),

    #PING/Trackback
    StringField('trackback_base',
        searchable=0,
        default='',
        widget=StringWidget(label='Trackback base URL',
                    description='',
                    label_msgid='label_trackback_base',
                    description_msgid='help_trackback_base',
                    i18n_domain='plone',
예제 #26
0
            description=_(u"Get unique values from catalog "
                        u"as an alternative for vocabulary"),
        )
    ),
    BooleanField('sortreversed',
        schemata="display",
        widget=BooleanWidget(
            label=_(u"Reverse options"),
            description=_(u"Sort options reversed"),
        )
    ),
    StringField('default',
        schemata="default",
        widget=StringWidget(
            size=25,
            label=_(u'Default value'),
            description=_(u'Default selected item'),
            i18n_domain="eea"
        )
    ),
))

class Widget(CountableWidget):
    """ Widget
    """
    # Widget properties
    widget_type = 'select'
    widget_label = _('Select')
    view_js = '++resource++eea.facetednavigation.widgets.select.view.js'
    edit_js = '++resource++eea.facetednavigation.widgets.select.edit.js'
    view_css = '++resource++eea.facetednavigation.widgets.select.view.css'
예제 #27
0
from Products.Archetypes.public import Schema
from Products.Archetypes.public import StringField
from Products.Archetypes.public import StringWidget
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile

from eea.facetednavigation.widgets.widget import Widget as AbstractWidget
from eea.facetednavigation import EEAMessageFactory as _

logger = logging.getLogger('eea.facetednavigation.widgets.portlet')

EditSchema = Schema(
    (StringField('macro',
                 schemata="default",
                 required=True,
                 widget=StringWidget(label=_(u'Portlet macro'),
                                     description=_(u'Path to portlet macro'),
                                     i18n_domain="eea")), ))


class Widget(AbstractWidget):
    """ Widget
    """
    # Widget properties
    widget_type = 'portlet'
    widget_label = _('Plone portlet')
    view_js = '++resource++eea.facetednavigation.widgets.portlet.view.js'
    view_css = '++resource++eea.facetednavigation.widgets.portlet.view.css'
    edit_css = '++resource++eea.facetednavigation.widgets.portlet.edit.css'
    css_class = 'faceted-portlet-widget'

    index = ZopeTwoPageTemplateFile('widget.pt', globals())
예제 #28
0
class AnalysisRequestSchemaExtender(object):
    adapts(IAnalysisRequest)
    implements(IOrderableSchemaExtender, IBrowserLayerAwareExtender)
    layer = INalLimsLayer

    fields = [
        ExtStringField(
            'PlantType',
            widget=StringWidget(
                label="Plant Type (Sap Samples)",
                description="The Plant Species or Crop the sample was taken from",
                render_own_label=True,
                visible={
                    'edit':'visible',
                    'view':'visible',
                    'add':'edit',
                    'header_table':'visible',
                },
            )
        ),

        ExtStringField(
            'Variety',
            widget=StringWidget(
                label="Variety (Sap Samples)",
                description="The Plant Variety or Cultivar the sample was taken from",
                render_own_label=True,
                visible={
                    'edit':'visible',
                    'view':'visible',
                    'add':'edit',
                    'header_table':'visible',
                },
            )
        ),

        ExtStringField(
            'GrowthStage',
            widget=StringWidget(
                label="Growth Stage (Sap Samples)",
                description="The development stage of the plant the sample was taken from",
                render_own_label=True,
                visible={
                    'edit':'visible',
                    'view':'visible',
                    'add':'edit',
                    'header_table':'visible',
                },
            )
        ),

        ExtBooleanField(
            'NewLeaf',
            widget=BooleanWidget(
                label="New Leaf (Sap Samples)",
                description="The sample is from the new growth of a plant",
                render_own_label=True,
                visible={
                    'edit':'visible',
                    'view':'visible',
                    'add':'edit',
                    'header_table':'visible',
                },
            )
        ),

        ExtStringField(
            'InternalLabID',
            widget=StringWidget(
                label="Internal Lab Sample ID",
                description="The Lab ID from a printed COC (Ex. '001')",
                render_own_label=True,
                visible={
                    'edit':'visible',
                    'view':'visible',
                    'add':'edit',
                    'header_table':'visible',
                },
            )
        ),

        ExtDateTimeField(
            'DateOfSampling',
            required=1,
            widget=DateTimeWidget(
                label="Date Sampled",
                description="The Date the sample was taken",
                render_own_label=True,
                show_time=False,
                datepicker_nofuture=1,
                visible={
                    'edit':'visible',
                    'view':'visible',
                    'add':'edit',
                    'header_table':'visible',
                },
            )
        ),

        ExtStringField(
            'TimeOfSampling',
            widget=StringWidget(
                label="Time Sampled",
                description="The time of day the sample was taken",
                render_own_label=True,
                visible={
                    'edit':'visible',
                    'view':'visible',
                    'add':'edit',
                    'header_table':'visible',
                },
            )
        ),
    ]

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

    def getOrder(self, schematas):
        return schematas

    def getFields(self):
        return self.fields
예제 #29
0
EditSchema = Schema((
    StringField(
        'index',
        schemata="default",
        required=True,
        vocabulary_factory='eea.faceted.vocabularies.AlphabeticCatalogIndexes',
        widget=SelectionWidget(
            format='select',
            label=_(u"Catalog index"),
            description=_(u"Catalog index to use for search"),
        )),
    StringField('default',
                schemata="default",
                widget=StringWidget(
                    size=3,
                    maxlength=1,
                    label=_(u"Default value"),
                    description=_(u"Default letter to be selected"),
                )),
))


class Widget(CountableWidget):
    """ Widget
    """
    implements(IAlphabeticWidget)

    # Widget properties
    widget_type = 'alphabetic'
    widget_label = _('Alphabetic')
    view_js = '++resource++eea.facetednavigation.widgets.alphabets.view.js'
    edit_js = '++resource++eea.facetednavigation.widgets.alphabets.edit.js'
예제 #30
0
from bika.lims.config import ARIMPORT_OPTIONS
from bika.lims.config import DECIMAL_MARKS
from bika.lims.config import PROJECTNAME
from bika.lims.content.attachment import Attachment
from bika.lims.content.organisation import Organisation
from bika.lims.interfaces import IClient, IDeactivable
from zope.interface import implements

schema = Organisation.schema.copy() + Schema((
    StringField(
        "ClientID",
        required=1,
        searchable=True,
        validators=("uniquefieldvalidator", "standard_id_validator"),
        widget=StringWidget(
            label=_("Client ID"),
        ),
    ),

    BooleanField(
        "BulkDiscount",
        default=False,
        widget=BooleanWidget(
            label=_("Bulk discount applies"),
        ),
    ),

    BooleanField(
        "MemberDiscountApplies",
        default=False,
        widget=BooleanWidget(