Changeset 2845 for WAeUP_SRP


Ignore:
Timestamp:
3 Dec 2007, 21:14:20 (17 years ago)
Author:
joachim
Message:

add sort_id, additional fields in payment

Location:
WAeUP_SRP
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/Accommodation.py

    r2823 r2845  
    1010from Products.CPSDocument.CPSDocument import CPSDocument
    1111from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
    12 from Products.WAeUP_SRP.WAeUPTables import AccommodationTable
     12from Products.WAeUP_SRP.WAeUPTables import AccommodationTable,NOT_OCCUPIED
    1313import logging
    1414import csv,re,os
     
    1818p_home = Globals.package_home(globals())
    1919i_home = Globals.INSTANCE_HOME
     20
    2021
    2122class AccoFolder(CPSDocument): ###(
     
    4748        for hall in halls:
    4849            #import pdb;pdb.set_trace()
    49             h = hall.getContent()
     50            hall_doc = hall.getContent()
    5051            hall_gen = {}
    5152            hall_gen['name'] = hall.Title
    5253            count = 0
    53             reserved = [(r.split('/')[0],int(r.split('/')[1])) for r in re.split(',|\.| ',h.reserved_rooms)
     54            reserved = [(r.split('/')[0],int(r.split('/')[1])) for r in re.split(',|\.| ',hall_doc.reserved_rooms)
    5455                                     if r]
    55             #for block in range(1,int(h.nr_of_blocks)+1):
    56             # for block in 'ABCDEFGHIJ'[:int(h.nr_of_blocks)]:
    57             if set(h.blocks_for_female).intersection(set(h.blocks_for_male)):
     56            #for block in range(1,int(hall_doc.nr_of_blocks)+1):
     57            # for block in 'ABCDEFGHIJ'[:int(hall_doc.nr_of_blocks)]:
     58            if set(hall_doc.blocks_for_female).intersection(set(hall_doc.blocks_for_male)):
    5859                return self.accommodation.acco_folder_view(beds_generated=beds_generated)
    59             for block in h.blocks_for_female + h.blocks_for_male:
     60            for block in hall_doc.blocks_for_female + hall_doc.blocks_for_male:
    6061                sex = 'male'
    61                 if block in h.blocks_for_female:
     62                if block in hall_doc.blocks_for_female:
    6263                    sex = 'female'
    63                 for floor in range(1,int(h.nr_of_floors)+1):
    64                     for room in range(1,int(h.rooms_per_floor)+1):
    65                         for bed in 'ABCDEFGH'[:int(h.beds_per_room)]:
     64                for floor in range(1,int(hall_doc.nr_of_floors)+1):
     65                    for room in range(1,int(hall_doc.rooms_per_floor)+1):
     66                        for bed in 'ABCDEFGH'[:int(hall_doc.beds_per_room)]:
    6667                            room_nr = floor*100 + room
    6768                            bt = 're'
    6869                            if (block,room_nr) in reserved:
    6970                                bt = "reserved"
    70                             elif h.special_handling and not h.special_handling.startswith("no"):
    71                                 bt = h.special_handling
    72                             elif bed in h.beds_for_fresh:
     71                            elif hall_doc.special_handling and not hall_doc.special_handling.startswith("no"):
     72                                bt = hall_doc.special_handling
     73                            elif bed in hall_doc.beds_for_fresh:
    7374                                bt = 'fr'
    74                             elif bed in h.beds_for_pre:
     75                            elif bed in hall_doc.beds_for_pre:
    7576                                bt = 'pr'
    76                             elif bed in h.beds_for_final:
     77                            elif bed in hall_doc.beds_for_final:
    7778                                bt = 'fi'
    78                             if h.special_handling.startswith("no_"):
    79                                 bt += "_" + h.special_handling[3:]
     79                            if hall_doc.special_handling.startswith("no_"):
     80                                bt += "_" + hall_doc.special_handling[3:]
    8081                            bt = "%(sex)s_%(bt)s" % vars()
    8182                            uid = '%s_%s_%d_%s' % (hall.getId(),block,room_nr,bed)
     83                            d = {}
     84                            d['bed'] = uid
     85                            d['bed_type'] = bt
     86                            d['sort_id'] = getattr(hall_doc,'sort_id')
     87                            d['hall'] = hall.getId()
     88                            d['student'] = NOT_OCCUPIED
    8289                            try:
    83                                 freelist.addRecord(bed = uid, bed_type = bt,hall = hall.getId())
     90                                #freelist.addRecord(bed = uid, bed_type = bt,hall = hall.getId())
     91                                freelist.addRecord(**d)
    8492                                count +=1
    8593                                generated.append('"%(uid)s","%(bt)s"' % vars())
    8694                            except ValueError:
    8795                                #freelist.modifyRecord(bed = uid, bed_type = bt,hall =hall.getId())
     96                                #freelist.modifyRecord(**d)
    8897                                pass
    8998            hall_gen['count']= count
     
    239248###)
    240249
     250###)
     251
    241252class AccoHall(CPSDocument): ###(
    242253    """
    243     WAeUP AccoHall containing Departments
     254    WAeUP AccoHall
    244255    """
    245256    meta_type = 'AccoHall'
  • WAeUP_SRP/base/WAeUPTables.py

    r2781 r2845  
    4141ADDING_SHEDULED = "adding_sheduled"
    4242OBJECT_CREATED = "object_created"
     43NOT_OCCUPIED = 'not_occupied'
    4344
    4445from interfaces import IWAeUPTable
     
    486487            name = self.name
    487488        WAeUPTable.__init__(self, name)
    488 
     489   
    489490    def searchAndReserveBed(self, student_id,bed_type):
    490         records = self.searchResults({'student' : student_id})
     491        #records = self.searchResults({'student' : student_id})
     492        import pdb;pdb.set_trace()
     493        records = self.evalAdvancedQuery(Eq('student',student_id))
    491494        if len(records) > 0:
    492495            return -1,"Student with Id %s already booked bed %s." % (student_id,records[0].bed)
    493496
    494         records = [r for r in self.searchResults({'bed_type' : bed_type}) if not r.student]
    495         #import pdb;pdb.set_trace()
     497        #records = [r for r in self.searchResults({'bed_type' : bed_type}) if not r.student]
     498        query = Eq('bed_type',bed_type) & Eq('student',NOT_OCCUPIED)
     499        records = self.evalAdvancedQuery(query,sortSpecs=('sort_id','bed'))
    496500        if len(records) == 0:
    497501            return -2,"No bed available"
  • WAeUP_SRP/base/skins/waeup_accommodation/acco_folder_view.pt

    r2825 r2845  
    5353              <strong tal:content="row/title" /></a> </td>
    5454            <td tal:content="row/id"> </td>
    55            
     55            <td tal:content="row/sort_id"> </td>
    5656            <td>
    57             <a tal:condition="row/is_editable"
     57              <a tal:condition="row/is_editable"
    5858                href="edit" tal:attributes="href string:/${row/url}/external_edit_form"
    5959                target="edit"
  • WAeUP_SRP/base/skins/waeup_accommodation/getAccoFolderInfo.py

    r1447 r2845  
    1212return Info about the Accommodation-Folder
    1313"""
     14try:
     15    from Products.zdb import set_trace
     16except:
     17    def set_trace():
     18        pass
    1419request = context.REQUEST
    1520
     
    2328items = []
    2429is_editable = mtool.checkPermission('Modify portal content', context)
    25 is_editable = False
    26 halls = context.portal_catalog(portal_type='AccoHall')
    27 for f in halls:
     30#is_editable = False
     31#halls = context.portal_catalog(portal_type='AccoHall')
     32for id,hall in context.objectItems():
     33    hall_doc = hall.getContent()
    2834    row = {}
    29     row['id'] = f.id
    30     row['title'] = f.Title
    31     row['url'] = "%s/%s" % (context.absolute_url(),f.id)
     35    row['id'] = id
     36    row['title'] = hall_doc.Title()
     37    row['sort_id'] = getattr(hall_doc,'sort_id',0)
     38    row['url'] = "%s/%s" % (context.absolute_url(),id)
    3239    #fo = f.getObject()
    3340    #row['is_editable'] = mtool.checkPermission('Modify portal content', fo)
    3441    row['is_editable'] = is_editable
    3542    items.append(row)
     43items.sort(cmp=lambda x,y: cmp( x['sort_id'],y['sort_id']))
    3644info['items'] = items
    3745return info
  • WAeUP_SRP/base/skins/waeup_accommodation/getAccoHallInfo.py

    r1914 r2845  
    1212return Info about a Accommodation Hall
    1313"""
     14try:
     15    from Products.zdb import set_trace
     16except:
     17    def set_trace():
     18        pass
     19   
     20from Products.AdvancedQuery import Eq, Between, Le,In
    1421
    1522def cmp_bed(a,b):
     
    2330path_info = request.get('PATH_INFO').split('/')
    2431mtool = context.portal_membership
    25 pa = context.portal_accommodation
     32portal_accommodation = context.portal_accommodation
     33aq_accommodation = portal_accommodation.evalAdvancedQuery
    2634info = {}
    2735#dep_id = request.get('PATH_TRANSLATED').split('/')[-2]
     
    3038info['choosen_ids'] = request.get('ids',[])
    3139info['doc'] = context.getContent()
    32 bed_types = pa.uniqueValuesFor('bed_type')
     40bed_types = portal_accommodation.uniqueValuesFor('bed_type')
    3341bt_list = []
    3442bt_names =  context.getBedTypeNames()
    35 res = pa.uniqueValuesFor('student')
    36 all_booked = [st for st in res if st]
     43res = portal_accommodation.uniqueValuesFor('student')
     44all_booked = [st for st in res if st and st != 'not_occupied']
    3745booked_list = []
    38 #from Products.zdb import set_trace;set_trace()
    3946for bt in bed_types:
    40     total = len(pa(bed_type=bt,hall=context.getId()))
     47    total = len(portal_accommodation(bed_type=bt,hall=context.getId()))
    4148    if total <= 1:
    4249        continue
    43     booked = pa.searchResults({'bed_type': bt,
     50    booked = portal_accommodation.searchResults({'bed_type': bt,
    4451                                 'student':all_booked,
    4552                                 'hall': context.getId()})
     
    4956                    })
    5057    booked_list.extend(booked)
     58# query = ~Eq('student','not_occupied')
     59# beds = aq_accommodation(query,sortSpecs=('bed_type',))
     60# bt_list = []
     61# bt_names =  context.getBedTypeNames()
     62# bt = 'xxx'
     63# for bed in beds:
     64#     if bt != bed.bed_type:
     65#         bt = bed.bed_type
     66#         total = len(aq_accommodation(Eq('bed_type',bt)))
     67#         bt_list.append({'name': bt_names[bt],
     68#                         'total': total,
     69#                         'reserved': len(booked),
     70#                        })
     71     
    5172info['bed_types'] = bt_list
    5273res_list = []
  • WAeUP_SRP/fceokene/profiles/default/accommodation.xml

    r1556 r2845  
    33<object name="portal_accommodation" meta_type="WAeUP Table">
    44 <column value="bed"/>
     5 <column value="sort_id"/>
    56 <column value="bed_type"/>
    67 <column value="hall"/>
     
    1213  <indexed_attr value="bed_type"/>
    1314 </index>
     15 <index name="sort_id" meta_type="FieldIndex">
     16  <indexed_attr value="sort_id"/>
     17 </index>
    1418 <index name="student" meta_type="FieldIndex">
    1519  <indexed_attr value="student"/>
  • WAeUP_SRP/fceokene/profiles/default/layouts/payment.xml

    r2836 r2845  
    99 <property name="validate_values_expr"></property>
    1010 <widget name="amount" meta_type="String Widget">
    11   <property name="title">Fee Authorized</property>
     11  <property name="title">Amount Authorized</property>
    1212  <property name="fields">
    1313   <element value="amount"/>
    1414  </property>
    15   <property name="label">Fee Authorized</property>
    16   <property name="label_edit">Fee Authorized</property>
     15  <property name="label">Amount Authorized</property>
     16  <property name="label_edit">Amount Authorized</property>
    1717  <property name="readonly_layout_modes">
    1818   <element value="edit"/>
     
    115115  <property name="hidden_readonly_layout_modes"/>
    116116 </widget>
     117 <widget name="status" meta_type="Select Widget">
     118  <property name="title">Payment status</property>
     119  <property name="fields">
     120   <element value="status"/>
     121  </property>
     122  <property name="is_required">False</property>
     123  <property name="label">Payment Status</property>
     124  <property name="label_edit">Payment Status</property>
     125  <property name="readonly_layout_modes"/>
     126  <property name="hidden_layout_modes"/>
     127  <property name="hidden_readonly_layout_modes"/>
     128  <property name="vocabulary">payment_status</property>
     129 </widget>
     130 <widget name="subject" meta_type="Select Widget">
     131  <property name="title">Payment Subject</property>
     132  <property name="fields">
     133   <element value="subject"/>
     134  </property>
     135  <property name="is_required">False</property>
     136  <property name="label">Payment Subject</property>
     137  <property name="label_edit">Payment Subject</property>
     138  <property name="readonly_layout_modes"/>
     139  <property name="hidden_layout_modes"/>
     140  <property name="hidden_readonly_layout_modes"/>
     141  <property name="vocabulary">payment_subjects</property>
     142 </widget>
     143 <widget name="target" meta_type="String Widget">
     144  <property name="title">Payment Target</property>
     145  <property name="fields">
     146   <element value="target"/>
     147  </property>
     148  <property name="is_required">False</property>
     149  <property name="label">Payment for</property>
     150  <property name="label_edit">Payment for</property>
     151  <property name="readonly_layout_modes"/>
     152  <property name="hidden_layout_modes"/>
     153  <property name="hidden_readonly_layout_modes"/>
     154 </widget>
     155 <widget name="type" meta_type="Select Widget">
     156  <property name="title">Payment Type</property>
     157  <property name="fields">
     158   <element value="type"/>
     159  </property>
     160  <property name="is_required">False</property>
     161  <property name="label">Payment Type</property>
     162  <property name="label_edit">Payment Type</property>
     163  <property name="readonly_layout_modes"/>
     164  <property name="hidden_layout_modes"/>
     165  <property name="hidden_readonly_layout_modes"/>
     166  <property name="vocabulary">payment_types</property>
     167 </widget>
     168 <widget name="session_id" meta_type="Select Widget">
     169  <property name="title">Session</property>
     170  <property name="fields">
     171   <element value="session_id"/>
     172  </property>
     173  <property name="is_required">False</property>
     174  <property name="label">Session</property>
     175  <property name="label_edit">Session</property>
     176  <property name="readonly_layout_modes"/>
     177  <property name="hidden_layout_modes"/>
     178  <property name="hidden_readonly_layout_modes"/>
     179  <property name="vocabulary">sessions</property>
     180 </widget>
    117181 <widget name="type_description" meta_type="String Widget">
    118182  <property name="title">Payment Description</property>
     
    123187  <property name="label_edit">Payment Description</property>
    124188  <property name="display_width">40</property>
    125   <property name="size_max">40</property>
     189  <property name="size_max">40</property> 
    126190  <property name="readonly_layout_modes"/>
    127191  <property name="hidden_layout_modes"/>
     
    136200  </row>
    137201  <row>
     202   <cell name="status"/>
     203  </row>
     204  <row>
     205   <cell name="type"/>
     206  </row>
     207  <row>
     208   <cell name="subject"/>
     209  </row>
     210  <row>
     211   <cell name="target"/>
     212  </row>
     213  <row>
     214   <cell name="session_id"/>
     215  </row>
     216  <row>
    138217   <cell name="date"/>
    139218  </row>
  • WAeUP_SRP/fceokene/profiles/default/schemas/payment.xml

    r1613 r2845  
    22<?xml-stylesheet type="text/xsl" href="schema.xsl"?>
    33<object name="payment" meta_type="CPS Schema">
     4  <field name="key" meta_type="CPS String Field"/>
    45  <field name="date" meta_type="CPS DateTime Field"/>
    56  <field name="type_code" meta_type="CPS String Field"/>
    67  <field name="type_description" meta_type="CPS String Field" >
    7     <property name="is_searchabletext">True</property>
     8    <property name="is_searchabletext">False</property>
    89  </field>
    910  <field name="amount" meta_type="CPS String Field"/>
     11  <field name="description" meta_type="CPS String Field"/>
     12  <field name="subject" meta_type="CPS String Field"/>
     13  <field name="type" meta_type="CPS String Field"/>
     14  <field name="target" meta_type="CPS String Field"/>
     15  <field name="status" meta_type="CPS String Field"/>
    1016  <field name="resp_pay_reference" meta_type="CPS String Field"/>
    1117  <field name="resp_desc" meta_type="CPS String Field">
    12     <property name="is_searchabletext">True</property>
     18    <property name="is_searchabletext">False</property>
    1319  </field>
    1420  <field name="order_id" meta_type="CPS String Field"/>
     21  <field name="session_id" meta_type="CPS String Field"/>
    1522  <field name="resp_code" meta_type="CPS String Field"/>
    1623  <field name="resp_card_num" meta_type="CPS String Field"/>
     24  <field name="resp_date" meta_type="CPS DateTime Field"/>
    1725  <field name="resp_approved_amount" meta_type="CPS String Field"/>
    1826</object>
Note: See TracChangeset for help on using the changeset viewer.