Changeset 2307 for WAeUP_SRP/base


Ignore:
Timestamp:
4 Oct 2007, 06:21:53 (17 years ago)
Author:
joachim
Message:

allow apply_pume without reg_no. call with apply_pume/prence

Location:
WAeUP_SRP/base
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/Widgets.py

    r2289 r2307  
    13331333    meta_type = "Pume Pin Widget"
    13341334    catalog = "applicants_catalog"
     1335    reference = ''
    13351336
    13361337    def validate(self, datastructure, **kw): ###(
     
    13411342        err = 0
    13421343        mapping = {}
    1343 
     1344        #import pdb;pdb.set_trace()
    13441345        prefix= self.prefix
    13451346        if prefix.startswith('@'):
     
    13501351        pin = "%(prefix)s%(b)s%(n)s" % vars()
    13511352        pin_str = "%(prefix)s-%(b)s-%(n)s" % vars()
     1353        member_id = str(self.portal_membership.getAuthenticatedMember())
    13521354        do = 1
    1353         s_id = str(self.portal_membership.getAuthenticatedMember())
    13541355        if self.isStaff():
    13551356            do = 0
     
    13591360            do = 0
    13601361            err = 'PIN must not contain "-"'
    1361             s_logger.info('%s entered invalid PIN  containing "-"' % (s_id))
     1362            s_logger.info('%s entered invalid PIN  containing "-"' % (member_id))
    13621363        elif n.find('-') > -1:
    13631364            do = 0
    13641365            err = 'PIN must not contain "-"'
    1365             s_logger.info('%s entered invalid PIN  containing "-"' % (s_id))
     1366            s_logger.info('%s entered invalid PIN  containing "-"' % (member_id))
    13661367        elif len(n) != 10:
    13671368            do = 0
    13681369            err = 'Invalid PIN length'
    1369             s_logger.info('%s entered invalid PIN with length %d' % (s_id,len(n)))
     1370            s_logger.info('%s entered invalid PIN with length %d' % (member_id,len(n)))
    13701371        elif self.reference == "":
    1371             ref = s_id
     1372            ref = n
    13721373        else:
    13731374            ref = datastructure[self.reference]
     
    13751376                do = 0
    13761377                datastructure.setError(widget_id, 'PIN neither checked nor used.')
    1377                 s_logger.info('%s/%s entered wrong data together with PIN %s' % (s_id,ref,pin_str))
     1378                s_logger.info('%s/%s entered wrong data together with PIN %s' % (member_id,ref,pin_str))
    13781379        while do:
    13791380            ok = pins.searchAndSetRecord(pin,ref,prefix)
    13801381            if ok < -2 or ok > 2:
    13811382                err = 'Unknown error, please report!'
    1382                 s_logger.info('%s/%s caused unknown error with PIN %s' % (s_id,ref,pin_str))
     1383                s_logger.info('%s/%s caused unknown error with PIN %s' % (member_id,ref,pin_str))
    13831384                break
    13841385            elif ok == -2:
    13851386                err = 'Service already is activated but with a different PIN.'
    1386                 s_logger.info('%s/%s repeatedly activated service but with different PIN %s' % (s_id,ref,pin_str))
     1387                s_logger.info('%s/%s repeatedly activated service but with different PIN %s' % (member_id,ref,pin_str))
    13871388                break
    13881389            elif ok == -1:
    13891390                err = 'Invalid PIN'
    1390                 s_logger.info('%s/%s entered invalid PIN %s' % (s_id,ref,pin_str))
     1391                s_logger.info('%s/%s entered invalid PIN %s' % (member_id,ref,pin_str))
    13911392                break
    13921393            if ok == 0:
    13931394                err = 'PIN already used'
    1394                 s_logger.info('%s/%s entered used PIN %s' % (s_id,ref,pin_str))
     1395                s_logger.info('%s/%s entered used PIN %s' % (member_id,ref,pin_str))
    13951396                break
    13961397            if ok >= 1:
    13971398                if self.isStudent():
    13981399                    err = "This is only for Pume application."
    1399                     s_logger.info('%s/%s applied for screening test with PIN %s' % (s_id,ref,pin_str))
     1400                    s_logger.info('%s/%s applied for screening test with PIN %s' % (member_id,ref,pin_str))
    14001401                    break
    1401                 else:
     1402                elif datastructure.has_key('record'):
    14021403                    applicant = datastructure['record']
    14031404                    if not applicant.pin:
     
    14091410                        getattr(self,self.catalog).modifyRecord(**d)
    14101411                    elif applicant.pin != pin_str:
    1411                         s_logger.info('%s/%s tried to enter application record with different PIN %s' % (s_id,ref,pin_str))
     1412                        s_logger.info('%s/%s tried to enter application record with different PIN %s' % (member_id,ref,pin_str))
    14121413                    elif applicant.pin == pin_str:
    1413                         s_logger.info('%s/%s repeatedly entered application record with PIN %s' % (s_id,ref,pin_str))
     1414                        s_logger.info('%s/%s repeatedly entered application record with PIN %s' % (member_id,ref,pin_str))
     1415                else:
     1416                    datastructure['reg_no'] = ref
     1417                    res = self.applicants_catalog(reg_no = ref)
     1418                    if not res:
     1419                        s_logger.info('%s successfully used PIN %s' % (ref,pin_str))
     1420                        d = {}
     1421                        d['reg_no'] = ref
     1422                        d['pin'] = pin_str
     1423                        d['status'] = 'entered'
     1424                        self.applicants_catalog.addRecord(**d)
     1425                    else:
     1426                        s_logger.info('%s/%s repeatedly entered application record with PIN %s' % (ref,ref,pin_str))
    14141427            break
    14151428        if err:
     
    14221435            datastructure[widget_id+'_b'] = b
    14231436            datastructure[widget_id+'_n'] = n
    1424             datastructure['s_id'] = s_id
    14251437        return not err
    14261438    ###)
  • WAeUP_SRP/base/skins/waeup_student/apply_pume.py

    r2184 r2307  
    4848if manage:
    4949    validate = False
    50 
     50layout = "application"
     51prence = ""
     52without_reg_no = False
     53if traverse_subpath and traverse_subpath[0] == "prence":
     54    layout = "application_prence"
     55    prence = "prence"
     56    without_reg_no = True
    5157lt = context.portal_layouts
    5258reg_no = request.get('widget__reg_no','').upper()
     
    8187    logger.info('%s/%s views application slip' % (member,reg_no))
    8288
    83 res,psm,ds = lt.renderLayout(layout_id= 'application',
     89res,psm,ds = lt.renderLayout(layout_id= layout,
    8490                             schema_id= 'application',
    8591                             layout_mode = mode,
     
    96102                                   mode = mode,
    97103                                   ds = ds,
     104                                   prence = prence,
    98105                                  )
    99106
     
    104111                                   mode = mode,
    105112                                   ds = ds,
     113                                   prence = prence,
    106114                                  )
    107115elif psm == '' and not manage:
     
    110118                                   ds = ds,
    111119                                   mode = mode,
     120                                   prence = prence,
    112121                                  )
    113122elif psm == 'valid' or (psm == '' and manage):
    114123    pass
     124if without_reg_no:
     125    reg_no = ds.get('reg_no')
    115126data = {}
    116127dm = ds.getDataModel()
     
    120131data['reg_no'] = reg_no
    121132
    122 
    123 
    124133if apply_pume:
    125134    if submitted:
     
    127136        psm = "The form has already been submitted and you are not allowed to resubmit the data!"
    128137        logger.info('%s/%s tried to resubmit application record' % (member,reg_no))
    129         res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= 'application',
     138        res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout,
    130139                                schema_id= 'application',
    131140                                layout_mode = mode,
     
    152161        context.applicants_catalog.modifyRecord(**data)
    153162
    154         res,psm_dummy,ds = lt.renderLayout(layout_id= 'application',
     163        res,psm_dummy,ds = lt.renderLayout(layout_id= layout,
    155164                                schema_id= 'application',
    156165                                layout_mode = mode,
     
    169178    psm = ""
    170179    #set_trace()
     180    if without_reg_no:
     181        object['reg_no'] = reg_no
    171182    object['pin'] = str(ds.get('pin'))
    172     res,psm,ds_dummy = lt.renderLayout(layout_id= 'application',
     183    res,psm,ds_dummy = lt.renderLayout(layout_id= layout,
    173184                                schema_id= 'application',
    174185                                layout_mode = mode,
     
    183194        psm = "The form has already been submitted and you are not allowed to modify the data!"
    184195        logger.info('%s/%s tried to edit submitted application record' % (member,reg_no))
    185         res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= 'application',
     196        res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout,
    186197                                schema_id= 'application',
    187198                                layout_mode = mode,
     
    203214        psm = "You are now assuming the applicant's role!"
    204215        logger.info('%s/%s entered application record' % (member,reg_no))
    205         res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= 'application',
     216        res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout,
    206217                                schema_id= 'application',
    207218                                layout_mode = mode,
     
    223234
    224235return context.apply_pume_form(rendered = res,
    225                             psm = psm,
    226                             #psm = "%s, %s" % (psm,ds),
    227                             mode = mode,
    228                             show_submit = passport_uploaded,
    229                             ds = ds,
    230                             )
    231 
    232 
     236                               psm = psm,
     237                               #psm = "%s, %s" % (psm,ds),
     238                               mode = mode,
     239                               show_submit = passport_uploaded,
     240                               ds = ds,
     241                               prence = prence,
     242                              )
     243
     244
  • WAeUP_SRP/base/skins/waeup_student/apply_pume_form.pt

    r2157 r2307  
    1515        <form action="" id="editForm" method="post"
    1616              enctype="multipart/form-data" class="workflow"
    17               tal:attributes="action string:${context/absolute_url}/apply_pume"
     17              tal:attributes="action string:${context/absolute_url}/apply_pume/${options/prence}"
    1818              >
    1919          <input type="hidden" name="reg_no"
Note: See TracChangeset for help on using the changeset viewer.