[600] | 1 | ## Script (Python) "cpsdocument_edit" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters= |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: student_edit.py 486 2006-09-06 10:09:39Z joachim $ |
---|
| 11 | """ |
---|
| 12 | return Info about the current Student |
---|
| 13 | """ |
---|
| 14 | request = context.REQUEST |
---|
| 15 | form = request.form |
---|
| 16 | fget = form.get |
---|
| 17 | info = {} |
---|
| 18 | wf = context.portal_workflow |
---|
| 19 | catalog = context.portal_catalog |
---|
| 20 | lt = context.portal_layouts |
---|
| 21 | pr = context.portal_registration |
---|
[611] | 22 | mtool = context.portal_membership |
---|
[600] | 23 | path_info = request.get('PATH_INFO').split('/') |
---|
[603] | 24 | is_manager = context.isManager |
---|
[600] | 25 | validate = request.has_key("cpsdocument_edit_button") |
---|
| 26 | items = [] |
---|
[603] | 27 | default = {'search_mode': 'course', |
---|
| 28 | 'review_state': 'unchecked', |
---|
[600] | 29 | 'search_string': '' |
---|
| 30 | } |
---|
[603] | 31 | |
---|
[600] | 32 | rend,psm,ds = lt.renderLayout(layout_id= 'academics_search', |
---|
| 33 | schema_id= 'academics_search', |
---|
| 34 | context=context, |
---|
| 35 | mapping=validate and request, |
---|
| 36 | ob=default, |
---|
| 37 | layout_mode='edit', |
---|
| 38 | formaction="searchAcademics" |
---|
| 39 | ) |
---|
| 40 | if psm == '': |
---|
| 41 | return context.academics_search_view(rendered = rend, |
---|
| 42 | psm = psm, |
---|
| 43 | #psm = "%s, %s" % (psm,ds), |
---|
| 44 | objects = items, |
---|
| 45 | is_manager = is_manager, |
---|
| 46 | ) |
---|
| 47 | what = ds.get('search_mode') |
---|
| 48 | state = ds.get('review_state') |
---|
| 49 | term = ds.get('search_string') |
---|
[611] | 50 | if not term and not with_review: |
---|
[600] | 51 | return context.academics_search_view(rendered = rend, |
---|
| 52 | psm = "You must specify a search string", |
---|
| 53 | #psm = "%s, %s" % (psm,ds), |
---|
| 54 | objects = items, |
---|
| 55 | is_manager = is_manager, |
---|
| 56 | ) |
---|
[611] | 57 | with_review = state != "all" |
---|
| 58 | what = ds.get('search_mode') |
---|
| 59 | state = ds.get('review_state') |
---|
| 60 | term = ds.get('search_string') |
---|
| 61 | err = False |
---|
| 62 | with_review = state != "all" |
---|
| 63 | if not term and not with_review: |
---|
| 64 | psm = "You must specify a search string when searching 'all states'." |
---|
| 65 | err = True |
---|
| 66 | elif '*' in term: |
---|
| 67 | psm = "you cannot use the '*' alone" |
---|
| 68 | err = True |
---|
| 69 | if err: |
---|
| 70 | return context.academics_search_view(rendered = rend, |
---|
| 71 | psm = psm, |
---|
| 72 | #psm = "%s, %s" % (psm,ds), |
---|
| 73 | students = items, |
---|
| 74 | is_manager = is_manager, |
---|
| 75 | ) |
---|
| 76 | with_review = state != "all" |
---|
[600] | 77 | items = [] |
---|
| 78 | res = [] |
---|
[611] | 79 | portal_type_query = {'query':['Course','CertificateCourse']} |
---|
| 80 | onlyreview = with_review and not term |
---|
[600] | 81 | if onlyreview: |
---|
| 82 | res = catalog(portal_type=portal_type_query, |
---|
| 83 | review_state=state) |
---|
[611] | 84 | elif what == "course": |
---|
| 85 | res = catalog(portal_type='Course', |
---|
[600] | 86 | SearchableText="%s*" % term.strip().lower()) |
---|
[611] | 87 | elif what == "certificate_course": |
---|
| 88 | res = catalog(portal_type='CertificateCourse', |
---|
[600] | 89 | SearchableText="%s*" % term.strip().lower()) |
---|
[611] | 90 | objects = [] |
---|
[600] | 91 | if res: |
---|
| 92 | for r in res: |
---|
| 93 | row = {} |
---|
[611] | 94 | ro = r.getObject() |
---|
| 95 | rd = ro.getContent() |
---|
| 96 | row['id'] = r.getId |
---|
| 97 | row['title'] = rd.Title() |
---|
| 98 | row['url'] = ro.absolute_url() |
---|
| 99 | row['review_state'] = wf.getInfoFor(ro,'review_state','None') |
---|
| 100 | row['is_editable'] = mtool.checkPermission('Modify portal content', ro) |
---|
| 101 | objects.append(row) |
---|
| 102 | #objects.append(context.getStudentInfo(item)) |
---|
[600] | 103 | return context.academics_search_view(rendered = rend, |
---|
[611] | 104 | psm = "%d matching objects found" % len(objects), |
---|
[600] | 105 | #psm = "%s, %s" % (psm,ds), |
---|
| 106 | objects = objects, |
---|
| 107 | is_manager = is_manager, |
---|
[611] | 108 | choosen_ids = [] |
---|
[600] | 109 | ) |
---|