Changeset 5183 for WAeUP_SRP/trunk/WAeUPTool.py
- Timestamp:
- 5 May 2010, 05:52:36 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note: See TracChangeset for help on using the changeset viewer.