source: WAeUP_SRP/trunk/skins/waeup_utilities/fillMetadata.py @ 11152

Last change on this file since 11152 was 5202, checked in by Henrik Bettermann, 14 years ago

add metadata firstname, middlename and lastname in students_catalog

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1## Script (Python) "fillMetadata"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST
8##title=
9##
10# $Id: fillMetadata.py 5202 2010-05-23 04:26:23Z henrik $
11"""
12
13"""
14
15request = REQUEST
16wftool = context.portal_workflow
17mtool = context.portal_membership
18member = mtool.getAuthenticatedMember()
19roles = member.getRolesInContext(context)
20retcat = context.returning_import
21scat = context.students_catalog
22students_folder = context.portal_url.getPortalObject().campus.students
23if str(member) not in ('admin',):
24    return
25count = 0
26students = scat()
27#from Products.zdb import set_trace;set_trace()
28for sbrain in students:
29    student = getattr(students_folder,sbrain.id,None)
30    if student is None:
31        continue
32       
33       
34    per = getattr(student,'personal',None)
35    if per is None:
36        continue
37    #from Products.zdb import set_trace;set_trace()
38    per_doc = per.getContent()
39    marit_stat = per_doc.marit_stat
40    if marit_stat == True:
41        ms = 'married'
42    elif marit_stat == False:
43        ms = 'single'
44    else:
45        ms = 'undefined'
46    fn = per_doc.firstname
47    mn = per_doc.middlename
48    ln = per_doc.lastname
49       
50    clear = getattr(student,'clearance',None)
51    if clear is None:
52        continue
53    birthday = clear.getContent().birthday
54    if birthday:
55        bd = birthday
56    else:
57        bd = ''
58               
59    context.students_catalog.modifyRecord(id = sbrain.id,marit_stat = ms, date_of_birth = bd,firstname = fn, middlename = mn,lastname = ln)
60return 'ready'
61   
62   
63   
Note: See TracBrowser for help on using the repository browser.