Changeset 1062


Ignore:
Timestamp:
14 Dec 2006, 20:16:23 (18 years ago)
Author:
joachim
Message:

add search for serial No

Location:
WAeUP_SRP/trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py

    r559 r1062  
    2424    na = node.attributes.items()
    2525    not_found = True
    26     if na[0][1] == "CMF Catalog":
     26    new_indexes = []
     27    new_columns = []
     28    if na[0][1] in ("WAeUP Table"):
    2729        not_found = False
     30    elif na[0][1] == "CMF Catalog":
    2831        #print na[1][1]
     32        not_found = False
    2933        for ch in node._get_childNodes():
    3034            if ch.nodeName in ('index',):
     
    3438                if iname in inds.keys() and inds[iname] == itype:
    3539                    continue
     40                new_indexes.append(iname)
    3641            elif ch.nodeName in ('column',):
    3742                cha = ch.attributes.items()
     
    3944                if iname in columns:
    4045                    continue
     46                new_columns.append(iname)
    4147            else:
    4248                continue
  • WAeUP_SRP/trunk/WAeUPTables.py

    r1030 r1062  
    7878        for field in self.schema() + self.indexes():
    7979            record_data[field] = getattr(record, field)
     80        record_data = {}
     81        for field in self.schema() + self.indexes():
     82            record_data[field] = getattr(record, field)
    8083        # Add the updated data:
    8184        record_data.update(data)
    8285        self.catalog_object(dict2ob(record_data), uid)
    8386
     87    def reindexIndex(self, name, REQUEST,pghandler=None):
     88        if isinstance(name, str):
     89            name = (name,)
     90        paths = self._catalog.uids.items()
     91        i = 0
     92        #import pdb;pdb.set_trace()
     93        for p,rid in paths:
     94            i += 1
     95            metadata = self.getMetadataForRID(rid)
     96            record_data = {}
     97            for field in name:
     98                record_data[field] = metadata.get(field)
     99            uid = metadata.get(self.key)
     100            self.catalog_object(dict2ob(record_data), uid, idxs=name,
     101                                update_metadata=0)
     102           
    84103    security.declareProtected(ModifyPortalContent,"exportAllRecords")
    85104    def exportAllRecords(self):
  • WAeUP_SRP/trunk/profiles/default/accommodation.xml

    r805 r1062  
    11<?xml version="1.0"?>
    2 <object name="portal_catalog" meta_type="CMF Catalog">
     2<object name="portal_catalog" meta_type="WAeUP Table">
    33 <column value="bed"/>
    44 <column value="bed_type"/>
  • WAeUP_SRP/trunk/profiles/default/pins.xml

    r1058 r1062  
    11<?xml version="1.0"?>
    2 <object name="portal_pins" meta_type="CMF Catalog">
     2<object name="portal_pins" meta_type="WAeUP Table">
    33 <column value="pin"/>
    44 <column value="student"/>
  • WAeUP_SRP/trunk/profiles/default/pumeresults.xml

    r966 r1062  
    11<?xml version="1.0"?>
    2 <object name="portal_catalog" meta_type="CMF Catalog">
     2<object name="portal_catalog" meta_type="WAeUP Table">
    33 <column value="jamb_reg_no"/>
    44 <column value="name"/>
  • WAeUP_SRP/trunk/profiles/default/students_catalog.xml

    r971 r1062  
    11<?xml version="1.0"?>
    2 <object name="portal_catalog" meta_type="CMF Catalog">
     2<object name="portal_catalog" meta_type="WAeUP Table">
    33 <column value="id"/>
    44 <column value="jamb_reg_no"/>
  • WAeUP_SRP/trunk/profiles/default/types/ScratchCardBatchesFolder.xml

    r951 r1062  
    2525 <property name="storage_methods"/>
    2626 <property name="cps_is_portlet">False</property>
    27  <alias from="(Default)" to="pins_view"/>
     27 <alias from="(Default)" to="search_pins"/>
    2828 <alias from="create_do" to=""/>
    2929 <alias from="created" to=""/>
    30  <alias from="view" to="pins_view"/>
     30 <alias from="view" to="search_pins"/>
    3131 <action title="View" action_id="view" category="object"
    32     condition_expr="" url_expr="string:${object_url}/pins_view"
     32    condition_expr="" url_expr="string:${object_url}/search_pins"
    3333    visible="True">
    3434  <permission value="View"/>
  • WAeUP_SRP/trunk/skins/waeup_pins/pins_view.pt

    r1002 r1062  
    1 <metal:html>
     1<metal:html tal:define="info options/info;
     2                        rendered options/rendered;
     3                        mtool here/portal_membership;
     4                        member mtool/getAuthenticatedMember;
     5                        ">
    26  <metal:body use-macro="here/main_template/macros/master">
    37    <metal:main fill-slot="main">
     
    59      </span> 
    610      <span tal:condition="not:isAnon">
     11        <span tal:replace="structure rendered" />
     12      <form action="." method="post">
     13        <table>
     14          <tr tal:repeat="pin info/used">
     15            <td>
     16              <input type="checkbox" name="ids:list" value="" id="" class="noborder"
     17                     tal:define="id string:${pin/serial}_${pin/prefix}"
     18                     tal:attributes="value id;
     19                     id python:'cb_' + id;"
     20                     />
     21            </td>
     22            <td width="50px"> <span tal:content="pin/serial" />: </td>
     23            <td tal:content="pin/pin" />
     24            <td tal:content="pin/student_id" />
     25            <td tal:condition="pin/student_url">
     26              <a tal:condition="pin/student_url" href="" tal:content="pin/student"
     27                 tal:attributes="href pin/student_url"></a>
     28              <span tal:condition="not: pin/student_url" tal:content="pin/student" />
     29            </td>
     30          </tr>
     31        </table>
     32        <table width="100%" cellspacing="0" cellpadding="2"
     33               summary="contents of the folder"
     34               class="folderButtons">
     35          <tr>
     36            <td align="left" valign="top" rowspan="3"></td>
     37            <td align="left" valign="top">
     38              <input type="submit" name="disable_pins:method"
     39                     value="disable pins"
     40                     class="destructive"
     41                     tal:attributes="onclick python:'return window.confirm(\'%s\')' %
     42                     (cpsmcat('really disable ?'), )"
     43                     />
     44            </td>
     45            <td align="left" valign="top">
     46              <input type="submit" name="enable_pins:method"
     47                     value="enable pins"
     48                     class="destructive"
     49                     tal:attributes="onclick python:'return window.confirm(\'%s\')' %
     50                     (cpsmcat('really enable ?'), )"
     51                     />
     52            </td>
     53          </tr>
     54        </table>
     55      </form>
    756        <h3>PIN Batches</h3>
    857        <br />
    9         <table tal:define="batches python: context.portal_catalog(portal_type='ScratchCardBatch')">
    10           <tr tal:repeat="batch batches">
    11             <td><a href="batch"
    12                    tal:attributes="href string:${batch/getPath}/search_pins"
    13                    tal:content="batch/Title"></a></td>   
    14           </tr>
    15         </table>
     58      <form action="." method="get">
     59        <select class="form-element" name=":action"
     60                tal:attributes="onChange string:location.href='${context/absolute_url}/'+this.options[this.selectedIndex].value"
     61                >
     62          <option value="--">Goto Batch ...</option>
     63          <option tal:repeat="batch context/objectIds"
     64                  tal:attributes="value batch"
     65                  tal:content="batch">
     66          </option>
     67        </select>
     68      </form>
    1669      </span>
    1770    </metal:main>
  • WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py

    r1012 r1062  
    3333                      )
    3434info = {}
    35 info['batch_doc'] = context.getContent()
    36 info['unused'] = info['batch_doc'].getUnusedPins()
    3735info['used'] = []
    38 info['nr_used'] = info['batch_doc'].getNumberOfUsedPins()
    39 
     36if context.portal_type == "ScratchCardBatch":
     37    info['batch_doc'] = context.getContent()
     38    info['unused'] = info['batch_doc'].getUnusedPins()
     39    info['nr_used'] = info['batch_doc'].getNumberOfUsedPins()
     40    view = context.batch_view
     41elif context.portal_type == "ScratchCardBatchesFolder":
     42    view = context.pins_view
    4043if psm == '':
    41     return context.batch_view(rendered = rend,
    42                              psm = psm,
    43                              #psm = "%s, %s" % (psm,ds),
    44                              info = info,
    45                              allowed = True,
    46                              )
    47 #set_trace()
     44    return view(rendered = rend,
     45                psm = psm,
     46                #psm = "%s, %s" % (psm,ds),
     47                info = info,
     48                allowed = True,
     49                )
    4850what = ds.get('search_mode')
    4951term = ds.get('search_string')
     52pincat = context.portal_pins
    5053if term != "":
    5154    if what == 'student' :
    52         items_1 = context.portal_pins(student = term.upper())
    53         items_2 = context.portal_pins(student = term.lower())
     55        items_1 = pincat(student = term.upper())
     56        items_2 = pincat(student = term.lower())
    5457        items = items_1 + items_2
    5558    elif what == 'pin':
    56         items = context.portal_pins(pin = term.upper())
     59        items = pincat(pin = term.upper())
     60    elif what == 'serial':
     61        try:
     62            snr = int(term.strip())
     63            items = pincat(serial = snr)
     64        except ValueError:
     65            psm = "invalid number"
     66            items = []
     67            pass
    5768    else:
    5869        items = []
     
    6475        sno = i['student']
    6576        item['student'] = sno
     77        item['prefix'] = i.prefix_batch
    6678        item['serial'] = i.serial
    67         item['pin'] = i.pin
     79        if len(sno) > 0:
     80            item['pin'] = i.pin
     81        else:
     82            item['pin'] = "%s%s****%s" % (i.prefix_batch,i.pin[-10:-7],i.pin[-3:])
    6883        if i.pin in pins:
    6984            continue
     
    7388            res = context.students_catalog(jamb_reg_no=sno.upper())
    7489            if len(res) > 0:
    75                 item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
     90                if sno.startswith('disabled'):
     91                    item['student_url'] = None
     92                else:
     93                    item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
    7694                item['student_id'] = res[0].id
    7795            else:
     
    7997                item['student_id'] = ''
    8098        elif sno:
    81             item['student_url'] = '%s/campus/students/%s' % (students_url,item['student'])
    82             item['student_id'] = student
     99            if sno.startswith('disabled'):
     100                item['student_url'] = None
     101            else:
     102                item['student_url'] = '%s/campus/students/%s' % (students_url,item['student'])
     103            item['student_id'] = item['student']
    83104        else:
    84105            item['student_url'] = ''
     
    88109    info['used'] = l
    89110
    90 return context.batch_view(rendered = rend,
    91                              psm = psm,
    92                              #psm = "%s, %s" % (psm,ds),
    93                              info = info,
    94                              allowed = True,
    95                              )
     111return view(rendered = rend,
     112            psm = psm,
     113            #psm = "%s, %s" % (psm,ds),
     114            info = info,
     115            allowed = True,
     116            )
Note: See TracChangeset for help on using the changeset viewer.