Ignore:
Timestamp:
2 Oct 2006, 12:24:04 (18 years ago)
Author:
joachim
Message:

academisSearch can now be used for searching Courses,
the context is not yet taken into account,
the delete button does not work correctly yet.
pleade edit layout academics_search and the vocabularies to fit your needs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_academics/searchAcademics.py

    r603 r611  
    2020lt = context.portal_layouts
    2121pr = context.portal_registration
     22mtool = context.portal_membership
    2223path_info = request.get('PATH_INFO').split('/')
    2324is_manager = context.isManager
     
    4748state = ds.get('review_state')
    4849term = ds.get('search_string')
    49 if state == " ----- ":
    50     state = ''
    51 if not term and what in ('student_edit','jamb_reg_no','name','matric_no'):
     50if not term and not with_review:
    5251    return context.academics_search_view(rendered = rend,
    5352                             psm = "You must specify a search string",
     
    5655                             is_manager = is_manager,
    5756                             )
    58 onlyreview = state and what == "review_state"
     57with_review = state != "all"
     58what = ds.get('search_mode')
     59state = ds.get('review_state')
     60term = ds.get('search_string')
     61err = False
     62with_review = state != "all"
     63if not term and not with_review:
     64    psm = "You must specify a search string when searching 'all states'."
     65    err = True
     66elif '*' in term:
     67    psm = "you cannot use the '*' alone"
     68    err = True
     69if 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                             )
     76with_review = state != "all"
    5977items = []
    6078res = []
    61 portal_type_query = {'query':['Department','Course','CertificateCourse']}
     79portal_type_query = {'query':['Course','CertificateCourse']}
     80onlyreview = with_review and not term
    6281if onlyreview:
    6382    res = catalog(portal_type=portal_type_query,
    6483                  review_state=state)
    65 elif what == "student_id":
    66     res = catalog(portal_type='Student',
    67                   id = term.strip())
    68 elif what == "jamb_reg_no":
    69     res = catalog(portal_type='StudentApplication',
     84elif what == "course":
     85    res = catalog(portal_type='Course',
    7086                  SearchableText="%s*" % term.strip().lower())
    71 elif what == "matric_no":
    72     res = catalog(portal_type='StudentClearance',
     87elif what == "certificate_course":
     88    res = catalog(portal_type='CertificateCourse',
    7389                  SearchableText="%s*" % term.strip().lower())
    74 elif what == "name":
    75     res = catalog(portal_type=portal_type_query,
    76                   SearchableText="%s*" % term.strip())
     90objects = []
    7791if res:
    7892    for r in res:
    7993        row = {}
    80         if r.portal_type in ("StudentApplication","StudentPersonal"):
    81             items.append(r.getObject().aq_parent)
    82         else:
    83             items.append(r.getObject())
    84 objects = []
    85 if items:
    86     for item in items:
    87         objects.append(context.getStudentInfo(item))
     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))
    88103return context.academics_search_view(rendered = rend,
    89                              psm = "%d matching objects found" % len(items),
     104                             psm = "%d matching objects found" % len(objects),
    90105                             #psm = "%s, %s" % (psm,ds),
    91106                             objects = objects,
    92107                             is_manager = is_manager,
     108                             choosen_ids = []
    93109                             )
Note: See TracChangeset for help on using the changeset viewer.