Ignore:
Timestamp:
30 Jan 2008, 19:16:38 (17 years ago)
Author:
joachim
Message:

avoid portal_catalog in payments-list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/fceokene/waeup_custom/getPaymentsFolderInfo.py

    r3026 r3069  
    1414
    1515mtool = context.portal_membership
     16wftool = context.portal_workflow
    1617member = mtool.getAuthenticatedMember()
    1718if mtool.isAnonymousUser():
     
    7475
    7576info['student_name'] = student_record.name
    76 payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
    77 sos = context.portal_catalog(container_path=payments_path)
    78 info['is_so'] = is_so
    7977
    80 for so in sos:
     78for payment_id,payment in context.objectItems():
    8179    row = {}
    82     row['id'] = so.getId
    83     row['title'] = so.Title
    84     url = row['url'] = "%s/%s" % (payments_path,so.getId)
    85     so_doc = context.restrictedTraverse(url,default=None).getContent()
    86     row['type'] = so.portal_type
    87     review_state = row['review_state'] = so.review_state
    88     if so_doc.type_description.startswith('School Fee'):
    89         row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] in ('cleared_and_validated','returning')
     80    row['id'] = payment_id
     81    row['title'] = payment.Title()
     82    url = row['url'] = payment.absolute_url()
     83    payment_doc = payment.getContent()
     84    row['type'] = payment_doc.portal_type
     85    review_state = row['review_state'] = wftool.getInfoFor(payment,'review_state',None)
     86    if payment_doc.type_description.startswith('School Fee'):
     87        row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
    9088    else:
    91         row['is_approvable'] = False    # is_so and (review_state == "opened")
     89        row['is_approvable'] = is_so and (review_state == "opened")
    9290    row['is_requeryable'] = False
    9391    #set_trace()
    94     row['resp_desc'] = getattr(so_doc,'resp_desc','no response')
    95     row['trans_ref'] = getattr(so_doc,'order_id','')
    96     if so_doc.type_description.startswith('School Fee'):
    97         if (review_state == 'opened' and info['review_state'] in ('cleared_and_validated','returning') and \
    98                                   hasattr(so_doc, 'order_id') and not so_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
     92    row['resp_desc'] = getattr(payment_doc,'resp_desc','no response')
     93    row['trans_ref'] = getattr(payment_doc,'order_id','')
     94    if payment_doc.type_description.startswith('School Fee'):
     95        if (review_state == 'opened' and info['review_state'] in ('cleared_and_validated',) and \
     96            hasattr(payment_doc, 'order_id') and not payment_doc.resp_code) or str(member) in ('admin',):
    9997            row['is_requeryable'] = True
    100             row['callback_url'] = "%s/payments/%s/interswitch_cb" % (student.absolute_url(),
    101                                                             so.getId)
     98            row['callback_url'] = "%(url)s/interswitch_cb" % row
    10299            href = '%(query_url)s' % info
    103100            href += '?transRef=%(trans_ref)s' % row
     
    105102            href += '&redirectURL=%(callback_url)s' % row
    106103            row['href'] = href
    107     elif so_doc.type_description.startswith('Hostel'):
     104    elif payment_doc.type_description.startswith('Hostel'):
    108105        if (review_state == 'opened' and \
    109                                   hasattr(so_doc, 'order_id') and not so_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
     106            hasattr(payment_doc, 'order_id') and not payment_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
    110107            row['is_requeryable'] = True
    111             row['callback_url'] = "%s/payments/%s/interswitch_acco_cb" % (student.absolute_url(),
    112                                                             so.getId)
     108            row['callback_url'] = "%(url)s/interswitch_acco_cb" % row
    113109            href = '%(query_url)s' % info
    114110            href += '?transRef=%(trans_ref)s' % row
     
    116112            href += '&redirectURL=%(callback_url)s' % row
    117113            row['href'] = href
    118     if (review_state == "closed") and so_doc.resp_code in ('SC','00','AP','IP',):
     114    if (review_state == "closed") and payment_doc.resp_code in ('SC','00','AP','IP',):
    119115        row['confirmed'] = 'active'
    120116    else:
     
    122118    row['is_editable'] = is_so and (row['confirmed'] == 'active')
    123119    payments.append(row)
     120# payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
     121# sos = context.portal_catalog(container_path=payments_path)
     122# info['is_so'] = is_so
     123
     124# for so in sos:
     125#     row = {}
     126#     row['id'] = so.getId
     127#     row['title'] = so.Title
     128#     url = row['url'] = "%s/%s" % (payments_path,so.getId)
     129#     so_doc = context.restrictedTraverse(url,default=None).getContent()
     130#     row['type'] = so.portal_type
     131#     review_state = row['review_state'] = so.review_state
     132#     if so_doc.type_description.startswith('School Fee'):
     133#         row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] in ('cleared_and_validated','returning')
     134#     else:
     135#         row['is_approvable'] = False    # is_so and (review_state == "opened")
     136#     row['is_requeryable'] = False
     137#     #set_trace()
     138#     row['resp_desc'] = getattr(so_doc,'resp_desc','no response')
     139#     row['trans_ref'] = getattr(so_doc,'order_id','')
     140#     if so_doc.type_description.startswith('School Fee'):
     141#         if (review_state == 'opened' and info['review_state'] in ('cleared_and_validated','returning') and \
     142#                                   hasattr(so_doc, 'order_id') and not so_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
     143#             row['is_requeryable'] = True
     144#             row['callback_url'] = "%s/payments/%s/interswitch_cb" % (student.absolute_url(),
     145#                                                             so.getId)
     146#             href = '%(query_url)s' % info
     147#             href += '?transRef=%(trans_ref)s' % row
     148#             href += '&prodID=%(prod_id)s' % info
     149#             href += '&redirectURL=%(callback_url)s' % row
     150#             row['href'] = href
     151#     elif so_doc.type_description.startswith('Hostel'):
     152#         if (review_state == 'opened' and \
     153#                                   hasattr(so_doc, 'order_id') and not so_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
     154#             row['is_requeryable'] = True
     155#             row['callback_url'] = "%s/payments/%s/interswitch_acco_cb" % (student.absolute_url(),
     156#                                                             so.getId)
     157#             href = '%(query_url)s' % info
     158#             href += '?transRef=%(trans_ref)s' % row
     159#             href += '&prodID=%(prod_id)s' % info
     160#             href += '&redirectURL=%(callback_url)s' % row
     161#             row['href'] = href
     162#     if (review_state == "closed") and so_doc.resp_code in ('SC','00','AP','IP',):
     163#         row['confirmed'] = 'active'
     164#     else:
     165#         row['confirmed'] = 'unsuccessful'
     166#     row['is_editable'] = is_so and (row['confirmed'] == 'active')
     167#     payments.append(row)
    124168
    125169payments.sort(cmp_id)
Note: See TracChangeset for help on using the changeset viewer.