Changeset 5183 for WAeUP_SRP/trunk
- Timestamp:
- 5 May 2010, 05:52:36 (15 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPImport.py
r5063 r5183 1127 1127 current_level = mapping.get('current_level','') 1128 1128 transition = mapping.get('reg_transition',None) 1129 change_reg_state = mapping.get('change_reg_state',None) # for brute force method 1129 1130 # the validate_courses import transition is not really useful because it does not execute validate_courses.py 1130 1131 if transition and transition not in ('admit','return','graduate','pay_school_fee','validate_courses'): … … 1181 1182 pass 1182 1183 if transition: 1184 #import pdb;pdb.set_trace() 1183 1185 try: 1184 1186 self.portal_workflow.doActionFor(student_obj,transition) 1185 1187 except: 1186 1188 msg = "reg_transition not allowed" 1189 elif change_reg_state: 1190 msg = self.waeup_tool.changeStudentState(student_obj, change_reg_state) 1191 1187 1192 if password: 1188 1193 self.waeup_tool.editPassword(student_id,password) … … 1441 1446 level_review_state = wftool.getInfoFor(level_obj,'review_state',None) 1442 1447 if level_review_state != "closed": 1443 wftool.doActionFor(level_obj,'close') 1448 #wftool.doActionFor(level_obj,'close') 1449 self.waeup_tool.changeWorkflowState(level_obj, 'closed') 1444 1450 # msg = 'student %s: level %s is not closed' % (student_id, 1445 1451 # current_level) … … 1448 1454 level_obj.getContent().edit(mapping = d) 1449 1455 if student_review_state != "returning": 1450 wftool.doActionFor(student_obj,'return') 1456 #wftool.doActionFor(student_obj,'return') 1457 self.waeup_tool.changeStudentState(student_obj, 'returning') 1451 1458 # try: 1452 1459 # wftool.doActionFor(level_obj,'close') -
WAeUP_SRP/trunk/WAeUPTool.py
r5168 r5183 1929 1929 1930 1930 1931 security.declareProtected(ModifyPortalContent,"changeWorkflowState") 1932 def changeWorkflowState(self, content, state_id, acquire_permissions=False, 1933 portal_workflow=None, **kw): 1934 """Change the workflow state of an object 1935 @param content: Content obj which state will be changed 1936 @param state_id: name of the state to put on content 1937 @param acquire_permissions: True->All permissions unchecked and on riles and 1938 acquired 1939 False->Applies new state security map 1940 @param portal_workflow: Provide workflow tool (optimisation) if known 1941 @param kw: change the values of same name of the state mapping 1942 @return: None 1943 """ 1944 1945 if portal_workflow is None: 1946 portal_workflow = getToolByName(content, 'portal_workflow') 1947 1948 # Might raise IndexError if no workflow is associated to this type 1949 1950 wf_def = portal_workflow.getWorkflowsFor(content)[0] 1951 wf_id= wf_def.getId() 1952 1953 wf_state = { 1954 'action': None, 1955 'actor': None, 1956 'comments': "Setting state to %s" % state_id, 1957 'review_state': state_id, 1958 'time': DateTime.DateTime(), 1959 } 1960 1961 # Updating wf_state from keyword args 1962 for k in kw.keys(): 1963 # Remove unknown items 1964 if not wf_state.has_key(k): 1965 del kw[k] 1966 if kw.has_key('review_state'): 1967 del kw['review_state'] 1968 wf_state.update(kw) 1969 1970 portal_workflow.setStatusOf(wf_id, content, wf_state) 1971 1972 if acquire_permissions: 1973 # Acquire all permissions 1974 for permission in content.possible_permissions(): 1975 content.manage_permission(permission, acquire=1) 1976 else: 1977 # Setting new state permissions 1978 wf_def.updateRoleMappingsFor(content) 1979 1980 # Map changes to the catalogs 1981 content.reindexObject(idxs=['allowedRolesAndUsers', 'review_state']) 1982 return 1983 1984 1985 1986 security.declareProtected(ModifyPortalContent,"changeStudentState") 1987 def changeStudentState(self, content, state_id, acquire_permissions=False, 1988 portal_workflow=None, **kw): 1989 """Change the student state of an object 1990 1991 ChangeWorkflowState + indexing students_catalog and check for registration state 1992 1993 """ 1994 1995 if portal_workflow is None: 1996 portal_workflow = getToolByName(content, 'portal_workflow') 1997 1998 # Might raise IndexError if no workflow is associated to this type 1999 2000 wf_def = portal_workflow.getWorkflowsFor(content)[0] 2001 wf_id= wf_def.getId() 2002 wf = portal_workflow.getWorkflowById(wf_id) 2003 2004 if not wf.states.get(state_id): 2005 return 'reg state does not exist' 2006 2007 wf_state = { 2008 'action': None, 2009 'actor': None, 2010 'comments': "Setting state to %s" % state_id, 2011 'review_state': state_id, 2012 'time': DateTime.DateTime(), 2013 } 2014 2015 # Updating wf_state from keyword args 2016 for k in kw.keys(): 2017 # Remove unknown items 2018 if not wf_state.has_key(k): 2019 del kw[k] 2020 if kw.has_key('review_state'): 2021 del kw['review_state'] 2022 wf_state.update(kw) 2023 2024 portal_workflow.setStatusOf(wf_id, content, wf_state) 2025 2026 if acquire_permissions: 2027 # Acquire all permissions 2028 for permission in content.possible_permissions(): 2029 content.manage_permission(permission, acquire=1) 2030 else: 2031 # Setting new state permissions 2032 wf_def.updateRoleMappingsFor(content) 2033 2034 # Map changes to the catalogs 2035 content.reindexObject(idxs=['allowedRolesAndUsers', 'review_state']) 2036 data = {} 2037 #import pdb;pdb.set_trace() 2038 student_id = content.getId() 2039 res = self.students_catalog(id=student_id) 2040 data['id'] = student_id 2041 data['review_state'] = state_id 2042 self.students_catalog.modifyRecord(**data) 2043 2044 return 2045 2046 1931 2047 InitializeClass(WAeUPTool) -
WAeUP_SRP/trunk/profiles/default/layouts/import_student.xml
r5031 r5183 31 31 <property name="is_required">True</property> 32 32 </widget> 33 34 <widget name="change_reg_state" meta_type="String Widget"> 35 <property name="fields"> 36 <element value="change_reg_state"/> 37 </property> 38 <property name="is_required">False</property> 39 </widget> 40 41 33 42 <widget name="email" meta_type="Email Widget"> 34 43 <property name="title">Email</property> -
WAeUP_SRP/trunk/profiles/default/schemas/import_student.xml
r4558 r5183 5 5 <field name="import_mode" meta_type="CPS String Field"/> 6 6 <field name="reg_transition" meta_type="CPS String Field"/> 7 <field name="change_reg_state" meta_type="CPS String Field"/> 7 8 <field name="firstname" meta_type="CPS String Field"/> 8 9 <field name="middlename" meta_type="CPS String Field"/>
Note: See TracChangeset for help on using the changeset viewer.