Index: main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py	(revision 14630)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py	(revision 14631)
@@ -19,7 +19,10 @@
 import grok
 from zope.component import getUtility
+from zope.interface import implementer, Interface, Attribute
 from waeup.kofa.interfaces import IKofaUtils
 from waeup.kofa.students.reports.session_results_presentation import (
-    SessionResultsPresentation, SessionResultsPresentationGenerator)
+    SessionResultsPresentation, SessionResultsPresentationGenerator,
+    ISessionResultsPresentation, SessionResultsPresentationGeneratorPage,
+    SessionResultsPresentationPDFView)
 
 class CustomSessionResultsPresentation(SessionResultsPresentation):
@@ -90,2 +93,57 @@
             level=level, author=author)
         return result
+
+
+# Session Results Presentation for graduating students only
+
+class IGradSessionResultsPresentation(ISessionResultsPresentation):
+    """Marker interface to distuingish graduating students level reports
+    from ordinary level reports.
+    """
+
+@implementer(IGradSessionResultsPresentation)
+class GradSessionResultsPresentation(CustomSessionResultsPresentation):
+    """
+    """
+
+    title = 'Presentation of Results to Senate'
+
+    @property
+    def right_footer(self):
+        return self.title + ' (graduating students only) - %s -' % self.session
+
+    def _excluded(self, level_obj):
+        """
+        """
+        final_level = max(level_obj.student['studycourse'].keys())
+        final_level_obj = level_obj.student['studycourse'][final_level]
+        if final_level_obj.remark not in (
+            'Pass', '3s_rd_s', '2s_2_s', '2s_1_s', '1s_st_s'):
+            return True
+        return False
+
+class GradSessionResultsPresentationGenerator(SessionResultsPresentationGenerator):
+
+    title = 'Presentation of Graduating Students Results to Senate'
+    grok.name('grad_session_results_presentation')
+
+    def generate(self, site, faccode=None, depcode=None, certcode=None,
+                 session=None, level=None, author=None):
+        result = GradSessionResultsPresentation(faccode=faccode, depcode=depcode,
+            certcode=certcode, session=session, level=level, author=author)
+        return result
+
+class GradSessionResultsPresentationGeneratorPage(SessionResultsPresentationGeneratorPage):
+
+    grok.context(GradSessionResultsPresentationGenerator)
+
+class GradSessionResultsPresentationPDFView(SessionResultsPresentationPDFView):
+
+    grok.context(IGradSessionResultsPresentation)
+    grok.name('pdf')
+    grok.require('waeup.handleReports')
+
+    def _filename(self):
+        return 'GradSessionResultsPresentation_rno%s_%s.pdf' % (
+            self.context.__name__,
+            self.context.creation_dt_string)
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py	(revision 14630)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py	(revision 14631)
@@ -12,5 +12,8 @@
 from waeup.kofa.browser.tests.test_pdf import samples_dir
 
-from waeup.aaue.students.reports.session_results_presentation import CustomSessionResultsPresentation
+from waeup.aaue.students.reports.session_results_presentation import (
+    CustomSessionResultsPresentation,
+    GradSessionResultsPresentation,
+    IGradSessionResultsPresentation)
 
 from waeup.aaue.testing import FunctionalLayer
@@ -40,5 +43,4 @@
         return
 
-
     def test_create_pdf(self):
         self.certificate.degree = 'BA(FS)'
@@ -55,2 +57,46 @@
 
  
+class GradSessionResultsPresentationTests(CatalogTestSetup):
+
+    layer = FunctionalLayer
+
+    def test_iface(self):
+        # ensure we fullfill interface contracts
+        obj = GradSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
+        verifyClass(IGradSessionResultsPresentation, GradSessionResultsPresentation)
+        verifyObject(IGradSessionResultsPresentation, obj)
+        return
+
+    def test_get_students(self):
+        sr = GradSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
+        result = sr._get_students('fac1', 'dep1', 'CERT1', 2010, 100)
+        self.assertEqual(result, [[], [], [], [], [], [], []])
+        # if end level is 100, the student seems graduating and
+        # we can get a table with one student
+        self.certificate.end_level = 100
+        self.student['studycourse']['100']['Course1'].credits = 91
+        result = sr._get_students('fac1', 'dep1', 'CERT1', 2010, 100)
+        self.assertEqual(result, [[], [], [], [], [], [], []])
+        self.student['studycourse']['100']['Course1'].score = 60
+        self.student['studycourse']['100']['Course1'].ca = 10
+        result = sr._get_students('fac1', 'dep1', 'CERT1', 2010, 100)
+        self.assertEqual(result,
+            [[], [], [], [], [], [(u'E1000000', u'1234', u'TESTER, Bob')], []])
+        return
+
+    def test_create_pdf(self):
+        self.certificate.degree = 'BA(FS)'
+        self.certificate.end_level = 100
+        self.student['studycourse']['100']['Course1'].credits = 91
+        self.student['studycourse']['100']['Course1'].ca = 0
+        self.app['faculties']['fac1'].officer_1 = 'Rosa Moonshine - Dean of Faculty'
+        self.app['faculties']['fac1']['dep1'].officer_1 = 'Amalia Sunshine - Head of Department'
+        self.app['faculties']['fac1']['dep1'].officer_2 = 'Theresa Starbright - External Examiner'
+        report = GradSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
+        result = report.create_pdf('JOB_ID')
+        self.assertTrue(result.startswith('%PDF-'))
+        path = os.path.join(samples_dir(), 'grad_session_results_presentation.pdf')
+        open(path, 'wb').write(result)
+        print "Sample grad_session_results_presentation.pdf written to %s" % path
+        return
+
