Index: main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py
===================================================================
--- main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py	(revision 8715)
+++ main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py	(revision 8720)
@@ -30,7 +30,8 @@
     StudentBaseEditFormPage, StudentPersonalEditFormPage,
     OnlinePaymentDisplayFormPage, OnlinePaymentAddFormPage,
-    OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage)
+    OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage,
+    StudentFilesUploadPage, emit_lock_message)
 from waeup.kofa.students.viewlets import (
-    PaymentReceiptActionButton)
+    PaymentReceiptActionButton, StudentPassportActionButton)
 from waeup.uniben.students.interfaces import (
     ICustomStudentBase, ICustomStudent, ICustomStudentPersonal,
@@ -38,4 +39,5 @@
     ICustomStudentOnlinePayment,
     )
+from waeup.kofa.students.workflow import ADMITTED
 from waeup.uniben.interfaces import MessageFactory as _
 
@@ -166,10 +168,10 @@
     form_fields[
         'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
-    grok.template('payment_view')
-
-    @property
-    def transaction_code(self):
-        tcode = self.context.p_id
-        return tcode[len(tcode)-8:len(tcode)]
+    #grok.template('payment_view')
+
+    #@property
+    #def transaction_code(self):
+    #    tcode = self.context.p_id
+    #    return tcode[len(tcode)-8:len(tcode)]
 
 class CustomOnlinePaymentAddFormPage(OnlinePaymentAddFormPage):
@@ -200,12 +202,38 @@
     form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
 
-    @property
-    def note(self):
-        tcode = self.context.p_id
-        tcode = tcode[len(tcode)-8:len(tcode)]
-        amount = self.context.amount_auth
-        note = translate(_(
-            u"""<br /><br /><br />
-The tranzaction code is <strong>${a}</strong>.""",
-            mapping = {'a':tcode}))
-        return note
+#    @property
+#    def note(self):
+#        tcode = self.context.p_id
+#        tcode = tcode[len(tcode)-8:len(tcode)]
+#        amount = self.context.amount_auth
+#        note = translate(_(
+#            u"""<br /><br /><br />
+#The tranzaction code is <strong>${a}</strong>.""",
+#            mapping = {'a':tcode}))
+#        return note
+
+class StudentPassportActionButton(StudentPassportActionButton):
+
+    @property
+    def target_url(self):
+        slip = getUtility(IExtFileStore).getFileByContext(
+            self.context, 'application_slip')
+        if self.context.state != ADMITTED or slip is not None:
+            return ''
+        return self.view.url(self.view.context, self.target)
+
+class CustomStudentFilesUploadPage(StudentFilesUploadPage):
+    """ View to upload passport picture.
+
+    Students are not allowed to change the picture if they
+    passed the regular Kofa application.
+    """
+
+    def update(self):
+        slip = getUtility(IExtFileStore).getFileByContext(
+            self.context, 'application_slip')
+        if self.context.state != ADMITTED or slip is not None:
+            emit_lock_message(self)
+            return
+        super(StudentFilesUploadPage, self).update()
+        return
Index: main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
===================================================================
--- main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py	(revision 8715)
+++ main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py	(revision 8720)
@@ -19,4 +19,5 @@
 import shutil
 import tempfile
+from StringIO import StringIO
 from hurry.workflow.interfaces import IWorkflowState
 from zope.component.hooks import setSite, clearSite
@@ -26,4 +27,6 @@
 from waeup.kofa.students.tests.test_browser import StudentsFullSetup
 from waeup.kofa.testing import FunctionalTestCase
+from waeup.kofa.interfaces import (
+    IExtFileStore, IFileStoreNameChooser)
 from waeup.kofa.students.batching import StudentProcessor
 from waeup.kofa.students.interfaces import IStudentsUtils
@@ -287,4 +290,18 @@
         self.browser.getControl(name="form.password").value = 'spwd'
         self.browser.getControl("Login").click()
+        # Even in state admitted students can't change the portait if
+        # application slip exists.
+        IWorkflowState(self.student).setState('admitted')
+        self.browser.open(self.student_path)
+        self.assertTrue('Change portrait' in self.browser.contents)
+        file_store = getUtility(IExtFileStore)
+        applicant_slip = 'My application slip'
+        file_id = IFileStoreNameChooser(self.student).chooseName(
+            attr="application_slip.pdf")
+        file_store.createFile(file_id, StringIO(applicant_slip))
+        self.browser.open(self.student_path)
+        self.assertFalse('Change portrait' in self.browser.contents)
+        self.browser.open(self.student_path + '/change_portrait')
+        self.assertTrue('The requested form is locked' in self.browser.contents)
         # Student can view and edit clearance data
         self.browser.getLink("Clearance Data").click()
