Index: /WAeUP_SRP/trunk/CHANGES.txt
===================================================================
--- /WAeUP_SRP/trunk/CHANGES.txt	(revision 3735)
+++ /WAeUP_SRP/trunk/CHANGES.txt	(revision 3736)
@@ -98,2 +98,6 @@
 - do not cache action portlet
 - allow graduate transition for more states
+
+1.18 (2008-10-26)
+-----------------
+- implement gown hiring
Index: /WAeUP_SRP/trunk/profiles/default/layouts.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 3735)
+++ /WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 3736)
@@ -114,4 +114,5 @@
   <object name="upload" meta_type="CPS Layout"/>
   <object name="waeup_common" meta_type="CPS Layout"/> 
+  <object name="student_gown" meta_type="CPS Layout"/>
  
 </object>
Index: /WAeUP_SRP/trunk/profiles/default/layouts/student_gown.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/student_gown.xml	(revision 3736)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/student_gown.xml	(revision 3736)
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="layout.xsl"?>
+<object name="student_gown" meta_type="CPS Layout">
+  <property name="layout_create_method"></property>
+  <property name="layout_edit_method"></property>
+  <property name="layout_view_method"></property>
+  <property name="style_prefix">layout_application_</property>
+  <property name="flexible_widgets"/>
+  <property name="validate_values_expr"></property>
+  <widget name="pin" meta_type="Scratchcard Pin Widget">
+    <property name="title">Gown Scratch Card</property>
+    <property name="fields">
+      <element value="order_id"/>
+    </property>
+    <property name="label">Access Code</property>
+    <property name="label_edit">Access Code</property>
+    <property name="readonly_layout_modes"/>
+    <property name="hidden_layout_modes"/>
+    <property name="hidden_readonly_layout_modes"/>
+    <property name="prefix">GWN</property>
+  </widget>
+  <table>
+    <row>
+      <cell name="pin"/>
+    </row>
+  </table>
+</object>
Index: /WAeUP_SRP/trunk/profiles/default/vocabularies/payment_categories.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/vocabularies/payment_categories.xml	(revision 3735)
+++ /WAeUP_SRP/trunk/profiles/default/vocabularies/payment_categories.xml	(revision 3736)
@@ -11,3 +11,4 @@
     <item key="schoolfee" msgid="">School Fee</item>
     <item key="transfer" msgid="">Transfer</item>
+    <item key="gown" msgid="">Gown Hire</item>
 </object>
Index: /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 3735)
+++ /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 3736)
@@ -222,7 +222,4 @@
   <exit-transition transition_id="create_content"/>
   <exit-transition transition_id="enter_application_pin"/>
-  <exit-transition transition_id="pume_fail"/>
-  <exit-transition transition_id="pume_pass"/>
-  <exit-transition transition_id="reject_admission"/>
   <exit-transition transition_id="return"/>
   <exit-transition transition_id="deactivate"/>
Index: /WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentsFolderInfo.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentsFolderInfo.py	(revision 3735)
+++ /WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentsFolderInfo.py	(revision 3736)
@@ -73,4 +73,12 @@
 info['prod_id'] = '61'
 
+try:
+    level = int(student_record.level)
+    end_level = int(student_record.end_level)
+    if level >= end_level:
+        info['gown'] = True
+except:
+    pass
+
 # end customization
 
Index: /WAeUP_SRP/trunk/skins/waeup_epayment/payments_view.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/payments_view.pt	(revision 3735)
+++ /WAeUP_SRP/trunk/skins/waeup_epayment/payments_view.pt	(revision 3736)
@@ -84,5 +84,15 @@
                    tal:attributes="value string:Pay ${info/next_session_str} School Fee by Scratch Card"
                    />
-          </form>          
+          </form>    
+          
+          <form tal:condition="info/gown|nothing" 
+                tal:attributes="action string: ${context/absolute_url}/request_gown" method="post" class="group">
+            <input type="submit" name="epayment" 
+                   class="context" 
+                   value="Initiate Gown Hiring" 
+                   />
+          </form>            
+          
+                
           <div tal:condition="info/reasons">
             <font color="red" tal:content="info/reasons"></font>
Index: /WAeUP_SRP/trunk/skins/waeup_epayment/request_gown.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/request_gown.py	(revision 3736)
+++ /WAeUP_SRP/trunk/skins/waeup_epayment/request_gown.py	(revision 3736)
@@ -0,0 +1,115 @@
+## Script (Python) "request_gown"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id: request_gown.py 3256 2008-02-29 06:51:46Z henrik $
+"""
+pay online
+"""
+import logging
+from urllib import urlencode
+logger = logging.getLogger('Skins.request_gown')
+import DateTime
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+
+if context.portal_membership.isAnonymousUser():
+    return None
+wftool = context.portal_workflow
+lt = context.portal_layouts
+request = context.REQUEST
+students = context.portal_url.getPortalObject().campus.students
+student_id = context.getStudentId()
+if student_id is None:
+    return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
+
+student = getattr(students,student_id)
+student_record = context.students_catalog.getRecordByKey(student_id)
+session = context.getSessionId()
+
+validate = request.has_key("cpsdocument_create_button")
+res,psm,ds = lt.renderLayout(layout_id= 'student_gown',
+                      schema_id= 'payment',
+                      context=context,
+                      mapping=validate and request,
+                      ob={},
+                      layout_mode="create",
+                      formaction = "request_gown",
+                      button = 'Pay',
+                      commit = False,
+                      )
+if psm == 'invalid':
+    psm = 'Please correct your errors!'
+    return context.request_gown_form(rendered = res,
+                                 psm = psm,
+                                 mode = 'edit',
+                                 #session_str = session[1],
+                                 ds = ds,
+                                 )
+elif psm == '':
+    return context.request_gown_form(rendered = res,
+                                 psm = None,
+                                 mode = 'edit',
+                                 #session_str = session[1],
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    pass
+if "payments" not in student.objectIds():
+    student.invokeFactory('PaymentsFolder','payments')
+    payments = getattr(student,'payments')
+    d = {}
+    d['Title'] = 'Payments'
+    payments.getContent().edit(mapping=d)
+    wftool.doActionFor(payments,'open')
+else:
+    payments = getattr(student,'payments')
+#from Products.zdb import set_trace; set_trace()
+info = {}
+p_id = "p%s" % ds.get('pin_n')
+pin = str(ds.get('pin'))
+try:
+    cost = context.portal_pins(pin="".join(pin.split('-')))[0].cost
+except:
+    cost = "n/a"
+try:
+    x = float(cost)
+except:
+    cost = "n/a"
+
+if not hasattr(payments,p_id):
+    now = DateTime.DateTime()
+    info['date'] = now
+    info['amount'] = cost
+    pin = info['order_id'] = "%s" % pin
+    #info['type_code'] = "%s" % pin  #type_code is redundant and will be removed soon
+    info['type_description'] = 'Gown Hire'
+    info['type'] = 'sc'
+    info['status'] = 'paid'
+    info['session_id'] = session[0]
+    info['item'] = ''
+    info['category'] = 'gown'
+    info['resp_code'] = "SC"
+    info['resp_desc'] = "SC Payment Successful"
+    payments.invokeFactory('Payment', p_id)
+    payment = getattr(payments,p_id)
+    wftool = context.portal_workflow
+    wftool.doActionFor(payment,'open')
+    payment.getContent().edit(mapping=info)
+    wftool.doActionFor(payment,'close')
+
+
+    logger.info('%s paid gown by scratch card' % student_id)
+else:
+    logger.info('%s repeatedly paid gown by scratch card' % student_id)
+url = "%s/payments" % (student.absolute_url())
+request.RESPONSE.redirect(url)
+
Index: /WAeUP_SRP/trunk/skins/waeup_epayment/request_gown_form.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/request_gown_form.pt	(revision 3736)
+++ /WAeUP_SRP/trunk/skins/waeup_epayment/request_gown_form.pt	(revision 3736)
@@ -0,0 +1,18 @@
+<metal:block use-macro="here/main_template/macros/master">
+    <metal:main fill-slot="header" />
+    <metal:main fill-slot="main"
+                    tal:define="rendered_main options/rendered;
+                            portal_status_message options/psm;
+                            paid options/paid|nothing;
+                            session_str python:context.getSessionId()[1]">
+
+
+        <span tal:condition="rendered_main">
+          <h3>Hire Gown for Session <span tal:replace="session_str" />!</h3>
+          <br />
+          <div tal:replace="structure rendered_main" />
+        </span>          
+
+     
+    </metal:main>
+</metal:block>
