1 | ##parameters=REQUEST=None |
---|
2 | # $Id: academics_view.py 296 2006-07-14 13:52:50Z joachim $ |
---|
3 | """ |
---|
4 | """ |
---|
5 | request = REQUEST |
---|
6 | rget = request.get |
---|
7 | rset = request.set |
---|
8 | fget = request.form.get |
---|
9 | form = request.form |
---|
10 | fhas = request.form.has_key |
---|
11 | |
---|
12 | |
---|
13 | lt = context.portal_layouts |
---|
14 | pr = context.portal_registration |
---|
15 | pm = context.portal_membership |
---|
16 | items = context.contentValues() |
---|
17 | |
---|
18 | validate = fhas('add') or fhas('change') or fhas('delete') |
---|
19 | res,psm,ds = lt.renderLayout(layout_id='faculty_row', |
---|
20 | schema_id= 'faculty_row', |
---|
21 | context=context, |
---|
22 | mapping= {},#validate and request, |
---|
23 | ob={}, |
---|
24 | layout_mode='edit', |
---|
25 | formaction = "academics_view", |
---|
26 | items=items, |
---|
27 | ) |
---|
28 | #return res |
---|
29 | |
---|
30 | if True:# or psm == 'invalid': |
---|
31 | return context.academics_view_form(rendered = res, |
---|
32 | psm = 'Please correct your errors', |
---|
33 | ds = ds, |
---|
34 | ) |
---|
35 | elif psm == '': |
---|
36 | return context.academics_view_form(rendered = res, |
---|
37 | psm = psm, |
---|
38 | ds = ds, |
---|
39 | ) |
---|
40 | inr = 0 |
---|
41 | if fhas('add') and (fget('type') or fget('subject') or fget('result')): |
---|
42 | sr.append((fget('type'),fget('subject'),fget('result'))) |
---|
43 | psm = "new result added" |
---|
44 | elif fhas('change') and fget('keys'): |
---|
45 | for k in fget('keys'): |
---|
46 | sr[int(k)] = (fget('type_%s' % k),fget('subject_%s' % k),fget('result_%s' % k)) |
---|
47 | inr += 1 |
---|
48 | psm = "%s items changed" % inr |
---|
49 | elif fhas('delete') and fget('keys'): |
---|
50 | new = [] |
---|
51 | todelete = fget('keys') |
---|
52 | for k in range(len(sr)): |
---|
53 | if str(k) not in todelete: |
---|
54 | new.append(sr[k]) |
---|
55 | inr = len(todelete) |
---|
56 | sr = new |
---|
57 | psm = "%s items deleted" % inr |
---|
58 | elif psm == 'valid': |
---|
59 | psm = "Your changes have been saved." |
---|
60 | |
---|
61 | res,dummy,fds = lt.renderLayout(layout_id= 'faculty_row', |
---|
62 | schema_id= 'faculty_row', |
---|
63 | context=context, |
---|
64 | mapping=request, |
---|
65 | ob={}, |
---|
66 | layout_mode='create', |
---|
67 | formaction = "academics_view", |
---|
68 | ) |
---|
69 | |
---|
70 | return context.academic_view_form(rendered = res, |
---|
71 | #psm = "%s <br /> %s" % (str(ds),str(lt.faculty_row.getLayoutDefinition())) |
---|
72 | psm = psm, |
---|
73 | ) |
---|