Ignore:
Timestamp:
13 Jul 2024, 06:40:06 (4 months ago)
Author:
Henrik Bettermann
Message:

Add note to attendance sheet.

Location:
main/kofacustom.unidel/trunk/src/kofacustom/unidel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/ftesting.zcml

    r17300 r17843  
    5353      principal="zope.Anybody"
    5454      />
    55 
     55  <grant
     56      permission="waeup.Authenticated"
     57      principal="zope.Authenticated" />
    5658
    5759  <principal
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/browser.py

    r17832 r17843  
    3535    StudentTriggerTransitionFormPage,
    3636    ExportPDFAdmissionSlip,
     37    ExportAttendanceSlip,
    3738    PaymentsManageFormPage, msave, emit_lock_message)
    3839from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket, IStudentBase
     
    302303            note=self.note)
    303304
    304 class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
    305     grok.require('waeup.managePortal')
    306 
     305
     306class CustomExportAttendanceSlip(ExportAttendanceSlip):
     307    """
     308    """
     309
     310    #def _signatures(self):
     311    #    return ([_('Student Signature')],
     312    #            [_('Clearance Officer Signature')])
     313
     314    @property
     315    def note(self):
     316        return """
     317
     318       
     319Faculty: __________________________________________________________
     320
     321Department: ______________________________________________________
     322
     323Date of Examination: _______________________________________________
     324
     325Time of Examination: _______________________________________________
     326
     327Venue of Examination: ______________________________________________
     328
     329Names of Supervisors:
     330
     331______________________________________________
     332
     333______________________________________________
     334
     335______________________________________________
     336
     337______________________________________________
     338
     339______________________________________________
     340        """
     341
     342    def render(self):
     343        lecturers = [i['user_title'] for i in self.getUsersWithLocalRoles()
     344                     if i['local_role'] == 'waeup.local.Lecturer']
     345        lecturers =  ', '.join(lecturers)
     346        students_utils = getUtility(IStudentsUtils)
     347        return students_utils.renderPDFCourseticketsOverview(
     348            self, 'attendance', self.current_academic_session,
     349            self.data(self.current_academic_session),
     350            lecturers, '', 65, self.note)
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/tests/test_browser.py

    r17715 r17843  
    3434from waeup.kofa.interfaces import (
    3535    IExtFileStore, IFileStoreNameChooser)
     36from waeup.kofa.interfaces import IUserAccount, IJobManager, VALIDATED, CREATED
    3637from waeup.kofa.browser.tests.test_pdf import samples_dir
    3738from waeup.kofa.students.interfaces import IStudentsUtils
     39from waeup.kofa.tests.test_authentication import SECRET
    3840from kofacustom.unidel.testing import FunctionalLayer
    3941
     
    6870        open(path, 'wb').write(self.browser.contents)
    6971        print "Sample exampclearance_slip.pdf written to %s" % path
     72
     73class LecturerUITests(StudentsFullSetup):
     74
     75    layer = FunctionalLayer
     76
     77    def login_as_lecturer(self):
     78        self.app['users'].addUser('mrslecturer', SECRET)
     79        self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng'
     80        self.app['users']['mrslecturer'].title = u'Mercedes Benz'
     81        # Add course ticket
     82        self.studylevel = createObject(u'waeup.StudentStudyLevel')
     83        self.studylevel.level = 100
     84        self.studylevel.level_session = 2004
     85        self.student['studycourse'].addStudentStudyLevel(
     86            self.certificate, self.studylevel)
     87        # Assign local Lecturer role for a course.
     88        course = self.app['faculties']['fac1']['dep1'].courses['COURSE1']
     89        prmlocal = IPrincipalRoleManager(course)
     90        prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer')
     91        notify(LocalRoleSetEvent(
     92            course, 'waeup.local.Lecturer', 'mrslecturer', granted=True))
     93        # Login as lecturer.
     94        self.browser.open(self.login_path)
     95        self.browser.getControl(name="form.login").value = 'mrslecturer'
     96        self.browser.getControl(
     97            name="form.password").value = SECRET
     98        self.browser.getControl("Login").click()
     99        # Store reused urls/paths
     100        self.course_url = (
     101            'http://localhost/app/faculties/fac1/dep1/courses/COURSE1')
     102        self.edit_scores_url = '%s/edit_scores' % self.course_url
     103        # Set standard parameters
     104        self.app['configuration'].current_academic_session = 2004
     105        self.app['faculties']['fac1']['dep1'].score_editing_disabled = False
     106        IWorkflowState(self.student).setState(VALIDATED)
     107
     108    def test_lecturers_can_download_attendance_sheet(self):
     109        # A course ticket slip can be downloaded
     110        self.course.title = (u'Lorem ipsum     dolor sit amet, consectetur     adipisici, '
     111                             u'sed         eiusmod tempor    incidunt ut  labore et dolore')
     112        self.student.firstname = u'Emmanuella Woyengifigha Mercy Onosemudiana'
     113        self.student.lastname = u'OYAKEMIEGBEGHA'
     114        self.student.matric_number = u'CMS/FBM/NSG/17/38186'
     115        self.login_as_lecturer()
     116        pdf_url = '%s/attendance.pdf' % self.course_url
     117        self.browser.open(pdf_url)
     118        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     119        self.assertEqual(
     120            self.browser.headers['Content-Type'], 'application/pdf')
     121        path = os.path.join(samples_dir(), 'attendance.pdf')
     122        open(path, 'wb').write(self.browser.contents)
     123        print "Sample PDF attendance.pdf written to %s" % path
Note: See TracChangeset for help on using the changeset viewer.