Esempio n. 1
0
 def reset_fields(self):
     ''' fields are moved around during save process and if the validation
         fails this method will return the fields to their original
         locations '''
     if self.api_changed is True:
         # reset the field listing attributes
         self.rdf_field_list = copy_obj(self.original_rdf_field_list)
         self.class_grouping = copy_obj(self.original_class_grouping)
         # reset the class links attribute
         self._set_class_links()
         # call the reset for the subapis
         for fld in self.rdf_field_list:
             if isinstance(fld, ApiList):
                 for api in fld.entries:
                     if isinstance(api, ApiField):
                         api.reset_fields()
             elif isinstance(fld, ApiField):
                         api.reset_fields()
         self.api_changed = False 
 def reset_fields(self):
     ''' fields are moved around during save process and if the validation
         fails this method will return the fields to their original
         locations '''
     if self.form_changed is True:
         # reset the field listing attributes
         self.rdf_field_list = copy_obj(self.original_rdf_field_list)
         self._fields = copy_obj(self.original_fields)
         self.class_grouping = copy_obj(self.original_class_grouping)
         # reset the class links attribute
         self._set_class_links()
         # call the reset for the subforms
         for fld in self.rdf_field_list:
             if isinstance(fld, FieldList):
                 for form in fld.entries:
                     if isinstance(form, FormField):
                         form.reset_fields()
             elif isinstance(fld, FormField):
                         form.reset_fields()
         self.form_changed = False 
 def _tie_wtf_fields_to_field_list(self):
     ''' add the attributes to the wtforms fields and creates the 
         rdf_field_list and the rdf class groupings '''
     self.class_grouping = {}
     _new_field_list = []
     for _class in self.class_set:
         self.class_grouping[_class] = []
     for field in self.rdf_field_list:
         #field['field'] = getattr(self,field['kds_formFieldName'])
         fld = getattr(self,field['kds_formFieldName'])
         if fld:
             for attr, value in field.items():
                 setattr(fld, attr, value)
             setattr(fld, 'processed_data', None)
             setattr(fld, 'old_data', None)
             setattr(fld, 'query_data', None)
             setattr(fld, 'subject_uri', None)
         _new_field_list.append(fld)
         self.class_grouping[field['kds_classUri']].append(fld)
         field['field'] = getattr(self,field['kds_formFieldName'])
     self.rdf_field_list = _new_field_list
     self.original_rdf_field_list = copy_obj(_new_field_list)
     self.original_class_grouping = copy_obj(self.class_grouping)
Esempio n. 4
0
 def _tie_wtf_fields_to_field_list(self):
     ''' add the attributes to the wtforms fields and creates the 
         rdf_field_list and the rdf class groupings '''
     self.class_grouping = {}
     _new_field_list = []
     for _class in self.class_set:
         self.class_grouping[_class] = []
     for field in self.rdf_field_list:
         #field['field'] = getattr(self,field['kds_formFieldName'])
         fld = getattr(self, field['kds_formFieldName'])
         if fld:
             for attr, value in field.items():
                 setattr(fld, attr, value)
             setattr(fld, 'processed_data', None)
             setattr(fld, 'old_data', None)
             setattr(fld, 'query_data', None)
             setattr(fld, 'subject_uri', None)
         _new_field_list.append(fld)
         self.class_grouping[field['kds_classUri']].append(fld)
         field['field'] = getattr(self, field['kds_formFieldName'])
     self.rdf_field_list = _new_field_list
     self.original_rdf_field_list = copy_obj(_new_field_list)
     self.original_class_grouping = copy_obj(self.class_grouping)
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     super(Form, self).__init__(*args, **kwargs)
     self.obj_type = "form"
     self.xsd_load = "string"
     self.form_changed = False
     self.base_url = kwargs.get("base_url", self.base_url)
     self.current_url = kwargs.get("current_url", self.current_url)
     self.form_uri = self.form_uri
     self.save_state = None
     self.save_subject_uri = None
     self.save_results = None
     self.data_subject_uri = kwargs.get("subject_uri",
                                        self.data_subject_uri)
     edit_path = rdfw().get_form_path(self.form_uri, "kdr_EditForm")
     self.edit_path = None
     if edit_path:
         self.edit_path = "{}{}?id={}".format(\
                 self.base_url,
                 edit_path,
                 quote(nz(self.data_subject_uri,'')))
     self.display_path = "{}{}?id={}".format(\
             self.base_url,
             rdfw().get_form_path(self.form_uri, "kdr_DisplayForm"),
             quote(nz(self.data_subject_uri,'')))
     self.data_class_uri = self.data_class_uri
     self.has_subobj = self.has_subobj
     self.is_subobj = self.is_subobj
     self.rdf_field_list = self.rdf_field_list
     self.rdf_instructions = self.rdf_instructions
     self.instance_uri = self.instance_uri
     self.data_class_uri = self.data_class_uri
     self.data_prop_uri = self.data_prop_uri
     self._set_class_links()
     self._tie_wtf_fields_to_field_list()
     if not kwargs.get('no_query'):
         #self._get_form_data()
         self._load_form_select_options()
     for fld in self.rdf_field_list:
         pretty_data = pp.pformat(fld.__dict__)
         setattr(fld, 'debug_data', pretty_data)
     pretty_data = pp.pformat(self.__dict__)
     self.debug_data = pretty_data
     self.original_fields = copy_obj(self._fields)
     self._renumber_field_rows()
 def __init__(self, *args, **kwargs):
     super(Form, self).__init__(*args, **kwargs)
     self.obj_type = "form"
     self.xsd_load = "string"
     self.form_changed = False
     self.base_url = kwargs.get("base_url", self.base_url)
     self.current_url = kwargs.get("current_url", self.current_url)
     self.form_uri = self.form_uri
     self.save_state = None
     self.save_subject_uri = None
     self.save_results = None
     self.data_subject_uri = kwargs.get("subject_uri",self.data_subject_uri)
     edit_path = rdfw().get_form_path(self.form_uri, "kdr_EditForm")
     self.edit_path = None
     if edit_path:
         self.edit_path = "{}{}?id={}".format(\
                 self.base_url,
                 edit_path,
                 quote(nz(self.data_subject_uri,'')))
     self.display_path = "{}{}?id={}".format(\
             self.base_url,
             rdfw().get_form_path(self.form_uri, "kdr_DisplayForm"),
             quote(nz(self.data_subject_uri,'')))     
     self.data_class_uri = self.data_class_uri
     self.has_subobj = self.has_subobj
     self.is_subobj = self.is_subobj                        
     self.rdf_field_list = self.rdf_field_list                
     self.rdf_instructions = self.rdf_instructions            
     self.instance_uri = self.instance_uri                
     self.data_class_uri = self.data_class_uri                          
     self.data_prop_uri = self.data_prop_uri                
     self._set_class_links()
     self._tie_wtf_fields_to_field_list()
     if not kwargs.get('no_query'):
         #self._get_form_data()
         self._load_form_select_options()      
     for fld in self.rdf_field_list:
         pretty_data = pp.pformat(fld.__dict__)
         setattr(fld, 'debug_data', pretty_data)
     pretty_data = pp.pformat(self.__dict__)
     self.debug_data = pretty_data
     self.original_fields = copy_obj(self._fields)
     self._renumber_field_rows()