Ignore:
Timestamp:
22 Dec 2006, 17:00:18 (18 years ago)
Author:
joachim
Message:

new function in search_pins goto Batch HOS_1 and select Pin, and type HOS1 as searchstring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py

    r1120 r1134  
    1818member = mtool.getAuthenticatedMember()
    1919roles = member.getRolesInContext(context)
    20 #from Products.zdb import set_trace
    21 #set_trace()
     20pincat = context.portal_pins
     21students = context.portal_url.getPortalObject().campus.students
     22def check_hostel_pins(term):
     23    items = pincat(prefix_batch = term)
     24    not_found = []
     25    #from Products.zdb import set_trace;set_trace()
     26    for item in items:
     27        if item.student == '':
     28            continue
     29        student = getattr(students,item.student,None)
     30        if student is None:
     31            not_found.append(item)
     32        elif not "accommodation_2006" in student.objectIds():
     33            not_found.append(item)
     34        else:
     35            acco = student.accommodation_2006
     36            acco_doc = acco.getContent()
     37            pin = "".join(str(acco_doc.acco_res_sc_pin).split('-'))
     38            if pin != item.pin:
     39                not_found.append(item)
     40    return not_found
     41       
    2242def set_used_pins(items, from_cat=False):
    2343    l = []
     
    99119what = ds.get('search_mode')
    100120term = ds.get('search_string')
    101 pincat = context.portal_pins
    102121if term != "":
    103122    if what == 'student' :
     
    106125        items = items_1 + items_2
    107126    elif what == 'pin':
    108         items = pincat(pin = term.upper())
     127        if context.portal_type == "ScratchCardBatch" and term == "HOS1":
     128            items = check_hostel_pins(term)
     129        else:
     130            items = pincat(pin = term.upper())
    109131    elif what == 'serial':
    110132        try:
     
    117139    else:
    118140        items = []
    119 ##  students_url = "%s/%s" % (context.portal_url(),'students')
    120141       
    121142info['used'] = set_used_pins(items,from_cat=True)
Note: See TracChangeset for help on using the changeset viewer.