source: WAeUP_SRP/trunk/skins/waeup_utilities/deleteStudentByMatricNo.py @ 1360

Last change on this file since 1360 was 1350, checked in by joachim, 18 years ago

added Patch for VocalbulariesTool?, which fixed the loading of to many objects.

  • Property svn:keywords set to Id
File size: 2.0 KB
RevLine 
[1310]1## Script (Python) "search_pins"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST,matric_no=None
8##title=
9##
10# $Id: deleteStudentByMatricNo.py 1350 2007-01-25 17:54:18Z joachim $
11"""
12"""
13import logging
14logger = logging.getLogger('DeleteStudentByMatricNo')
15
16request = REQUEST
17wftool = context.portal_workflow
18mtool = context.portal_membership
19member = mtool.getAuthenticatedMember()
20roles = member.getRolesInContext(context)
21stdir = context.portal_directories.students
22st_cat = context.students_catalog
23ret_imp = context.returning_import
24res_imp = context.results_import
25students = context.portal_url.getPortalObject().campus.students
26if str(member) not in ('admin','joachim') or matric_no is None:
[1316]27    return
[1310]28res = st_cat(matric_no=matric_no)
29if len(res) != 1:
30    msg = "Student with matric_no %s not found in students_catalog" % matric_no
31    logger.info(msg)
32    return msg
33stbrain = res[0]
34#from Products.zdb import set_trace;set_trace()
35student_id = stbrain.id
36res_deleted = []
37output = []
38resi = ret_imp(matric_no=matric_no)
39if len(res) != 1:
40    msg = "Student with matric_no %s not found in students_import" % matric_no
41    logger.info(msg)
42else:
43    msg = "Student with matric_no %s removed from students_import" % matric_no
44logger.info(msg)
45output.append(msg)
46results = res_imp(matric_no=matric_no)
47if len(results) > 0:
48    for r in results:
49        res_imp.deleteRecord(r.key)
50        res_deleted.append(r.key)
[1350]51    msg = "%s results deleted" % (',\n'.join(res_deleted))
[1310]52else:
[1316]53    msg = "No results to delete for %s" % matric_no
[1310]54output.append(msg)
55logger.info(msg)
56if hasattr(stdir, student_id):
57    stdir.deleteEntry(student_id)
[1316]58    msg = "Student directory entry for %s deleted" % student_id
[1310]59else:
[1316]60    msg = "No Student directory entry for %s" % student_id
[1310]61output.append(msg)
62logger.info(msg)
63if hasattr(students,student_id):
64    students.manage_delObjects((student_id),)
[1316]65    msg = "Student object for %s deleted" % student_id
[1310]66else:
[1316]67    msg = "No students object for %s" % student_id
[1310]68output.append(msg)
69logger.info(msg)
70return "\n".join(output)
Note: See TracBrowser for help on using the repository browser.