1 | ##parameters= |
---|
2 | # $Id: change_password.py 1461 2007-02-21 17:45:21Z joachim $ |
---|
3 | """ |
---|
4 | process the Application Form |
---|
5 | return html renderer + psm |
---|
6 | """ |
---|
7 | request = context.REQUEST |
---|
8 | import DateTime,logging |
---|
9 | |
---|
10 | current = DateTime.DateTime() |
---|
11 | #pr = context.portal_registration |
---|
12 | logger = logging.getLogger('Student.change_password') |
---|
13 | validate = request.has_key("change_password") |
---|
14 | students_dir = context.portal_directories.students |
---|
15 | lt = context.portal_layouts |
---|
16 | res,psm,ds = lt.renderLayout(layout_id= 'student_change_password', |
---|
17 | schema_id= 'student_change_password', |
---|
18 | context=context, |
---|
19 | mapping=validate and request, |
---|
20 | ob = {}, |
---|
21 | layout_mode='edit', |
---|
22 | button = "Change Password", |
---|
23 | commit = False, |
---|
24 | ) |
---|
25 | if psm == '': |
---|
26 | return context.change_password_form(rendered = res, |
---|
27 | psm = None, |
---|
28 | ds = ds, |
---|
29 | mode = "edit", |
---|
30 | formaction = "change_password", |
---|
31 | button = "Change Password", |
---|
32 | ) |
---|
33 | elif psm == 'invalid': |
---|
34 | psm = "Please correct your input!" |
---|
35 | return context.change_password_form(rendered = res, |
---|
36 | psm = None, |
---|
37 | ds = ds, |
---|
38 | mode = "edit", |
---|
39 | formaction = "change_password", |
---|
40 | button = "Change Password", |
---|
41 | ) |
---|
42 | else: |
---|
43 | student_id = context.getStudentId() |
---|
44 | old_password = request.get('widget__old_password') |
---|
45 | password = request.get('widget__password') |
---|
46 | entry = students_dir.getEntry |
---|
47 | context.portal_membership.setPassword(password) |
---|
48 | psm = "Your Password has been changed" |
---|
49 | return context.change_password_form(rendered = res, |
---|
50 | psm = None, |
---|
51 | ds = ds, |
---|
52 | mode = "edit", |
---|
53 | formaction = "change_password", |
---|
54 | button = "Change Password", |
---|
55 | ) |
---|