def lotInvariant(data): lot = data.lot try: int(lot) except ValueError: raise Invalid(_(u"Lot is not a valid number.")) if len(lot) != 3: raise Invalid( _(u"Lot is not in the correct format (ie 045 for lot 45)"))
def residentInvariant(data): resident_one = data.resident_one resident_two = data.resident_two if resident_one and resident_two: if resident_one == resident_two: raise Invalid( _(u"Resident One and Two cannot be the same individual."))
def ownersInvariant(data): owner_one = data.owner_one owner_two = data.owner_two if owner_one and owner_two: if owner_one == owner_two: raise Invalid( _(u"Owners One and Two cannot be the same individual."))
def conditionPerists(data): context = data.__context__ context_state = api.content.get_state(obj=context) if context_state in ['failed_final', 'remedied']: for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: if hasattr(data, '%s_cond_remains' % fieldset_id): if getattr(data, '%s_cond_remains' % fieldset_id): rewalk_txt = getattr(data, '%s_rewalk_text' % fieldset_id) rewalk_image = getattr(data, '%s_rewalk_image' % fieldset_id) if not rewalk_txt: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an a reason the condition persists for %s." % error_str)) if not rewalk_image: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an a photo of the condition for %s." % error_str))
def confirmAction(data): context = data.__context__ context_state = api.content.get_state(obj=context) for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: if hasattr(data, '%s_text' % fieldset_id): if getattr(data, '%s_text' % fieldset_id): action_required = getattr(data, '%s_action_required' % fieldset_id) if not action_required: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide a required action for %s." % error_str)) if hasattr(data, '%s_action_required' % fieldset_id): if getattr(data, '%s_action_required' % fieldset_id): failure_text = getattr(data, '%s_text' % fieldset_id) if not failure_text: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide a description of the issue if action is required for: %s." % error_str))
def imagesRequired(data): context = data.__context__ context_state = api.content.get_state(obj=context) for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: if context_state == 'failed_initial': if getattr(data, '%s_text' % fieldset_id): image = getattr(data, '%s_image' % fieldset_id) if not image: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an image for %s." % error_str)) if context_state == 'failed_final': if getattr(data, '%s_rewalk_text' % fieldset_id): image = getattr(data, '%s_rewalk_image' % fieldset_id) if not image: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an image for %s." % error_str))
def verifyCondition(data): context = data.__context__ context_state = api.content.get_state(obj=context) if context_state in ['failed_final', 'remedied']: for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: if hasattr(data, '%s_cond_remains' % fieldset_id): initial_text = getattr(data, '%s_text' % fieldset_id) if initial_text and not getattr(data, '%s_cond_remains' % fieldset_id): error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an image for %s." % error_str))
def verifyCondition(data): context = data.__context__ data_dict = data._Data_data___ context_state = api.content.get_state(obj=context) if context_state in ['failed_final', 'remedied']: for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: if '%s_cond_remains' % fieldset_id in data_dict: initial_text = data_dict.get('%s_text' % fieldset_id) or None cond_remains = data_dict.get('%s_cond_remains' % fieldset_id) if cond_remains is True: continue if cond_remains is False: continue error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must verify the condition remains for %s." % error_str))
class HouseInspectionForm(form.SchemaForm): grok.context(IHOAHouse) grok.require("zope2.View") grok.template("home_inspection") grok.name("home-inspection") label = _(u"Home Inspection Form") schema = IHouseInspectionForm ignoreContext = False @button.buttonAndHandler(u"Cancel") def handleCancel(self, action): """ user cancelled go back to the walker assignment page """ context = self.context api.portal.show_message(message=u"You cancelled the inspection of %s" % context.title, request=context.REQUEST, type='info') request = context.REQUEST parent_container = context.aq_parent response = request.response response.redirect('%s/@@walker-assignments' % parent_container.absolute_url()) @button.buttonAndHandler(u"Pass") def handlePass(self, action): """ """ context = self.context annual_inspection_brain = getAnnualInspection() ai_review_state = annual_inspection_brain.review_state active_home_inspection_id = getActiveHomeInspectionId() if not active_home_inspection_id: #nothing to do api.portal.show_message( message= u"Could not find a home inspection form to update, was the annual " u"inspection properly initiated?", request=context.REQUEST, type='info') else: current_member = api.user.get_current() current_member_id = current_member.getId() hi_obj = context.get(active_home_inspection_id) current_state = api.content.get_state(obj=hi_obj) had_errors = False try: api.content.transition(obj=hi_obj, transition='pass') if ai_review_state == 'initial_inspection': setattr(hi_obj, 'inspected_by_first', current_member_id) elif ai_review_state == 'secondary_inspection': setattr(hi_obj, 'inspected_by_second', current_member_id) now = datetime.now() setattr(hi_obj, 'passed_datetime', now) setattr(hi_obj, 'inspection_datetime', now) except MissingParameterError: had_errors = True except InvalidParameterError: had_errors = True if had_errors: home_id = context.getId() api.portal.show_message( message= u"An error occurred while updating home %s. Please notify the administrator." % home_id, request=context.REQUEST, type='error') request = context.REQUEST parent_container = context.aq_parent response = request.response response.redirect('%s/@@walker-assignments' % parent_container.absolute_url()) @button.buttonAndHandler(u'Fail') def handleFail(self, action): """ If fail, transition to first or second failure """ context = self.context annual_inspection_brain = getAnnualInspection() ai_review_state = annual_inspection_brain.review_state active_home_inspection_id = getActiveHomeInspectionId() if not active_home_inspection_id: #nothing to do api.portal.show_message( message= u"Could not find a home inspection form to update, was the annual " u"inspection properly initiated?", request=context.REQUEST, type='info') else: hi_obj = context.get(active_home_inspection_id) current_state = api.content.get_state(obj=hi_obj) had_errors = False transition_id = '' if current_state == 'failed_initial': transition_id = 'fail_second' elif current_state == 'pending': transition_id = 'fail_initial' if transition_id: try: current_member = api.user.get_current() current_member_id = current_member.getId() api.content.transition(obj=hi_obj, transition=transition_id) now = datetime.now() setattr(hi_obj, 'inspection_datetime', now) if transition_id == 'fail_initial': setattr(hi_obj, 'inspected_by_first', current_member_id) elif transition_id == 'fail_second': setattr(hi_obj, 'inspected_by_second', current_member_id) except MissingParameterError: had_errors = True except InvalidParameterError: had_errors = True if had_errors: home_id = context.getId() api.portal.show_message( message= u"An error occurred while updating home %s. Please notify the administrator." % home_id, request=context.REQUEST, type='error') request = context.REQUEST parent_container = context.aq_parent response = request.response return response.redirect('%s/@@walker-assignments' % parent_container.absolute_url()) request = context.REQUEST parent_container = context.aq_parent response = request.response return response.redirect('%s/edit' % hi_obj.absolute_url()) else: home_id = context.getId() api.portal.show_message( message=u"The home inspection was not in a state we could " u"transition from." % home_id, request=context.REQUEST, type='error') request = context.REQUEST parent_container = context.aq_parent response = request.response return response.redirect('%s/@@walker-assignments' % parent_container.absolute_url())
class HouseInspectionEditForm(edit.DefaultEditForm): description = _( u'For each inspection criteria, if the home fails, select the tab and enter a brief explanation. ' u'If a picture is required, take a picture and upload. <i><u>Do Not click "Done" until you have ' u'completed the inspection of the house</u></i> as this immediately saves and closes the inspection. ' u'<b>Once your inspection is completed, click "Done".</b> You will be brought to a page that summarizes ' u'your findings with an opportunity to make changes before the inspection is saved.' ) def updateActions(self): super(HouseInspectionEditForm, self).updateActions() save_action = self.actions.get('save') or None if save_action: save_action.title = u'Done' def updateWidgets(self): context = self.context current_state = api.content.get_state(obj=context) groups = self.groups if current_state in ['failed_final', 'remedied']: for group in groups: fieldset_key = group.__name__ group.fields['%s_rewalk_image' % fieldset_key].mode = None group.fields['%s_rewalk_text' % fieldset_key].mode = None group.fields['%s_cond_remains' % fieldset_key].mode = None group.fields['%s_cond_remains' % fieldset_key].widgetFactory = RadioFieldWidget group.fields['%s_text' % fieldset_key].mode = interfaces.DISPLAY_MODE group.fields['%s_action_required' % fieldset_key].mode = interfaces.DISPLAY_MODE group.fields['%s_image' % fieldset_key].mode = interfaces.DISPLAY_MODE group.fields['%s_image' % fieldset_key].width = 128 group.fields['%s_image' % fieldset_key].height = 96 for_show = [] fieldset_dict = {} [fieldset_dict.update({group.__name__: group}) for group in groups] for key in inspection_keys_to_fieldset_dict.keys(): if getattr(context, key): for_show.append(key) new_groups = [] for skey in for_show: fieldset_key = inspection_keys_to_fieldset_dict.get(skey) s_group = fieldset_dict.get(fieldset_key) new_groups.append(s_group) self.groups = new_groups super(HouseInspectionEditForm, self).updateWidgets() # @z3c.form.button.buttonAndHandler(_(u'Save')) # def handleApply(self, action): # data, errors = self.extractData() # context = self.context # context_state = api.content.get_state(obj=context) # if context_state in ['failed_final', 'remedied']: # for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: # if hasattr(data, '%s_cond_remains' % fieldset_id): # initial_text = getattr(data, '%s_text' % fieldset_id) or None # cond_remains = getattr(data, '%s_cond_remains' % fieldset_id) # if cond_remains is True: # continue # if initial_text is not None and cond_remains is None: # error_keys = fieldset_id.split('_') # error_str = ' '.join(error_keys) # #raise Invalid(_(u"You must verify the condition remains for %s." % error_str)) # #api.portal.show_message(message="Did you verify the condition for %s?" % error_str.title()) # raise ActionExecutionError(Invalid(_(u"You must verify the condition remains " # u"for %s." % error_str.title()))) # # if errors: # self.status = self.formErrorsMessage # return @property def fti(self): return getUtility(IDexterityFTI, name=self.portal_type) @property def label(self): type_name = self.fti.Title() return _(u"${name} - Failures", mapping={'name': type_name})
def label(self): type_name = self.fti.Title() return _(u"${name} - Failures", mapping={'name': type_name})
class IHOANeighborhood(form.Schema): """Uses IDublinCore """ street_addresses = schema.List( title=_(u"Street Addresses"), description=_( u"Please provide a list of street addresses for this neighborhood." ), value_type=schema.TextLine(), ) city = schema.TextLine( title=_(u"City"), description= _(u"Please provide the city to be used with addresses in this neighborhood." )) state = schema.TextLine( title=_(u"State Abbreviation"), description= _(u"Please provide the state abbreviation to be used with addresses in this neighborhood." )) zipcode = schema.TextLine( title=_(u"Zipcode"), description=_(u"Which zipcode does this neighborhood use?")) secretary_email = Email( title=_(u"Executive Secretary Email"), description=_(u"Email address of the Executive Secretary"), required=True, ) fieldset('initial_messages', label=u'Initial Inspection Messages', description=u'', fields=[ 'initial_pass_message', 'initial_fail_message', ]) initial_pass_message = schema.Text( title=_(u"Initial Passed Inspection Message"), description= _(u"This message is used for both email and postal messages to be sent." ), required=False, ) initial_fail_message = schema.Text( title=_(u"Initial Fail Inspection Message"), description= _(u"This message is used for both email and postal messages to be sent." ), required=False, ) fieldset('rewalk_messages', label=u'Re-walk Inspection Messages', description=u'', fields=[ 'rewalk_pass_message', 'rewalk_fail_message', ]) rewalk_pass_message = schema.Text( title=_(u"Reinspect Passed Inspection Message"), description= _(u"This message is used for both email and postal messages to be sent." ), required=False, ) rewalk_fail_message = schema.Text( title=_(u"Reinspect Fail Message"), description= _(u"This message is used for both email and postal messages to be sent." ), required=False, )
class IHOAHouseReWalkInspection(form.Schema): """ """ fieldset('roof', label=u'Roof', description=u'', fields=['title', 'inspection_datetime', 'passed_datetime', 'inspected_by_first', 'inspected_by_second', 'roof_cond_remains', 'roof_action_required', 'roof_text', 'roof_rewalk_text', 'roof_image', 'roof_rewalk_image'] ) form.mode(title='hidden') title = schema.TextLine( title=_(u"Title"), ) form.mode(inspection_datetime='hidden') inspection_datetime = schema.Datetime( title=_(u'First Inspection Datetime'), description=_(u''), required=False, ) form.mode(passed_datetime='hidden') passed_datetime = schema.Datetime( title=_(u'Secondary Inspection Datetime'), description=_(u''), required=False, ) form.mode(inspected_by_first='hidden') inspected_by_first = schema.TextLine( title=_(u"Primary Inspection By"), required=False, ) form.mode(inspected_by_second='hidden') inspected_by_second = schema.TextLine( title=_(u"Secondary Inspection By"), required=False, ) form.widget(roof_cond_remains=RadioFieldWidget) roof_cond_remains = schema.Choice( title=_(u'Roof Condition Remains?'), description=_(u''), source=SimpleVocabulary([SimpleTerm(value=True, title=u"Yes"), SimpleTerm(value=False, title=U"No")]), required=False, ) form.mode(roof_action_required='display') roof_action_required = schema.Choice( title=_(u'Roof Required Action'), description=_(u''), vocabulary=REQUIRED_ACTION_VOCABULARY, required=False, ) form.mode(roof_text='display') roof_text = schema.Text( title=_(u"Roof Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) roof_rewalk_text = schema.Text( title=_(u"Roof Reinspect Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) form.mode(roof_image='display') roof_image = NamedBlobImage( title=_(u"Roof Photo"), description=_(u""), required=False, ) roof_rewalk_image = NamedBlobImage( title=_(u"Roof Re-walk Photo"), description=_(u""), required=False, ) fieldset('gutters', label=u'Gutters', description=u'', fields=['gutters_cond_remains', 'gutters_action_required', 'gutters_text', 'gutters_rewalk_text', 'gutters_image', 'gutters_rewalk_image'] ) form.widget(gutters_cond_remains=RadioFieldWidget) gutters_cond_remains = schema.Choice( title=_(u'Gutter Condition Remains?'), description=_(u''), source=SimpleVocabulary([SimpleTerm(value=True, title=u"Yes"), SimpleTerm(value=False, title=U"No")]), required=False, ) form.mode(gutters_action_required='display') gutters_action_required = schema.Choice( title=_(u'Gutters Required Action'), description=_(u''), vocabulary=REQUIRED_ACTION_VOCABULARY, required=False, ) form.mode(gutters_text='display') gutters_text = schema.Text( title=_(u"Gutters Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) gutters_rewalk_text = schema.Text( title=_(u"Gutters Reinspect Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) form.mode(gutters_image='display') gutters_image = NamedBlobImage( title=_(u"Gutters Photo"), description=_(u""), required=False, ) gutters_rewalk_image = NamedBlobImage( title=_(u"Gutters Re-walk Photo"), description=_(u""), required=False, ) fieldset('exterior_paint', label=u'Exterior Paint', description=u'', fields=['exterior_paint_cond_remains', 'exterior_paint_action_required', 'exterior_paint_text', 'exterior_paint_rewalk_text', 'exterior_paint_image', 'exterior_paint_rewalk_image'] ) form.widget(exterior_paint_cond_remains=RadioFieldWidget) exterior_paint_cond_remains = schema.Choice( title=_(u'Exterior Paint Condition Remains?'), description=_(u''), source=SimpleVocabulary([SimpleTerm(value=True, title=u"Yes"), SimpleTerm(value=False, title=U"No")]), required=False, ) form.mode(exterior_paint_action_required='display') exterior_paint_action_required = schema.Choice( title=_(u'Exterior Paint Required Action'), description=_(u''), vocabulary=REQUIRED_ACTION_VOCABULARY, required=False, ) form.mode(exterior_paint_text='display') exterior_paint_text = schema.Text( title=_(u"Exterior Paint Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) exterior_paint_rewalk_text = schema.Text( title=_(u"Exterior Paint Reinspect Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) form.mode(exterior_paint_image='display') exterior_paint_image = NamedBlobImage( title=_(u"Exterior Paint Photo"), description=_(u""), required=False, ) exterior_paint_rewalk_image = NamedBlobImage( title=_(u"Exterior Paint Re-walk Photo"), description=_(u""), required=False, ) fieldset('decks', label=u'Decks', description=u'', fields=['decks_cond_remains', 'decks_action_required', 'decks_text', 'decks_rewalk_text', 'decks_image', 'decks_rewalk_image'] ) form.widget(decks_cond_remains=RadioFieldWidget) decks_cond_remains = schema.Choice( title=_(u'Decks Condition Remains?'), description=_(u''), source=SimpleVocabulary([SimpleTerm(value=True, title=u"Yes"), SimpleTerm(value=False, title=U"No")]), required=False, ) form.mode(decks_action_required='display') decks_action_required = schema.Choice( title=_(u'Decks Required Action'), description=_(u''), vocabulary=REQUIRED_ACTION_VOCABULARY, required=False, ) form.mode(decks_text='display') decks_text = schema.Text( title=_(u"Decks Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) decks_rewalk_text = schema.Text( title=_(u"Decks Reinspect Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) form.mode(decks_image='display') decks_image = NamedBlobImage( title=_(u"Decks Photo"), description=_(u""), required=False, ) decks_rewalk_image = NamedBlobImage( title=_(u"Decks Re-walk Photo"), description=_(u""), required=False, ) fieldset('entry_way', label=u'Entry Way', description=u'', fields=['entry_way_cond_remains', 'entry_way_action_required', 'entry_way_text', 'entry_way_rewalk_text', 'entry_way_image', 'entry_way_rewalk_image'] ) form.widget(entry_way_cond_remains=RadioFieldWidget) entry_way_cond_remains = schema.Choice( title=_(u'Entry Way Condition Remains?'), description=_(u''), source=SimpleVocabulary([SimpleTerm(value=True, title=u"Yes"), SimpleTerm(value=False, title=U"No")]), required=False, ) form.mode(entry_way_action_required='display') entry_way_action_required = schema.Choice( title=_(u'Entry Way Required Action'), description=_(u''), vocabulary=REQUIRED_ACTION_VOCABULARY, required=False, ) form.mode(entry_way_text='display') entry_way_text = schema.Text( title=_(u"Entry Way Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) entry_way_rewalk_text = schema.Text( title=_(u"Entry Way Reinspect Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) form.mode(entry_way_image='display') entry_way_image = NamedBlobImage( title=_(u"Entry Way Photo"), description=_(u""), required=False, ) entry_way_rewalk_image = NamedBlobImage( title=_(u"Entry Way Re-walk Photo"), description=_(u""), required=False, ) fieldset('paved_surfaces', label=u'Paved Surfaces', description=u'', fields=['paved_surfaces_cond_remains', 'paved_surfaces_action_required', 'paved_surfaces_text', 'paved_surfaces_rewalk_text', 'paved_surfaces_image', 'paved_surfaces_rewalk_image'] ) form.widget(paved_surfaces_cond_remains=RadioFieldWidget) paved_surfaces_cond_remains = schema.Choice( title=_(u'Paved Surfaces Condition Remains?'), description=_(u''), source=SimpleVocabulary([SimpleTerm(value=True, title=u"Yes"), SimpleTerm(value=False, title=U"No")]), required=False, ) form.mode(paved_surfaces_action_required='display') paved_surfaces_action_required = schema.Choice( title=_(u'Paved Surfaces Required Action'), description=_(u''), vocabulary=REQUIRED_ACTION_VOCABULARY, required=False, ) form.mode(paved_surfaces_text='display') paved_surfaces_text = schema.Text( title=_(u"Paved Surfaces Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) paved_surfaces_rewalk_text = schema.Text( title=_(u"Paved Surfaces Reinspect Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) form.mode(paved_surfaces_image='display') paved_surfaces_image = NamedBlobImage( title=_(u"Paved Surfaces Photo"), description=_(u""), required=False, ) paved_surfaces_rewalk_image = NamedBlobImage( title=_(u"Paved Surfaces Re-walk Photo"), description=_(u""), required=False, ) fieldset('landscaping', label=u'Landscaping', description=u'', fields=['landscaping_cond_remains', 'landscaping_action_required', 'landscaping_text', 'landscaping_rewalk_text', 'landscaping_image', 'landscaping_rewalk_image'] ) form.widget(landscaping_cond_remains=RadioFieldWidget) landscaping_cond_remains = schema.Choice( title=_(u'Landscaping Condition Remains?'), description=_(u''), source=SimpleVocabulary([SimpleTerm(value=True, title=u"Yes"), SimpleTerm(value=False, title=U"No")]), required=False, ) form.mode(landscaping_action_required='display') landscaping_action_required = schema.Choice( title=_(u'Landscaping Required Action'), description=_(u''), vocabulary=REQUIRED_ACTION_VOCABULARY, required=False, ) form.mode(landscaping_text='display') landscaping_text = schema.Text( title=_(u"Landscaping Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) landscaping_rewalk_text = schema.Text( title=_(u"Landscaping Reinspect Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) form.mode(landscaping_image='display') landscaping_image = NamedBlobImage( title=_(u"Landscaping Photo"), description=_(u""), required=False, ) landscaping_rewalk_image = NamedBlobImage( title=_(u"Landscaping Re-walk Photo"), description=_(u""), required=False, ) fieldset('general_maintenance', label=u'General Maintenance', description=u'', fields=['general_maintenance_cond_remains', 'general_maintenance_action_required', 'general_maintenance_text', 'general_maintenance_rewalk_text', 'general_maintenance_image', 'general_maintenance_rewalk_image'] ) form.widget(general_maintenance_cond_remains=RadioFieldWidget) general_maintenance_cond_remains = schema.Choice( title=_(u'General Maintenance Condition Remains?'), description=_(u''), source=SimpleVocabulary([SimpleTerm(value=True, title=u"Yes"), SimpleTerm(value=False, title=U"No")]), required=False, ) form.mode(general_maintenance_action_required='display') general_maintenance_action_required = schema.Choice( title=_(u'General Maintenance Required Action'), description=_(u''), vocabulary=REQUIRED_ACTION_VOCABULARY, required=False, ) form.mode(general_maintenance_text='display') general_maintenance_text = schema.Text( title=_(u"General Maintenance Issue"), description=_(u""), required=False, max_length=50, ) general_maintenance_rewalk_text = schema.Text( title=_(u"General Maintenance Reinspect Issue"), description=_(u"Comments included in letter and email. 50 character limit"), required=False, max_length=50, ) form.mode(general_maintenance_image='display') general_maintenance_image = NamedBlobImage( title=_(u"General Maintenance Photo"), description=_(u""), required=False, ) general_maintenance_rewalk_image = NamedBlobImage( title=_(u"General Maintenance Re-walk Photo"), description=_(u""), required=False, ) form.mode(redirect_assignments='hidden') redirect_assignments = schema.TextLine(title=_(u"Redirect Assignments"), required=False) @invariant def confirmAction(data): context = data.__context__ context_state = api.content.get_state(obj=context) for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: if hasattr(data, '%s_text' % fieldset_id): if getattr(data, '%s_text' % fieldset_id): action_required = getattr(data, '%s_action_required' % fieldset_id) if not action_required: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide a required action for %s." % error_str)) if hasattr(data, '%s_action_required' % fieldset_id): if getattr(data, '%s_action_required' % fieldset_id): failure_text = getattr(data, '%s_text' % fieldset_id) if not failure_text: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide a description of the issue if action is required for: %s." % error_str)) @invariant def conditionPerists(data): context = data.__context__ context_state = api.content.get_state(obj=context) if context_state in ['failed_final', 'remedied']: for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: if hasattr(data, '%s_cond_remains' % fieldset_id): if getattr(data, '%s_cond_remains' % fieldset_id): rewalk_txt = getattr(data, '%s_rewalk_text' % fieldset_id) rewalk_image = getattr(data, '%s_rewalk_image' % fieldset_id) if not rewalk_txt: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an a reason the condition persists for %s." % error_str)) if not rewalk_image: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an a photo of the condition for %s." % error_str)) @invariant def verifyCondition(data): context = data.__context__ context_state = api.content.get_state(obj=context) if context_state in ['failed_final', 'remedied']: for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: if hasattr(data, '%s_cond_remains' % fieldset_id): initial_text = getattr(data, '%s_text' % fieldset_id) if initial_text and not getattr(data, '%s_cond_remains' % fieldset_id): error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an image for %s." % error_str)) @invariant def imagesRequired(data): context = data.__context__ context_state = api.content.get_state(obj=context) for fieldset_id in IHOAHOUSEINSPECTION_FIELDSETS: if context_state == 'failed_initial': if getattr(data, '%s_text' % fieldset_id): image = getattr(data, '%s_image' % fieldset_id) if not image: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an image for %s." % error_str)) if context_state == 'failed_final': if getattr(data, '%s_rewalk_text' % fieldset_id): image = getattr(data, '%s_rewalk_image' % fieldset_id) if not image: error_keys = fieldset_id.split('_') error_str = ' '.join(error_keys) raise Invalid(_(u"You must provide an image for %s." % error_str))
sort_on="created", sort_order="descending") annual_inspection_brain = None if annual_inspection_brains: annual_inspection_brain = annual_inspection_brains[0] return annual_inspection_brain def computeTitle(): today = date.today() house_inspection_title = today.strftime(u'%Y-%m') return u'House Inspection %s' % house_inspection_title, REQUIRED_ACTION_VOCABULARY = SimpleVocabulary( [SimpleTerm(value='clean', title=_(u'Clean - 30 Days')), SimpleTerm(value='repair', title=_(u'Repair - 60 Days')), SimpleTerm(value='replace', title=_(u'Replace - 12 Months'))] ) class IHOAHouseInspection(form.Schema): """ """ fieldset('roof', label=u'Roof', description=u'', fields=['title', 'inspection_datetime', 'passed_datetime', 'inspected_by_first',
class IHOAHomeLookupRegistry(form.Schema): """Global Blacklist Settings """ hoa_owners = schema.Dict( title=_(u"Home Owners"), description=_(u"Each key value equals a list of home uuids"), key_type=schema.ASCIILine(title=_(u"Member Id")), value_type=schema.Set(title=_(u"House UUIDS"), value_type=schema.ASCIILine()), required=False, defaultFactory=getDefaultDict, ) hoa_renters = schema.Dict( title=_(u"Home Owners"), description=_(u"Each key value equals a list of home uuids"), key_type=schema.ASCIILine(title=_(u"Member Id")), value_type=schema.Set(title=_(u"House UUIDS"), value_type=schema.ASCIILine()), required=False, defaultFactory=getDefaultDict, ) hoa_property_managers = schema.Dict( title=_(u"Home Owners"), description=_(u"Each key value equals a list of home uuids"), key_type=schema.ASCIILine(title=_(u"Member Id")), value_type=schema.Set(title=_(u"House UUIDS"), value_type=schema.ASCIILine()), required=False, defaultFactory=getDefaultDict, ) hoa_homes_by_uuid = schema.Dict( title=_(u"Home Owners"), description=_(u"Each key value equals a list of home uuids"), key_type=schema.ASCIILine(title=_(u"Home UUID")), value_type=schema.Dict(key_type=schema.ASCIILine(), value_type=schema.ASCIILine()), required=False, defaultFactory=getDefaultDict, )
class IHOAHouse(form.Schema): """ """ fieldset('house_information', label=u'House Information', description=u'Home details', fields=[ 'title', 'div', 'lot', 'street_number', 'street_address', 'city', 'state', 'zipcode', 'picture', 'geo_coordinates_lat', 'geo_coordinates_long', 'last_sale_date', 'rental', ]) form.mode(title='hidden') title = schema.TextLine( title=_(u"Title"), required=False, ) div = schema.Choice( title=_(u"Division Number"), description=_(u""), vocabulary=u'docent.hoa.div_numbers', required=False, ) lot = schema.Choice( title=_(u"Lot Number"), description=_(u""), vocabulary=u'docent.hoa.lot_numbers', required=False, ) street_number = schema.TextLine(title=_(u"Street Number"), description=_(u"")) street_address = schema.Choice( title=_(u"Street Address"), description=_(u""), vocabulary=u'docent.hoa.street_addresses', ) form.mode(city='hidden') city = schema.TextLine( title=_(u"City"), description= _(u"Please provide the city to be used with addresses in this neighborhood." ), defaultFactory=getNeighborhoodCity, ) form.mode(state='hidden') state = schema.TextLine( title=_(u"State Abbreviation"), description= _(u"Please provide the state abbreviation to be used with addresses in this neighborhood." ), defaultFactory=getNeighborhoodState, ) form.mode(zipcode='hidden') zipcode = schema.TextLine( title=_(u"Zipcode"), description=_(u"Which zipcode does this neighborhood use?"), defaultFactory=getNeighborhoodZipCode, ) picture = NamedBlobImage( title=_(u"Upload an image of the home."), required=False, ) geo_coordinates_lat = schema.TextLine( title=_(u"Geo Coordinates Latitude"), description=_(u""), required=False, ) geo_coordinates_long = schema.TextLine( title=_(u"Geo Coordinates Longitude"), description=_(u""), required=False, ) last_sale_date = schema.Date( title=_(u"Last Sale Date"), description=_(u""), required=False, ) rental = schema.Bool( title=_(u'Is this a rental property?'), description=_(u''), required=False, ) fieldset('owner_information', label=u'Owner Information', description=u'Owner details', fields=[ 'owner_one', 'owner_two', ]) owner_one = schema.Choice( title=_(u"Owner One"), description=_(u""), vocabulary=u'docent.hoa.home_owner', ) owner_two = schema.Choice( title=_(u"Owner Two"), description=_(u""), vocabulary=u'docent.hoa.home_owner', required=False, ) fieldset('resident_information', label=u'Resident Information', description=u'Resident details', fields=[ 'resident_one', 'resident_two', ]) resident_one = schema.Choice( title=_(u"Renter One"), description=_(u""), vocabulary=u'docent.hoa.renters', required=False, ) resident_two = schema.Choice( title=_(u"Renter Two"), description=_(u""), vocabulary=u'docent.hoa.renters', required=False, ) fieldset('property_manager', label=u'Propertry Manager', description=u'', fields=[ 'property_manager', ]) property_manager = schema.Choice( title=_(u"Property Manager"), description=_(u""), vocabulary=u'docent.hoa.property_managers', required=False, ) @invariant def ownersInvariant(data): owner_one = data.owner_one owner_two = data.owner_two if owner_one and owner_two: if owner_one == owner_two: raise Invalid( _(u"Owners One and Two cannot be the same individual.")) @invariant def residentInvariant(data): resident_one = data.resident_one resident_two = data.resident_two if resident_one and resident_two: if resident_one == resident_two: raise Invalid( _(u"Resident One and Two cannot be the same individual.")) @invariant def lotInvariant(data): lot = data.lot try: int(lot) except ValueError: raise Invalid(_(u"Lot is not a valid number.")) if len(lot) != 3: raise Invalid( _(u"Lot is not in the correct format (ie 045 for lot 45)"))