- Timestamp:
- 11 May 2007, 15:33:54 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTool.py
r1773 r1774 755 755 ###) 756 756 757 security.declareProtected(ModifyPortalContent,'importEditStudent') ###( 758 def importEditStudent(self,dict): 759 "edit a students data" 760 logger = logging.getLogger('WAeUPTool.create_student') 761 students_folder = self.portal_url.getPortalObject().campus.students 762 sid = dict.get('id',None) 763 jamb_reg_no = dict.get('jamb_reg_no',None) 764 matric_no = dict.get('matric_no',None) 765 if sid: 766 res = self.students_catalog(id = sid) 767 if not res: 768 return '',"no student with id %s" % sid 769 elif matric_no and res[0].matric_no and\ 770 matric_no != res[0].matric_no: 771 return '%s' % res[0].id ,"student has no matric_no %s" % matric_no 772 elif jamb_reg_no and res[0].jamb_reg_no and\ 773 jamb_reg_no != res[0].jamb_reg_no: 774 return '%s' % res[0].id ,"student has no jamb_reg_no %s" % jamb_reg_no 775 elif matric_no: 776 res = self.students_catalog(matric_no = matric_no) 777 if not res: 778 return '',"no student with matric_no %s" % matric_no 779 elif jamb_reg_no and res[0].jamb_reg_no and\ 780 jamb_reg_no != res[0].jamb_reg_no: 781 return '%s' % res[0].id ,"student has no jamb_reg_no %s" % jamb_reg_no 782 elif jamb_reg_no: 783 res = self.students_catalog(jamb_reg_no = jamb_reg_no) 784 if not res: 785 return '',"no student with jamb_reg_no %s" % jamb_reg_no 786 sid = res[0].id 787 student_obj = getattr(students_folder,sid) 788 f2t = self.student_field2types 789 d = {} 790 d['jamb_sex'] = 'M' 791 if dict.get('sex'): 792 d['jamb_sex'] = 'F' 793 for pt in f2t.keys(): 794 sub_obj = getattr(student_obj,f2t[pt]['id'],None) 795 if sub_obj is None: 796 student_obj.invokeFactory(pt,f2t[pt]['id']) 797 sub_obj = getattr(student_obj,f2t[pt]['id']) 798 sub_doc = sub_obj.getContent() 799 self.portal_workflow.doActionFor(sub_obj,'open',dest_container=sub_obj) 800 d['Title'] = f2t[pt]['title'] 801 for field in f2t[pt]['fields']: 802 d[field] = dict.get(field,'') 803 sub_doc.edit(mapping = d) 804 # new_state = f2t[pt]['wf_state'] 805 # if new_state != "remain": 806 # self.portal_workflow.doActionFor(sub_obj,new_state,dest_container=sub_obj) 807 # wfaction = 'return' 808 # self.portal_workflow.doActionFor(student_obj,wfaction) 809 # student_obj.manage_setLocalRoles(sid, ['Owner',]) 810 return sid,'' 811 ###) 812 757 813 security.declareProtected(ModifyPortalContent,"importData")###( 758 def importData(self,filename,name ):814 def importData(self,filename,name,edit=False): 759 815 """load data from CSV values""" 760 816 import transaction … … 788 844 for widget in layout.keys(): 789 845 validators[widget] = layout[widget].validate 790 importer_name = "import%s" % name.capitalize() 846 if edit: 847 importer_name = "importEdit%s" % name.capitalize() 848 else: 849 importer_name = "import%s" % name.capitalize() 791 850 importer = getattr(self, '%s' % importer_name,None) 792 851 if importer is None: -
WAeUP_SRP/trunk/profiles/default/layouts/import.xml
r1756 r1774 33 33 <property name="vocabulary">import_names</property> 34 34 </widget> 35 <widget name="import_or_edit" meta_type="Boolean Widget"> 36 <property name="title">Sex</property> 37 <property name="fields"> 38 <element value="import_or_edit"/> 39 </property> 40 <property name="label">Import or Edit</property> 41 <property name="label_edit">Import or Edit</property> 42 <property name="readonly_layout_modes"/> 43 <property name="hidden_layout_modes"/> 44 <property name="hidden_readonly_layout_modes"/> 45 <property name="label_false">import</property> 46 <property name="label_true">edit</property> 47 <property name="render_format">select</property> 48 </widget> 35 49 <table> 36 50 <row> … … 40 54 <cell name="name"/> 41 55 </row> 56 <row> 57 <cell name="import_or_edit"/> 58 </row> 42 59 </table> 43 60 -
WAeUP_SRP/trunk/profiles/default/schemas/import.xml
r1756 r1774 3 3 <field name="filename" meta_type="CPS String Field"/> 4 4 <field name="name" meta_type="CPS String Field"/> 5 <field name="import_or_edit" meta_type="CPS Boolean Field"/> 5 6 </object> -
WAeUP_SRP/trunk/skins/waeup_default/import.py
r1756 r1774 25 25 if psm == 'invalid': 26 26 return context.import_form(rendered = res, 27 28 29 27 psm = "Please correct your input!", 28 ds = ds, 29 ) 30 30 elif psm == '': 31 31 return context.import_form(rendered = res, 32 33 34 32 psm = None, 33 ds = ds, 34 ) 35 35 elif psm == 'valid': 36 36 pass 37 psm = context.waeup_tool.importData(ds.get('filename'),ds.get('name')) 37 psm = context.waeup_tool.importData(ds.get('filename'), 38 ds.get('name'), 39 ds.get('import_or_edit') 40 ) 38 41 return context.import_form(rendered = res, 39 42 psm = psm,
Note: See TracChangeset for help on using the changeset viewer.