Changeset 1012 for WAeUP_SRP/trunk


Ignore:
Timestamp:
8 Dec 2006, 12:34:33 (18 years ago)
Author:
joachim
Message:

=clearance_edit_form fixed, nr_of used Pins is shown in batch_view

Location:
WAeUP_SRP/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/ScratchCards.py

    r1002 r1012  
    147147        return unused
    148148
     149    security.declareProtected(View,"getNumberOfUsedPins")
     150    def getNumberOfUsedPins(self):
     151        """return the number of used Pins"""
     152        #import pdb;pdb.set_trace()
     153        pins_cat = self.portal_pins
     154        doc = self.getContent()
     155        used = [{'pin': p.pin,
     156              'serial': p.serial,
     157              'student': p.student,
     158              } for p in pins_cat.searchResults(prefix_batch = "%s%d"
     159                                               % (doc.prefix,doc.batch_no),
     160                                               ) if p.student]
     161        return len(used)
     162
    149163InitializeClass(ScratchCardBatch)
    150164
  • WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt

    r1009 r1012  
    2727       
    2828       
     29
     30        <h3><span tal:replace="info/nr_used" /> Pins used out of
     31        <span tal:replace="info/batch_doc/no_of_pins" /></h3>
     32     
    2933        <span tal:replace="structure rendered" />
    3034
  • WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py

    r1006 r1012  
    2222lt = context.portal_layouts
    2323validate = request.has_key("cpsdocument_edit_button")
     24default = {'search_mode': 'student',}
    2425rend,psm,ds = lt.renderLayout(layout_id= 'scratch_card_search',
    2526                      schema_id= 'student_search',
    2627                      context=context,
    2728                      mapping=validate and request,
    28                       ob={},
     29                      ob=default,
    2930                      layout_mode='edit',
    3031                      formaction="search_pins",
     
    3536info['unused'] = info['batch_doc'].getUnusedPins()
    3637info['used'] = []
     38info['nr_used'] = info['batch_doc'].getNumberOfUsedPins()
    3739
    3840if psm == '':
     
    4648what = ds.get('search_mode')
    4749term = ds.get('search_string')
     50if term != "":
     51    if what == 'student' :
     52        items_1 = context.portal_pins(student = term.upper())
     53        items_2 = context.portal_pins(student = term.lower())
     54        items = items_1 + items_2
     55    elif what == 'pin':
     56        items = context.portal_pins(pin = term.upper())
     57    else:
     58        items = []
     59    l = []
     60    students_url = "%s/%s" % (context.portal_url(),'students')
     61    pins = []
     62    for i in items:
     63        item = {}
     64        sno = i['student']
     65        item['student'] = sno
     66        item['serial'] = i.serial
     67        item['pin'] = i.pin
     68        if i.pin in pins:
     69            continue
     70        pins.append(i.pins)
     71        if len(sno)==10:
     72            #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
     73            res = context.students_catalog(jamb_reg_no=sno.upper())
     74            if len(res) > 0:
     75                item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
     76                item['student_id'] = res[0].id
     77            else:
     78                item['student_url'] = None
     79                item['student_id'] = ''
     80        elif sno:
     81            item['student_url'] = '%s/campus/students/%s' % (students_url,item['student'])
     82            item['student_id'] = student
     83        else:
     84            item['student_url'] = ''
     85            item['student_id'] = "not used"
     86        l.append(item)
     87       
     88    info['used'] = l
    4889
    49 if what == 'student':
    50     items_1 = context.portal_pins(student = term.upper())
    51     items_2 = context.portal_pins(student = term.lower())
    52     items = items_1 + items_2
    53 elif what == 'pin':
    54     items = context.portal_pins(pin = term.upper())
    55 else:
    56     items = []
    57 l = []
    58 students_url = "%s/%s" % (context.portal_url(),'students')
    59 pins = []
    60 for i in items:
    61     item = {}
    62     sno = i['student']
    63     item['student'] = sno
    64     item['serial'] = i.serial
    65     item['pin'] = i.pin
    66     if i.pin in pins:
    67         continue
    68     pins.append(i.pins)
    69     if len(sno)==10:
    70         #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
    71         res = context.students_catalog(jamb_reg_no=sno.upper())
    72         if len(res) > 0:
    73             item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
    74             item['student_id'] = res[0].id
    75         else:
    76             item['student_url'] = None
    77             item['student_id'] = ''
    78     elif sno:
    79         item['student_url'] = '%s/campus/students/%s' % (students_url,item['student'])
    80         item['student_id'] = student
    81     else:
    82         item['student_url'] = ''
    83         item['student_id'] = "not used"
    84     l.append(item)
    85    
    86 info['used'] = l
    8790return context.batch_view(rendered = rend,
    8891                             psm = psm,
  • WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form.pt

    r939 r1012  
    1010           editable python: (is_student and clear_review_state == 'opened' or is_so) and not is_co;
    1111           mode python: test(editable,'edit','view');
     12           layout_id python: test(is_co,'student_clearance','student_clearance_fe');
    1213           rendered_main python:info['clear_doc'].render(request=request,
    1314                                               layout_mode = mode,
    1415                                               schema_id='student_clearance',
    15                                                layout_id='student_clearance',
     16                                               layout_id=layout_id,
    1617                                               use_session=True);
    1718           form_action string:clearance_edit;
Note: See TracChangeset for help on using the changeset viewer.