Changeset 635 for WAeUP_SRP


Ignore:
Timestamp:
10 Oct 2006, 08:23:10 (18 years ago)
Author:
joachim
Message:

halls can now be deleted, first steps for accommodation reservation

Location:
WAeUP_SRP/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/WAeUPTables.py

    r502 r635  
    4848   
    4949    def deleteRecord(self, uid):
     50        #import pdb;pdb.set_trace()
    5051        self.uncatalog_object(uid)
    5152   
     
    7879        WAeUPTable.__init__(self, 'portal_accommodation')
    7980
     81    def searchAndReserveBed(self, student_id,bed_type):
     82        import pdb;pdb.set_trace()
     83        records = self.searchResults({'student' : student_id})
     84        if len(records) > 0:
     85            return -1,"Student with Id %s already booked bed %s" % (student_id,records[0].bed)
     86           
     87        records = self.searchResults({'bed_type' : bed_type, "student": ''})
     88        if len(records) == 0:
     89            return -1,"no bed of this type available"
     90        rec = records[0]
     91        self.modifyRecord(bed=rec.bed,student=student_id)
     92        return 1,rec.bed
     93       
    8094
    8195InitializeClass(AccommodationTable)
     
    90104
    91105
    92     def searchAndSetRecord(self, uid, jamb_reg_no):
     106    def searchAndSetRecord(self, uid, student_id):
    93107        #records = self.searchResults(uid=uid)
    94108        records = self.searchResults({"%s" % self.key : uid})
     
    104118                record_data[field] = getattr(record, field)
    105119            # Add the updated data:
    106             record_data['student'] = jamb_reg_no
     120            record_data['student'] = student_id
    107121            self.catalog_object(dict2ob(record_data), uid)
    108122            return 1
    109         if record.student != jamb_reg_no:
     123        if record.student != student_id:
    110124            return 0
    111         if record.student == jamb_reg_no:
     125        if record.student == student_id:
    112126            return 2
    113127
  • WAeUP_SRP/trunk/Widgets.py

    r586 r635  
    345345        pins = self.portal_pins
    346346        pin = "%(p)s%(b)s%(n)s" % vars()
    347         ref = datastructure[self.reference]
    348         #import pdb;pdb.set_trace()
     347        if self.reference == "":
     348            ref = str(self.portal_membership.getAuthenticatedMember())
     349        else:
     350            ref = datastructure[self.reference]
     351        import pdb;pdb.set_trace()
    349352        ok = pins.searchAndSetRecord(pin,ref)
    350353        while 1:
     
    356359                break
    357360            if ok >= 1:
    358                 student = getStudentByRegNo(self,ref)
     361                if self.isStudent():
     362                    student = self.getStudentInfo()['student']
     363                else:
     364                    student = getStudentByRegNo(self,ref)
    359365                if student is None:
    360366                    err = "Student not Found in validate SC"
  • WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml

    r622 r635  
    1414  </field>
    1515 <field name="reserved_rooms" meta_type="CPS String List Field">
    16     <property name="default_expr"></property>
     16    <property name="default_expr">string:101 102</property>
    1717  </field>
    1818  <field name="rooms_per_floor" meta_type="CPS Int Field">
  • WAeUP_SRP/trunk/profiles/default/types/AccoHall.xml

    r622 r635  
    88 <property name="product">WAeUP_SRP</property>
    99 <property name="factory">addAccoHall</property>
    10  <property name="immediate_view">academics_contents</property>
     10 <property name="immediate_view">accommodation_index</property>
    1111 <property name="global_allow">True</property>
    1212 <property name="filter_content_types">True</property>
  • WAeUP_SRP/trunk/skins/waeup_accommodation/accommodation_view.pt

    r630 r635  
    9393                       % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))"
    9494                       />
    95                 <input type="submit" name="folder_delete:method" value="button_delete"
     95                <input type="submit" name="hall_delete:method" value="button_delete"
    9696                       class="destructive" i18n:attributes="value"
    9797                       tal:attributes="onclick python:'return window.confirm(\'%s\')' %
    9898                       (cpsmcat('description_confirm_delete'), )"
    9999                       />
    100                 <input tal:condition="python: context.portal_type not in ('Semester','Certificate')"
     100                <input tal:condition="python: 0 and context.portal_type not in ('Semester','Certificate')"
    101101                       type="submit" name="id_rename_form:method"
    102102                       class="context" value="Change Object ID" i18n:attributes="value"
  • WAeUP_SRP/trunk/skins/waeup_accommodation/getAccoHallsInfo.py

    r627 r635  
    2121info['is_manager'] = context.isManager()
    2222info['is_student'] = context.isStudent()
    23 info['action'] = "%s" % context.campus.absolute_url()
     23info['action'] = "%s" % context.absolute_url()
    2424info['choosen_ids'] = request.get('ids',[])
    2525items = []
     
    4949        if st:
    5050            res = pa(student=st)
    51             bt_list.append({'student': st, 'bed': res[0].bed })
     51            res_list.append({'student': st, 'bed': res[0].bed })
    5252info['reserved'] = res_list
    5353
  • WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_acco.py

    r629 r635  
    99pr = context.portal_registration
    1010
    11 
    12 type_name = 'StudentApplication'
    13 ti = context.portal_types[type_name]
    14 REQUEST.set('type_name',type_name)
    15 
     11info = context.getStudentInfo()
    1612validate = REQUEST.has_key("cpsdocument_create_button")
    1713
     
    2521                      ob={},
    2622                      layout_mode='create',
    27                       formaction = "acco_reserve",
     23                      formaction = "reserve_acco",
    2824                      button = "book Bed",
    2925                      )
    3026if psm == 'invalid':
    3127    return context.acco_reserve_form(rendered = res,
    32                                  psm = "Please correct your input.",
    33                                  #psm = "%s, %s" % (psm,ds),
     28                                 #psm = "Please correct your input.",
     29                                 psm = "%s, %s" % (psm,ds),
    3430                                 firstlayout = True,
    3531                                 lastlayout = True,
     
    4541elif psm == 'valid':
    4642    s_id = ds.get('s_id')
    47     pin = str(ds.get('app_ac_pin'))
    48     return context.REQUEST.RESPONSE.redirect("%s/logged_in?__ac_name=%s&__ac_password=%s&pin=%s"
    49           % (context.absolute_url(),s_id,pin.split('-')[2],pin))
     43    pin = str(ds.get('acco_res_ac_pin'))
     44    pa = context.portal_accommodation
     45    code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
     46    if code < 0:
     47        return context.acco_reserve_form(rendered = res,
     48                                 psm = bed,
     49                                 firstlayout = True,
     50                                 lastlayout = True,
     51                                 ds = ds,
     52                                 )
     53    else:
     54        return context.acco_reserve_form(rendered = res,
     55                                 psm = "successfully reserved bed %s" % bed,
     56                                 firstlayout = True,
     57                                 lastlayout = True,
     58                                 ds = ds,
     59                                 )
    5060
    5161
    52 return
    53 
    54 
  • WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py

    r603 r635  
    3939info['per'] = student.personal
    4040info['per_doc'] = student.personal.getContent()
     41info['sex'] = 'male'
     42if info['per_doc'].sex:
     43    info['sex'] = 'female'
    4144return info
  • WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt

    r537 r635  
    66  ds options/datastructure;
    77  dm ds/getDataModel;
    8   formaction formaction|string:student_edit;
     8  formaction options/formaction|string:student_edit;
    99  creation creation|nothing;
    1010  metadata metadata|nothing;
Note: See TracChangeset for help on using the changeset viewer.