# If the result is outside of the detection limits of the method or instrument, # the operand (< or >) is stored here. For routine analyses this is taken # from the Result, if the result entered explicitly startswith "<" or ">" DetectionLimitOperand = StringField( 'DetectionLimitOperand' ) # The ID of the logged in user who submitted the result for this Analysis. Analyst = StringField( 'Analyst' ) # The actual uncertainty for this analysis' result, populated from the ranges # specified in the analysis service when the result is submitted. Uncertainty = FixedPointField( 'Uncertainty', precision=10, ) # transitioned to a 'verified' state. This value is set automatically # when the analysis is created, based on the value set for the property # NumberOfRequiredVerifications from the Analysis Service NumberOfRequiredVerifications = IntegerField( 'NumberOfRequiredVerifications', default=1 ) # This field keeps the user_ids of members who verified this analysis. # After each verification, user_id will be added end of this string # seperated by comma- ',' . Verificators = StringField( 'Verificators',
widget=IntegerWidget( label=_("Exponential format precision"), description=_( "Define the precision when converting values to exponent " "notation. The default is 7."), )) # If the value is below this limit, it means that the measurement lacks # accuracy and this will be shown in manage_results and also on the final # report. LowerDetectionLimit = FixedPointField( 'LowerDetectionLimit', schemata="Analysis", default='0.0', precision=7, widget=DecimalWidget( label=_("Lower Detection Limit (LDL)"), description=_( "The Lower Detection Limit is the lowest value to which the " "measured parameter can be measured using the specified testing " "methodology. Results entered which are less than this value will " "be reported as < LDL"))) # If the value is above this limit, it means that the measurement lacks # accuracy and this will be shown in manage_results and also on the final # report. UpperDetectionLimit = FixedPointField( 'UpperDetectionLimit', schemata="Analysis", default='1000000000.0', precision=7, widget=DecimalWidget(
# the operand (< or >) is stored here. For routine analyses this is taken # from the Result, if the result entered explicitly startswith "<" or ">" DetectionLimitOperand = StringField( 'DetectionLimitOperand', read_permission=View, write_permission=FieldEditAnalysisResult, ) # The ID of the logged in user who submitted the result for this Analysis. Analyst = StringField('Analyst') # The actual uncertainty for this analysis' result, populated from the ranges # specified in the analysis service when the result is submitted. Uncertainty = FixedPointField( 'Uncertainty', read_permission=View, write_permission="Field: Edit Result", precision=10, ) # transitioned to a 'verified' state. This value is set automatically # when the analysis is created, based on the value set for the property # NumberOfRequiredVerifications from the Analysis Service NumberOfRequiredVerifications = IntegerField('NumberOfRequiredVerifications', default=1) # Routine Analyses and Reference Analysis have a versioned link to # the calculation at creation time. Calculation = HistoryAwareReferenceField('Calculation', allowed_types=('Calculation', ), relationship='AnalysisCalculation', referenceClass=HoldingReference)
class FGStripeField(FGStringField): """ A string entry field """ implements(IStripeField) security = ClassSecurityInfo() schema = FGStringField.schema.copy() + Schema( (LinesField( 'amounts', required=False, accessor="getAmounts", mutator="setAmounts", searchable=False, widget=LinesWidget( label='Available amounts', description='You can also provide a description of value ' 'using the | operator. Example: 10.00|$10 small')), BooleanField('variable', required=False, default=True, searchable=False, widget=BooleanWidget(label='Allow variable amount')), StringField('variableLabel', required=True, default='Amount: $', searchable=False, widget=StringWidget( label='Label used for variable amount field')), FixedPointField( 'fixedPrice', required=False, default='0.00', searchable=False, widget=DecimalWidget( label='Fixed amount', description='If filled in, ignore previous 2 fields.')), StringField('stripeSecretKey', require=True, searchable=False, view_permission=ModifyPortalContent, widget=StringWidget(label='Stripe Secret Key')), StringField('stripePublishableKey', require=True, searchable=False, widget=StringWidget(label='Stripe Publishable Key')), StringField('stripePanelLabel', required=True, searchable=False, default='More info about this', widget=StringWidget( label='The label of the payment button in the ' 'Checkout form')), StringField( 'stripeLabel', required=True, searchable=False, default='Authorize Donation', widget=StringWidget(label='Specify the text to be shown on the ' 'default blue button')), StringField('stripeCurrency', required=True, searchable=False, default='USD', widget=StringWidget(label='3 letter ISO currency code')), LinesField( 'stripeMetadata', required=False, default=[], vocabulary='getPFGFields', multiValued=True, widget=MultiSelectionWidget( label='Metadata Fields', description= 'Select the fields that should be included as metadata. ' 'You can only include 10 fields. Extras will be striped.')))) schema['required'].default = True schema['required'].widget.visible['edit'] = 'hidden' schema['hidden'].widget.visible['edit'] = 'hidden' schema['fgDefault'].widget.visible['edit'] = 'hidden' schema['fgmaxlength'].widget.visible['edit'] = 'hidden' schema['fgsize'].widget.visible['edit'] = 'hidden' schema['fgStringValidator'].widget.visible['edit'] = 'hidden' finalizeFieldSchema(schema, folderish=True, moveDiscussion=False) # Standard content type setup portal_type = meta_type = 'FormStripeField' archetype_name = 'StripeField' def __init__(self, oid, **kwargs): """ initialize class """ super(FGStripeField, self).__init__(oid, **kwargs) # set a preconfigured field as an instance attribute self.fgField = StripeField('fg_stripe_field', searchable=0, required=0, write_permission=View, widget=StripeWidget(), amounts=('10.00', '25.00', '50.00', '100.00'), variable=True, variableLabel='Amount: $', fixedPrice='0.00', stripeSecretKey='', stripePublishableKey='', stripePanelLabel='More info about this', stripeLabel='Authorize Donation', stripeCurrency='USD') def getPFGFields(self): form = aq_parent(aq_inner(self)) if form.portal_type == 'TempFolder': form = aq_parent(form) values = [] for field in form.values(): if (IPloneFormGenField.providedBy(field) and not IStripeField.providedBy(field)): values.append((field.getId(), field.Title())) return DisplayList(values) security.declareProtected(ModifyPortalContent, 'getStripeSecretKey') def getStripeSecretKey(self): # noqa return self.fgField.stripeSecretKey security.declareProtected(ModifyPortalContent, 'setStripeSecretKey') def setStripeSecretKey(self, value, **kw): # noqa self.fgField.stripeSecretKey = value security.declareProtected(View, 'getAmounts') def getAmounts(self): # noqa return self.fgField.amounts security.declareProtected(ModifyPortalContent, 'setAmounts') def setAmounts(self, value, **kw): # noqa self.fgField.amounts = value self.amounts = value # yikes, I'm lazy for fieldName in [ 'variable', 'variableLabel', 'fixedPrice', 'stripePublishableKey', 'stripePanelLabel', 'stripeLabel', 'stripeCurrency' ]: upper = fieldName[0].upper() + fieldName[1:] exec(''' security.declareProtected(View, 'get%(upper)s') def get%(upper)s(self): return getattr(self.fgField, '%(name)s', '') security.declareProtected(ModifyPortalContent, 'set%(upper)s') def set%(upper)s(self, value, **kw): self.fgField.%(name)s = value ''' % { 'name': fieldName, 'upper': upper }) def htmlValue(self, REQUEST): value = REQUEST.form.get(self.__name__, 'No Input') if type(value) != dict: return 'Invalid' if 'error' in value: return 'Error charging' if 'charge_data' not in value: return 'Card not charged for some reason' return 'Charged to %s for $%s' % (value['charge_data']['email'], value['original-amount'])
ReflexRuleAction = StringField('ReflexRuleAction', required=0, default=0) # Which is the 'local_id' inside the reflex rule ReflexRuleLocalID = StringField('ReflexRuleLocalID', required=0, default=0) # Reflex rule triggered actions which the current analysis is responsible for. # Separated by '|' ReflexRuleActionsTriggered = StringField('ReflexRuleActionsTriggered', required=0, default='') # The actual uncertainty for this analysis' result, populated when the result # is submitted. Uncertainty = FixedPointField('Uncertainty', read_permission=View, write_permission="Field: Edit Result", precision=10, widget=DecimalWidget(label=_("Uncertainty"))) # This field keep track if the field hidden has been set manually or not. If # this value is false, the system will assume the visibility of this analysis # in results report will depend on the value set at AR, Profile or Template # levels (see AnalysisServiceSettings fields in AR). If the value for this # field is set to true, the system will assume the visibility of the analysis # will only depend on the value set for the field Hidden (bool). HiddenManually = BooleanField( 'HiddenManually', default=False, ) schema = schema.copy() + Schema(( IsReflexAnalysis,
# Which is the Reflex Rule action that has created this analysis ReflexRuleAction = StringField('ReflexRuleAction', required=0, default=0) # Which is the 'local_id' inside the reflex rule ReflexRuleLocalID = StringField('ReflexRuleLocalID', required=0, default=0) # Reflex rule triggered actions which the current analysis is responsible for. # Separated by '|' ReflexRuleActionsTriggered = StringField('ReflexRuleActionsTriggered', required=0, default='') # The actual uncertainty for this analysis' result, populated when the result # is submitted. Uncertainty = FixedPointField('Uncertainty', precision=10, widget=DecimalWidget(label=_("Uncertainty"))) # This field keep track if the field hidden has been set manually or not. If # this value is false, the system will assume the visibility of this analysis # in results report will depend on the value set at AR, Profile or Template # levels (see AnalysisServiceSettings fields in AR). If the value for this # field is set to true, the system will assume the visibility of the analysis # will only depend on the value set for the field Hidden (bool). HiddenManually = BooleanField( 'HiddenManually', default=False, ) schema = schema.copy() + Schema(( IsReflexAnalysis, OriginalReflexedAnalysis,