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 | |
---|
15 | request = REQUEST |
---|
16 | wftool = context.portal_workflow |
---|
17 | mtool = context.portal_membership |
---|
18 | member = mtool.getAuthenticatedMember() |
---|
19 | roles = member.getRolesInContext(context) |
---|
20 | retcat = context.returning_import |
---|
21 | scat = context.students_catalog |
---|
22 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
23 | if str(member) not in ('admin',): |
---|
24 | return |
---|
25 | count = 0 |
---|
26 | students = scat() |
---|
27 | #from Products.zdb import set_trace;set_trace() |
---|
28 | for 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) |
---|
60 | return 'ready' |
---|
61 | |
---|
62 | |
---|
63 | |
---|