Index: main/waeup.futminna/trunk/src/waeup/futminna/applicants/browser.py
===================================================================
--- main/waeup.futminna/trunk/src/waeup/futminna/applicants/browser.py	(revision 10220)
+++ main/waeup.futminna/trunk/src/waeup/futminna/applicants/browser.py	(revision 10224)
@@ -38,4 +38,5 @@
     PG_OMIT_PDF_FIELDS,
     PG_OMIT_MANAGE_FIELDS,
+    PG_OMIT_EDIT_FIELDS,
     PUTME_OMIT_EDIT_FIELDS,
     PUTME_OMIT_DISPLAY_FIELDS,
@@ -101,6 +102,5 @@
     @property
     def form_fields(self):
-        target = getattr(self.context.__parent__, 'prefix', None)
-        if target is not None and target.startswith('pg'):
+        if self.target is not None and self.target.startswith('pg'):
             form_fields = grok.AutoFields(ICustomPGApplicant)
             for field in PG_OMIT_DISPLAY_FIELDS:
@@ -136,10 +136,9 @@
     @property
     def form_fields(self):
-        target = getattr(self.context.__parent__, 'prefix', None)
-        if target is not None and target.startswith('pg'):
+        if self.target is not None and self.target.startswith('pg'):
             form_fields = grok.AutoFields(ICustomPGApplicant)
             for field in PG_OMIT_PDF_FIELDS:
                 form_fields = form_fields.omit(field)
-        elif target is not None and target.startswith('putme'):
+        elif self.target is not None and self.target.startswith('putme'):
             form_fields = grok.AutoFields(ICustomUGApplicant)
             if self._reduced_slip():
@@ -169,10 +168,9 @@
     @property
     def form_fields(self):
-        target = getattr(self.context.__parent__, 'prefix', None)
-        if target is not None and target.startswith('pg'):
+        if self.target is not None and self.target.startswith('pg'):
             form_fields = grok.AutoFields(ICustomPGApplicant)
             for field in PG_OMIT_MANAGE_FIELDS:
                 form_fields = form_fields.omit(field)
-        elif target is not None and target.startswith('putme'):
+        elif self.target is not None and self.target.startswith('putme'):
             form_fields = grok.AutoFields(ICustomUGApplicant)
             for field in PUTME_OMIT_MANAGE_FIELDS:
@@ -225,10 +223,9 @@
     @property
     def form_fields(self):
-        target = getattr(self.context.__parent__, 'prefix', None)
-        if target is not None and target.startswith('pg'):
+        if self.target is not None and self.target.startswith('pg'):
             form_fields = grok.AutoFields(ICustomPGApplicantEdit)
             for field in PG_OMIT_EDIT_FIELDS:
                 form_fields = form_fields.omit(field)
-        elif target is not None and target.startswith('putme'):
+        elif self.target is not None and self.target.startswith('putme'):
             form_fields = grok.AutoFields(ICustomUGApplicantEdit)
             for field in PUTME_OMIT_EDIT_FIELDS:
@@ -252,5 +249,6 @@
         if not store.getFileByContext(self.context, attr=u'refereeform.pdf'):
             return _('No referee form pdf file uploaded.')
-        if not store.getFileByContext(self.context, attr=u'credentialform.pdf'):
+        if self.target is not None and self.target.startswith('pg') \
+            and not store.getFileByContext(self.context, attr=u'credentialform.pdf'):
             return _('No credential form pdf file uploaded.')
         if not self.request.form.get('confirm_passport', False):
Index: main/waeup.futminna/trunk/src/waeup/futminna/applicants/browser_templates/applicanteditpage.pt
===================================================================
--- main/waeup.futminna/trunk/src/waeup/futminna/applicants/browser_templates/applicanteditpage.pt	(revision 10220)
+++ main/waeup.futminna/trunk/src/waeup/futminna/applicants/browser_templates/applicanteditpage.pt	(revision 10224)
@@ -85,5 +85,5 @@
           <span tal:replace="view/max_file_upload_size">10 KB</span>
       </tr>
-      <tr>
+      <tr tal:condition="python: view.target.startswith('pg')">
         <td class="fieldname" i18n:translate="">
           Credential Form:
Index: main/waeup.futminna/trunk/src/waeup/futminna/applicants/tests/test_browser.py
===================================================================
--- main/waeup.futminna/trunk/src/waeup/futminna/applicants/tests/test_browser.py	(revision 10220)
+++ main/waeup.futminna/trunk/src/waeup/futminna/applicants/tests/test_browser.py	(revision 10224)
@@ -21,8 +21,11 @@
 
 import os
+import pytz
 import grok
+from datetime import datetime, date, timedelta
 from zope.event import notify
 from StringIO import StringIO
 from zope.component import createObject, getUtility
+from waeup.kofa.applicants.container import ApplicantsContainer
 from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
 from waeup.kofa.interfaces import (
@@ -249,48 +252,4 @@
         self.assertTrue(fd is None)
 
-    def test_upload_credentialform_by_student(self):
-        self.login()
-        self.browser.open(self.edit_path)
-        # Create a pseudo file and select it to be uploaded in form
-        pdf_content = 'A' * 1024 * 600  # A string of 600 KB size
-        pseudo_pdf = StringIO(pdf_content)
-        ctrl = self.browser.getControl(name='form.credentialform')
-        file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_pdf, filename='myform.pdf')
-        self.browser.getControl("Save").click() # submit form
-        # We get a warning message
-        self.assertTrue(
-            'Uploaded file is too big' in self.browser.contents)
-        # Create a pseudo file with acceptable size
-        pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
-        pseudo_pdf = StringIO(pdf_content)
-        ctrl = self.browser.getControl(name='form.credentialform')
-        file_ctrl = ctrl.mech_control
-        file_ctrl.add_file(pseudo_pdf, filename='myform.pdf')
-        self.browser.getControl("Save").click() # submit form
-        # Even though the form could not be saved ...
-        self.assertTrue('Required input is missing' in self.browser.contents)
-        # ... the file has been successfully uploaded
-        pdf_url = self.edit_path.replace('edit', 'credentialform.pdf')
-        self.browser.open(pdf_url)
-        self.assertEqual(
-            self.browser.headers['content-type'], 'application/pdf')
-        self.assertEqual(len(self.browser.contents), 307200)
-        # There is really a file stored for the applicant
-        storage = getUtility(IExtFileStore)
-        file_id = IFileStoreNameChooser(self.applicant).chooseName(
-            attr='credentialform.pdf')
-        # The stored file can be fetched
-        fd = storage.getFile(file_id)
-        file_len = len(fd.read())
-        self.assertEqual(file_len, 307200)
-        # A file link is displayed on the edit view ...
-        self.browser.open(self.edit_path)
-        self.assertTrue('<a href="credentialform.pdf">' in self.browser.contents)
-        # ... and on the dislay view
-        self.browser.open(self.view_path)
-        self.assertTrue('<a href="credentialform.pdf">Credential Form</a>'
-            in self.browser.contents)
-
     def test_upload_credentialform_by_manager(self):
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
@@ -299,4 +258,34 @@
         pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
         pseudo_pdf = StringIO(pdf_content)
+        # This is a ug applicant, thus the credential form is not
+        # required
+        self.assertFalse('credentialform">' in self.browser.contents)
+
+        # We have to add a pg applicants container
+        container_name = u'pg%s' % (datetime.now().year - 1)
+        applicantscontainer = ApplicantsContainer()
+        applicantscontainer.code = container_name
+        applicantscontainer.prefix = 'pgft'
+        applicantscontainer.year = datetime.now().year - 1
+        applicantscontainer.title = u'This is the %s container' % container_name
+        applicantscontainer.application_category = 'pg_ft'
+        applicantscontainer.mode = 'create'
+        applicantscontainer.strict_deadline = True
+        delta = timedelta(days=10)
+        applicantscontainer.startdate = datetime.now(pytz.utc) - delta
+        applicantscontainer.enddate = datetime.now(pytz.utc) + delta
+        self.app['applicants'][container_name] = applicantscontainer
+        applicant = createObject('waeup.Applicant')
+        # reg_number is the only field which has to be preset here
+        # because managers are allowed to edit this required field
+        applicant.reg_number = u'2345'
+        applicant.course1 = self.certificate
+        self.app['applicants'][container_name].addApplicant(applicant)
+        self.manage_path_pg = 'http://localhost/app/applicants/%s/%s/%s' % (
+            container_name, applicant.application_number, 'manage')
+        self.view_path_pg = 'http://localhost/app/applicants/%s/%s' % (
+            container_name, applicant.application_number)
+
+        self.browser.open(self.manage_path_pg)
         ctrl = self.browser.getControl(name='form.credentialform')
         file_ctrl = ctrl.mech_control
@@ -306,5 +295,5 @@
         self.assertTrue('Required input is missing' in self.browser.contents)
         # ... the file has been successfully uploaded
-        pdf_url = self.manage_path.replace('manage', 'credentialform.pdf')
+        pdf_url = self.manage_path_pg.replace('manage', 'credentialform.pdf')
         self.browser.open(pdf_url)
         self.assertEqual(
@@ -313,5 +302,5 @@
         # There is rally a file stored for the applicant
         storage = getUtility(IExtFileStore)
-        file_id = IFileStoreNameChooser(self.applicant).chooseName(
+        file_id = IFileStoreNameChooser(applicant).chooseName(
             attr='credentialform.pdf')
         # The stored file can be fetched
@@ -320,8 +309,8 @@
         self.assertEqual(file_len, 307200)
         # A file link is displayed on the edit view ...
-        self.browser.open(self.manage_path)
+        self.browser.open(self.manage_path_pg)
         self.assertTrue('<a href="credentialform.pdf">' in self.browser.contents)
         # ... and on the dislay view
-        self.browser.open(self.view_path)
+        self.browser.open(self.view_path_pg)
         self.assertTrue('<a href="credentialform.pdf">Credential Form</a>'
             in self.browser.contents)
@@ -333,8 +322,8 @@
             'zope.mgr - waeup.futminna.applicants.browser.CustomApplicantManageFormPage'
             ' - %s - saved: credentialform'
-            % (self.applicant.applicant_id)
+            % (applicant.applicant_id)
             in logcontent)
         # When an applicant is removed, also the pdf files are gone.
-        del self.app['applicants']['app2011'][self.applicant.application_number]
+        del self.app['applicants'][container_name][applicant.application_number]
         fd = storage.getFile(file_id)
         self.assertTrue(fd is None)
